Class: GitCompound::Repository::GitVersion

Inherits:
Object
  • Object
show all
Defined in:
lib/git_compound/repository/git_version.rb

Overview

GitVersion represents tagged version inside Git repository

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#shaObject (readonly)

Returns the value of attribute sha.



6
7
8
# File 'lib/git_compound/repository/git_version.rb', line 6

def sha
  @sha
end

#tagObject (readonly)

Returns the value of attribute tag.



6
7
8
# File 'lib/git_compound/repository/git_version.rb', line 6

def tag
  @tag
end

#versionObject (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

Returns:

  • (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_versionObject



14
15
16
# File 'lib/git_compound/repository/git_version.rb', line 14

def to_gem_version
  Gem::Version.new(@version)
end

#valid?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/git_compound/repository/git_version.rb', line 18

def valid?
  @tag.match(/^v?#{Gem::Version::VERSION_PATTERN}$/)
end