Class: Tagistrano::Tag

Inherits:
String
  • Object
show all
Defined in:
lib/tagistrano/tag.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.allObject



13
14
15
# File 'lib/tagistrano/tag.rb', line 13

def self.all
  git_tags.split(/\s+/).map { |tag| new(tag) }.sort
end

.git_tagsObject



17
18
19
# File 'lib/tagistrano/tag.rb', line 17

def self.git_tags
  `git tag`
end

.next_tagsObject



3
4
5
6
7
8
9
10
11
# File 'lib/tagistrano/tag.rb', line 3

def self.next_tags
  last_tag = all.last

  [
    last_tag.next_major_tag,
    last_tag.next_minor_tag,
    last_tag.next_patch_tag
  ]
end

Instance Method Details

#<=>(other) ⇒ Object



33
34
35
# File 'lib/tagistrano/tag.rb', line 33

def <=>(other)
  version <=> other.version
end

#next_major_tagObject



21
22
23
# File 'lib/tagistrano/tag.rb', line 21

def next_major_tag
  [major + 1, 0, 0].join('.')
end

#next_minor_tagObject



25
26
27
# File 'lib/tagistrano/tag.rb', line 25

def next_minor_tag
  [major, minor + 1, 0].join('.')
end

#next_patch_tagObject



29
30
31
# File 'lib/tagistrano/tag.rb', line 29

def next_patch_tag
  [major, minor, patch + 1].join('.')
end

#versionObject



37
38
39
# File 'lib/tagistrano/tag.rb', line 37

def version
  [major, minor, patch]
end