Class: KeepUp::Dependency
- Inherits:
-
Object
- Object
- KeepUp::Dependency
- Defined in:
- lib/keep_up/dependency.rb
Overview
Single dependency with its current locked version.
Instance Attribute Summary collapse
-
#locked_version ⇒ Object
readonly
Returns the value of attribute locked_version.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #generalize_specification(specification) ⇒ Object
-
#initialize(name:, requirement_list:, locked_version:) ⇒ Dependency
constructor
A new instance of Dependency.
- #matches_spec?(spec) ⇒ Boolean
- #requirement ⇒ Object
Constructor Details
#initialize(name:, requirement_list:, locked_version:) ⇒ Dependency
Returns a new instance of Dependency.
4 5 6 7 8 |
# File 'lib/keep_up/dependency.rb', line 4 def initialize(name:, requirement_list:, locked_version:) @name = name @requirement_list = requirement_list @locked_version = Gem::Version.new locked_version end |
Instance Attribute Details
#locked_version ⇒ Object (readonly)
Returns the value of attribute locked_version.
10 11 12 |
# File 'lib/keep_up/dependency.rb', line 10 def locked_version @locked_version end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
10 11 12 |
# File 'lib/keep_up/dependency.rb', line 10 def name @name end |
Instance Method Details
#==(other) ⇒ Object
28 29 30 31 32 |
# File 'lib/keep_up/dependency.rb', line 28 def ==(other) other.name == name && other.locked_version == locked_version && other.requirement == requirement end |
#generalize_specification(specification) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/keep_up/dependency.rb', line 20 def generalize_specification(specification) return specification if requirement.exact? segments = specification.version.segments return specification if segments.count <= segment_count version = segments.take(segment_count).join('.') Gem::Specification.new(specification.name, version) end |
#matches_spec?(spec) ⇒ Boolean
16 17 18 |
# File 'lib/keep_up/dependency.rb', line 16 def matches_spec?(spec) dependency.matches_spec? spec end |
#requirement ⇒ Object
12 13 14 |
# File 'lib/keep_up/dependency.rb', line 12 def requirement @requirement ||= Gem::Requirement.new @requirement_list end |