Module: Datag::DSL

Included in:
Datag
Defined in:
lib/Datag.rb

Instance Method Summary collapse

Instance Method Details

#bump_majorObject



59
60
61
62
# File 'lib/Datag.rb', line 59

def bump_major
  mj, m, p = to_arr( last! )
  to_str mj + 1, 0, 0
end

#bump_minorObject



54
55
56
57
# File 'lib/Datag.rb', line 54

def bump_minor
  mj, m, p = to_arr( last! )
  to_str  mj, m + 1, 0
end

#bump_patchObject



49
50
51
52
# File 'lib/Datag.rb', line 49

def bump_patch
  mj, m, p = to_arr( last! )
  to_str  mj, m, p + 1
end

#currentObject



45
46
47
# File 'lib/Datag.rb', line 45

def current
  Exit_0('git describe --tag').out
end

#firstObject



27
28
29
# File 'lib/Datag.rb', line 27

def first
  list.first
end

#lastObject



31
32
33
# File 'lib/Datag.rb', line 31

def last
  list.last
end

#last!Object



73
74
75
# File 'lib/Datag.rb', line 73

def last!
  list.last || "v0.0.0"
end

#listObject



9
10
11
12
13
14
15
16
17
# File 'lib/Datag.rb', line 9

def list
  Split_Lines(Exit_0("git tag -l").out)
  .select { |str|
    str[ %r!v[\d\.]! ]
  }
  .sort_by { |str| 
    to_arr str
  }
end

#move(count) ⇒ Object



35
36
37
38
39
40
41
42
43
# File 'lib/Datag.rb', line 35

def move count
  c = current
  l = list
  i = list.index(c.split('-').first)
  return c if i.nil? || (i == 0 && count < 0)
  t = l[ i + count ]
  return c if t.nil?
  t
end

#nextObject



19
20
21
# File 'lib/Datag.rb', line 19

def next
  move 1
end

#previousObject



23
24
25
# File 'lib/Datag.rb', line 23

def previous
  move -1
end

#to_arr(str) ⇒ Object



64
65
66
67
# File 'lib/Datag.rb', line 64

def to_arr str
  mj, m, p = str.sub('v', '').split( '.' ).map(&:to_i)
  [ (mj || 0), (m || 0), (p || 0) ]
end

#to_str(*arr) ⇒ Object



69
70
71
# File 'lib/Datag.rb', line 69

def to_str *arr
  "v" + arr.flatten.join('.')
end