Class: ControlMod

Inherits:
Object
  • Object
show all
Defined in:
lib/release_manager/control_mod.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, args) ⇒ ControlMod

Returns a new instance of ControlMod.



7
8
9
10
# File 'lib/release_manager/control_mod.rb', line 7

def initialize(name, args)
  @name = name
   = args.each_with_object({}) { |(k, v), memo| memo[k.to_sym] = v; }
end

Instance Attribute Details

#metadataObject (readonly)

Returns the value of attribute metadata.



4
5
6
# File 'lib/release_manager/control_mod.rb', line 4

def 
  
end

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/release_manager/control_mod.rb', line 4

def name
  @name
end

#repoObject (readonly)

Returns the value of attribute repo.



4
5
6
# File 'lib/release_manager/control_mod.rb', line 4

def repo
  @repo
end

#versionObject

Returns the value of attribute version.



5
6
7
# File 'lib/release_manager/control_mod.rb', line 5

def version
  @version
end

Instance Method Details

#branchObject



20
21
22
# File 'lib/release_manager/control_mod.rb', line 20

def branch
  [:branch]
end

#bump_major_versionObject



57
58
59
60
61
62
63
64
65
66
67
# File 'lib/release_manager/control_mod.rb', line 57

def bump_major_version
  return unless [:tag]

  pieces = [:tag].split('.')
  raise "invalid semver structure #{metadata[:tag]}" if pieces.count != 3

  pieces[2] = '0'
  pieces[1] = '0'
  pieces[0] = pieces[0].next
  pin_version(pieces.join('.'))
end

#bump_minor_versionObject



46
47
48
49
50
51
52
53
54
55
# File 'lib/release_manager/control_mod.rb', line 46

def bump_minor_version
  return unless [:tag]

  pieces = [:tag].split('.')
  raise "invalid semver structure #{metadata[:tag]}" if pieces.count != 3

  pieces[2] = '0'
  pieces[1] = pieces[1].next
  pin_version(pieces.join('.'))
end

#bump_patch_versionObject



36
37
38
39
40
41
42
43
44
# File 'lib/release_manager/control_mod.rb', line 36

def bump_patch_version
  return unless [:tag]

  pieces = [:tag].split('.')
  raise "invalid semver structure #{metadata[:tag]}" if pieces.count != 3

  pieces[2] = pieces[2].next
  pin_version(pieces.join('.'))
end

#git_urlObject



16
17
18
# File 'lib/release_manager/control_mod.rb', line 16

def git_url
  [:git]
end

#pin_branch(name) ⇒ Object



83
84
85
86
87
# File 'lib/release_manager/control_mod.rb', line 83

def pin_branch(name)
  [:branch] = name
  .delete(:ref)
  .delete(:tag)
end

#pin_url(src) ⇒ Object



89
90
91
# File 'lib/release_manager/control_mod.rb', line 89

def pin_url(src)
  [:git] = src
end

#pin_version(v) ⇒ Object



77
78
79
80
81
# File 'lib/release_manager/control_mod.rb', line 77

def pin_version(v)
  .delete(:ref)
  .delete(:branch)
  [:tag] = v
end

#to_json(state = nil) ⇒ Object



24
25
26
# File 'lib/release_manager/control_mod.rb', line 24

def to_json(state = nil)
  .to_json(state)
end

#to_sObject



28
29
30
31
32
33
34
# File 'lib/release_manager/control_mod.rb', line 28

def to_s
  name_line = "mod '#{name}',"
  data = .map do |k, v|
    v == :control_branch ? ":#{k} => #{v.inspect}" : ":#{k} => '#{v}'"
  end.join(",\n\  ")
  "#{name_line}\n  #{data}"
end