Class: Bundler::Resolver::Package
- Inherits:
-
Object
- Object
- Bundler::Resolver::Package
- Defined in:
- lib/bundler/resolver/package.rb
Overview
Represents a gem being resolved, in a format 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).
Direct Known Subclasses
Instance Attribute Summary collapse
-
#dependency ⇒ Object
readonly
Returns the value of attribute dependency.
-
#locked_version ⇒ Object
readonly
Returns the value of attribute locked_version.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#platforms ⇒ Object
readonly
Returns the value of attribute platforms.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #consider_prereleases! ⇒ Object
- #consider_remote_versions! ⇒ Object
- #current_platform? ⇒ Boolean
- #force_ruby_platform? ⇒ Boolean
- #hash ⇒ Object
- #ignores_prereleases? ⇒ Boolean
-
#initialize(name, platforms, locked_specs:, unlock:, prerelease: false, prefer_local: false, dependency: nil) ⇒ Package
constructor
A new instance of Package.
- #meta? ⇒ Boolean
- #platform_specs(specs) ⇒ Object
- #prefer_local? ⇒ Boolean
- #prerelease_specified? ⇒ Boolean
- #root? ⇒ Boolean
- #to_s ⇒ Object
- #top_level? ⇒ Boolean
- #unlock? ⇒ Boolean
Constructor Details
#initialize(name, platforms, locked_specs:, unlock:, prerelease: false, prefer_local: false, dependency: nil) ⇒ Package
Returns a new instance of Package.
18 19 20 21 22 23 24 25 26 27 |
# 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
#dependency ⇒ Object (readonly)
Returns the value of attribute dependency.
16 17 18 |
# File 'lib/bundler/resolver/package.rb', line 16 def dependency @dependency end |
#locked_version ⇒ Object (readonly)
Returns the value of attribute locked_version.
16 17 18 |
# File 'lib/bundler/resolver/package.rb', line 16 def locked_version @locked_version end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
16 17 18 |
# File 'lib/bundler/resolver/package.rb', line 16 def name @name end |
#platforms ⇒ Object (readonly)
Returns the value of attribute platforms.
16 17 18 |
# File 'lib/bundler/resolver/package.rb', line 16 def platforms @platforms end |
Instance Method Details
#==(other) ⇒ Object
49 50 51 |
# File 'lib/bundler/resolver/package.rb', line 49 def ==(other) self.class == other.class && @name == other.name end |
#consider_prereleases! ⇒ Object
69 70 71 |
# File 'lib/bundler/resolver/package.rb', line 69 def consider_prereleases! @prerelease = :consider_last end |
#consider_remote_versions! ⇒ Object
77 78 79 |
# File 'lib/bundler/resolver/package.rb', line 77 def consider_remote_versions! @prefer_local = false end |
#current_platform? ⇒ Boolean
85 86 87 |
# File 'lib/bundler/resolver/package.rb', line 85 def current_platform? @dependency.current_platform? end |
#force_ruby_platform? ⇒ Boolean
81 82 83 |
# File 'lib/bundler/resolver/package.rb', line 81 def force_ruby_platform? @dependency.force_ruby_platform end |
#hash ⇒ Object
53 54 55 |
# File 'lib/bundler/resolver/package.rb', line 53 def hash @name.hash end |
#ignores_prereleases? ⇒ Boolean
61 62 63 |
# File 'lib/bundler/resolver/package.rb', line 61 def ignores_prereleases? @prerelease == :ignore end |
#meta? ⇒ Boolean
45 46 47 |
# File 'lib/bundler/resolver/package.rb', line 45 def @name.end_with?("\0") end |
#platform_specs(specs) ⇒ Object
29 30 31 |
# 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 |
#prefer_local? ⇒ Boolean
73 74 75 |
# File 'lib/bundler/resolver/package.rb', line 73 def prefer_local? @prefer_local end |
#prerelease_specified? ⇒ Boolean
65 66 67 |
# File 'lib/bundler/resolver/package.rb', line 65 def prerelease_specified? @prerelease == :consider_first end |
#root? ⇒ Boolean
37 38 39 |
# File 'lib/bundler/resolver/package.rb', line 37 def root? false end |
#to_s ⇒ Object
33 34 35 |
# File 'lib/bundler/resolver/package.rb', line 33 def to_s @name.delete("\0") end |
#top_level? ⇒ Boolean
41 42 43 |
# File 'lib/bundler/resolver/package.rb', line 41 def top_level? @top_level end |
#unlock? ⇒ Boolean
57 58 59 |
# File 'lib/bundler/resolver/package.rb', line 57 def unlock? @unlock.empty? || @unlock.include?(name) end |