Class: GitCompound::Repository::GitVersion
- Inherits:
-
Object
- Object
- GitCompound::Repository::GitVersion
- Defined in:
- lib/git_compound/repository/git_version.rb
Overview
GitVersion represents tagged version inside Git repository
Instance Attribute Summary collapse
-
#sha ⇒ Object
readonly
Returns the value of attribute sha.
-
#tag ⇒ Object
readonly
Returns the value of attribute tag.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #==(other) ⇒ Object
-
#initialize(tag, sha) ⇒ GitVersion
constructor
A new instance of GitVersion.
- #matches?(requirement) ⇒ Boolean
- #to_gem_version ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(tag, sha) ⇒ GitVersion
Returns a new instance of GitVersion.
8 9 10 11 12 |
# File 'lib/git_compound/repository/git_version.rb', line 8 def initialize(tag, sha) @tag = tag @sha = sha @version = tag.sub(/^v/, '') end |
Instance Attribute Details
#sha ⇒ Object (readonly)
Returns the value of attribute sha.
6 7 8 |
# File 'lib/git_compound/repository/git_version.rb', line 6 def sha @sha end |
#tag ⇒ Object (readonly)
Returns the value of attribute tag.
6 7 8 |
# File 'lib/git_compound/repository/git_version.rb', line 6 def tag @tag end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
6 7 8 |
# File 'lib/git_compound/repository/git_version.rb', line 6 def version @version end |
Instance Method Details
#<=>(other) ⇒ Object
27 28 29 |
# File 'lib/git_compound/repository/git_version.rb', line 27 def <=>(other) to_gem_version <=> other.to_gem_version end |
#==(other) ⇒ Object
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/git_compound/repository/git_version.rb', line 31 def ==(other) case other when String version == other when GitVersion version == other.version else false end end |
#matches?(requirement) ⇒ Boolean
22 23 24 25 |
# File 'lib/git_compound/repository/git_version.rb', line 22 def matches?(requirement) dependency = Gem::Dependency.new('component', requirement) dependency.match?('component', to_gem_version, true) end |
#to_gem_version ⇒ Object
14 15 16 |
# File 'lib/git_compound/repository/git_version.rb', line 14 def to_gem_version Gem::Version.new(@version) end |
#valid? ⇒ Boolean
18 19 20 |
# File 'lib/git_compound/repository/git_version.rb', line 18 def valid? @tag.match(/^v?#{Gem::Version::VERSION_PATTERN}$/) end |