Class: Bundler::Resolver::Package
Relationships & Source Files | |
Extension / Inclusion / Inheritance Descendants | |
Subclasses:
|
|
Inherits: | Object |
Defined in: | lib/bundler/resolver/package.rb |
Overview
Represents a gem being resolved, in a format ::Bundler::PubGrub
likes.
The class holds the following information:
-
Platforms this gem will be resolved on.
-
The locked version of this gem resolution should favor (if any).
-
Whether the gem should be unlocked to its latest version.
-
The dependency explicit set in the Gemfile for this gem (if any).
Class Method Summary
Instance Attribute Summary
- #current_platform? ⇒ Boolean readonly
- #dependency readonly
- #force_ruby_platform? ⇒ Boolean readonly
- #ignores_prereleases? ⇒ Boolean readonly
- #locked_version readonly
- #meta? ⇒ Boolean readonly
- #name readonly
- #platforms readonly
- #prefer_local? ⇒ Boolean readonly
- #prerelease_specified? ⇒ Boolean readonly
- #root? ⇒ Boolean readonly
- #top_level? ⇒ Boolean readonly
- #unlock? ⇒ Boolean readonly
Instance Method Summary
Constructor Details
.new(name, platforms, locked_specs:, unlock:, prerelease: false, prefer_local: false, dependency: nil) ⇒ Package
# File 'lib/bundler/resolver/package.rb', line 18
def initialize(name, platforms, locked_specs:, unlock:, prerelease: false, prefer_local: false, dependency: nil) @name = name @platforms = platforms @locked_version = locked_specs[name].first&.version @unlock = unlock @dependency = dependency || Dependency.new(name, @locked_version) @top_level = !dependency.nil? @prerelease = @dependency.prerelease? || @locked_version&.prerelease? || prerelease ? :consider_first : :ignore @prefer_local = prefer_local end
Instance Attribute Details
#current_platform? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'lib/bundler/resolver/package.rb', line 85
def current_platform? @dependency.current_platform? end
#dependency (readonly)
[ GitHub ]# File 'lib/bundler/resolver/package.rb', line 16
attr_reader :name, :platforms, :dependency, :locked_version
#force_ruby_platform? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'lib/bundler/resolver/package.rb', line 81
def force_ruby_platform? @dependency.force_ruby_platform end
#ignores_prereleases? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'lib/bundler/resolver/package.rb', line 61
def ignores_prereleases? @prerelease == :ignore end
#locked_version (readonly)
[ GitHub ]# File 'lib/bundler/resolver/package.rb', line 16
attr_reader :name, :platforms, :dependency, :locked_version
#meta? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'lib/bundler/resolver/package.rb', line 45
def @name.end_with?("\0") end
#name (readonly)
[ GitHub ]# File 'lib/bundler/resolver/package.rb', line 16
attr_reader :name, :platforms, :dependency, :locked_version
#platforms (readonly)
[ GitHub ]# File 'lib/bundler/resolver/package.rb', line 16
attr_reader :name, :platforms, :dependency, :locked_version
#prefer_local? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'lib/bundler/resolver/package.rb', line 73
def prefer_local? @prefer_local end
#prerelease_specified? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'lib/bundler/resolver/package.rb', line 65
def prerelease_specified? @prerelease == :consider_first end
#root? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'lib/bundler/resolver/package.rb', line 37
def root? false end
#top_level? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'lib/bundler/resolver/package.rb', line 41
def top_level? @top_level end
#unlock? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'lib/bundler/resolver/package.rb', line 57
def unlock? @unlock.empty? || @unlock.include?(name) end
Instance Method Details
#==(other)
[ GitHub ]# File 'lib/bundler/resolver/package.rb', line 49
def ==(other) self.class == other.class && @name == other.name end
#consider_prereleases!
[ GitHub ]# File 'lib/bundler/resolver/package.rb', line 69
def consider_prereleases! @prerelease = :consider_last end
#consider_remote_versions!
[ GitHub ]# File 'lib/bundler/resolver/package.rb', line 77
def consider_remote_versions! @prefer_local = false end
#hash
[ GitHub ]# File 'lib/bundler/resolver/package.rb', line 53
def hash @name.hash end
#platform_specs(specs)
[ GitHub ]# File 'lib/bundler/resolver/package.rb', line 29
def platform_specs(specs) platforms.map {|platform| GemHelpers.select_best_platform_match(specs, platform, prefer_locked: !unlock?) } end
#to_s
[ GitHub ]# File 'lib/bundler/resolver/package.rb', line 33
def to_s @name.delete("\0") end