Class: GitCompound::Component::Version::GemVersion
- Inherits:
-
VersionStrategy
- Object
- VersionStrategy
- GitCompound::Component::Version::GemVersion
- Defined in:
- lib/git_compound/component/version/gem_version.rb
Overview
Component Gem-like version
Instance Attribute Summary collapse
-
#requirement ⇒ Object
readonly
Returns the value of attribute requirement.
Instance Method Summary collapse
-
#initialize(repository, requirement) ⇒ GemVersion
constructor
A new instance of GemVersion.
- #lastest_version ⇒ Object
- #matches ⇒ Object
- #reachable? ⇒ Boolean
- #ref ⇒ Object
- #sha ⇒ Object
- #to_s ⇒ Object
Methods inherited from VersionStrategy
Constructor Details
#initialize(repository, requirement) ⇒ GemVersion
Returns a new instance of GemVersion.
9 10 11 12 13 14 15 |
# File 'lib/git_compound/component/version/gem_version.rb', line 9 def initialize(repository, requirement) raise CompoundSyntaxError, 'Malformed version requirement string' unless requirement =~ Gem::Requirement::PATTERN @repository = repository @requirement = requirement end |
Instance Attribute Details
#requirement ⇒ Object (readonly)
Returns the value of attribute requirement.
7 8 9 |
# File 'lib/git_compound/component/version/gem_version.rb', line 7 def requirement @requirement end |
Instance Method Details
#lastest_version ⇒ Object
17 18 19 |
# File 'lib/git_compound/component/version/gem_version.rb', line 17 def lastest_version matches.first end |
#matches ⇒ Object
29 30 31 32 33 |
# File 'lib/git_compound/component/version/gem_version.rb', line 29 def matches versions = @repository.versions versions.select! { |version| version.matches?(@requirement) } versions.sort.reverse end |
#reachable? ⇒ Boolean
35 36 37 |
# File 'lib/git_compound/component/version/gem_version.rb', line 35 def reachable? matches.any? end |
#ref ⇒ Object
21 22 23 |
# File 'lib/git_compound/component/version/gem_version.rb', line 21 def ref lastest_version.tag end |
#sha ⇒ Object
25 26 27 |
# File 'lib/git_compound/component/version/gem_version.rb', line 25 def sha lastest_version.sha end |
#to_s ⇒ Object
39 40 41 |
# File 'lib/git_compound/component/version/gem_version.rb', line 39 def to_s "version: #{@requirement}" end |