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
- #current_platform? ⇒ Boolean
- #force_ruby_platform? ⇒ Boolean
- #hash ⇒ Object
- #ignores_prereleases? ⇒ Boolean
-
#initialize(name, platforms, locked_specs:, unlock:, prerelease: false, dependency: nil) ⇒ Package
constructor
A new instance of Package.
- #meta? ⇒ Boolean
- #prerelease_specified? ⇒ Boolean
- #root? ⇒ Boolean
- #to_s ⇒ Object
- #unlock? ⇒ Boolean
Constructor Details
#initialize(name, platforms, locked_specs:, unlock:, prerelease: false, dependency: nil) ⇒ Package
Returns a new instance of Package.
18 19 20 21 22 23 24 25 |
# File 'lib/bundler/resolver/package.rb', line 18 def initialize(name, platforms, locked_specs:, unlock:, prerelease: false, dependency: nil) @name = name @platforms = platforms @locked_version = locked_specs[name].first&.version @unlock = unlock @dependency = dependency || Dependency.new(name, @locked_version) @prerelease = @dependency.prerelease? || @locked_version&.prerelease? || prerelease ? :consider_first : :ignore 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
39 40 41 |
# File 'lib/bundler/resolver/package.rb', line 39 def ==(other) self.class == other.class && @name == other.name end |
#consider_prereleases! ⇒ Object
59 60 61 |
# File 'lib/bundler/resolver/package.rb', line 59 def consider_prereleases! @prerelease = :consider_last end |
#current_platform? ⇒ Boolean
67 68 69 |
# File 'lib/bundler/resolver/package.rb', line 67 def current_platform? @dependency.current_platform? end |
#force_ruby_platform? ⇒ Boolean
63 64 65 |
# File 'lib/bundler/resolver/package.rb', line 63 def force_ruby_platform? @dependency.force_ruby_platform end |
#hash ⇒ Object
43 44 45 |
# File 'lib/bundler/resolver/package.rb', line 43 def hash @name.hash end |
#ignores_prereleases? ⇒ Boolean
51 52 53 |
# File 'lib/bundler/resolver/package.rb', line 51 def ignores_prereleases? @prerelease == :ignore end |
#meta? ⇒ Boolean
35 36 37 |
# File 'lib/bundler/resolver/package.rb', line 35 def @name.end_with?("\0") end |
#prerelease_specified? ⇒ Boolean
55 56 57 |
# File 'lib/bundler/resolver/package.rb', line 55 def prerelease_specified? @prerelease == :consider_first end |
#root? ⇒ Boolean
31 32 33 |
# File 'lib/bundler/resolver/package.rb', line 31 def root? false end |
#to_s ⇒ Object
27 28 29 |
# File 'lib/bundler/resolver/package.rb', line 27 def to_s @name.delete("\0") end |
#unlock? ⇒ Boolean
47 48 49 |
# File 'lib/bundler/resolver/package.rb', line 47 def unlock? @unlock.empty? || @unlock.include?(name) end |