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.
-
#newest_version ⇒ Object
readonly
Returns the value of attribute newest_version.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #generalize_specification(specification) ⇒ Object
-
#initialize(name:, requirement_list:, locked_version:, newest_version:) ⇒ Dependency
constructor
A new instance of Dependency.
- #matches_spec?(spec) ⇒ Boolean
- #requirement ⇒ Object
Constructor Details
#initialize(name:, requirement_list:, locked_version:, newest_version:) ⇒ Dependency
Returns a new instance of Dependency.
6 7 8 9 10 11 |
# File 'lib/keep_up/dependency.rb', line 6 def initialize(name:, requirement_list:, locked_version:, newest_version:) @name = name @requirement_list = requirement_list @locked_version = Gem::Version.new locked_version @newest_version = Gem::Version.new newest_version end |
Instance Attribute Details
#locked_version ⇒ Object (readonly)
Returns the value of attribute locked_version.
13 14 15 |
# File 'lib/keep_up/dependency.rb', line 13 def locked_version @locked_version end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
13 14 15 |
# File 'lib/keep_up/dependency.rb', line 13 def name @name end |
#newest_version ⇒ Object (readonly)
Returns the value of attribute newest_version.
13 14 15 |
# File 'lib/keep_up/dependency.rb', line 13 def newest_version @newest_version end |
Instance Method Details
#==(other) ⇒ Object
33 34 35 36 37 38 |
# File 'lib/keep_up/dependency.rb', line 33 def ==(other) other.name == name && other.locked_version == locked_version && other.newest_version == newest_version && other.requirement == requirement end |
#generalize_specification(specification) ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/keep_up/dependency.rb', line 23 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
19 20 21 |
# File 'lib/keep_up/dependency.rb', line 19 def matches_spec?(spec) dependency.matches_spec? spec end |
#requirement ⇒ Object
15 16 17 |
# File 'lib/keep_up/dependency.rb', line 15 def requirement @requirement ||= Gem::Requirement.new @requirement_list end |