mirror of
https://github.com/ruby/ruby.git
synced 2025-08-24 21:44:30 +02:00

For installed specifications, we can ignore any constraints they may
have, since we know they match the current version of Ruby or otherwise
would not be installed.
For remote specifications, we already resolve optimistically without
metadata and retry force-fetching it if necessary.
If in the future we support resolving against a Ruby version different
that the one being run, we'll probably need to change this but now it's
unnecessary and saves some memory.
### Before
Total allocated: 262.99 MB (3177437 objects)
Total retained: 115.91 MB (1297821 objects)
### After
Total allocated: 259.89 MB (3134199 objects)
Total retained: 115.05 MB (1283779 objects)
201c1863fc
30 lines
769 B
Ruby
30 lines
769 B
Ruby
# frozen_string_literal: true
|
|
|
|
module Bundler
|
|
module MatchMetadata
|
|
def matches_current_metadata?
|
|
matches_current_ruby? && matches_current_rubygems?
|
|
end
|
|
|
|
def matches_current_ruby?
|
|
@required_ruby_version.satisfied_by?(Gem.ruby_version)
|
|
end
|
|
|
|
def matches_current_rubygems?
|
|
@required_rubygems_version.satisfied_by?(Gem.rubygems_version)
|
|
end
|
|
|
|
def expanded_dependencies
|
|
runtime_dependencies + [
|
|
metadata_dependency("Ruby", @required_ruby_version),
|
|
metadata_dependency("RubyGems", @required_rubygems_version),
|
|
].compact
|
|
end
|
|
|
|
def metadata_dependency(name, requirement)
|
|
return if requirement.nil? || requirement.none?
|
|
|
|
Gem::Dependency.new("#{name}\0", requirement)
|
|
end
|
|
end
|
|
end
|