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.



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

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

Instance Attribute Details

#metadataObject (readonly)

Returns the value of attribute metadata.



2
3
4
# File 'lib/release_manager/control_mod.rb', line 2

def 
  
end

#nameObject (readonly)

Returns the value of attribute name.



2
3
4
# File 'lib/release_manager/control_mod.rb', line 2

def name
  @name
end

#repoObject (readonly)

Returns the value of attribute repo.



2
3
4
# File 'lib/release_manager/control_mod.rb', line 2

def repo
  @repo
end

#versionObject

Returns the value of attribute version.



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

def version
  @version
end

Instance Method Details

#branchObject



18
19
20
# File 'lib/release_manager/control_mod.rb', line 18

def branch
  [:branch]
end

#bump_major_versionObject



49
50
51
52
53
54
55
56
57
# File 'lib/release_manager/control_mod.rb', line 49

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



40
41
42
43
44
45
46
47
# File 'lib/release_manager/control_mod.rb', line 40

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



32
33
34
35
36
37
38
# File 'lib/release_manager/control_mod.rb', line 32

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



14
15
16
# File 'lib/release_manager/control_mod.rb', line 14

def git_url
  [:git]
end

#pin_branch(name) ⇒ Object



73
74
75
76
77
# File 'lib/release_manager/control_mod.rb', line 73

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

#pin_url(src) ⇒ Object



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

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

#pin_version(v) ⇒ Object



67
68
69
70
71
# File 'lib/release_manager/control_mod.rb', line 67

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

#to_json(state = nil) ⇒ Object



22
23
24
# File 'lib/release_manager/control_mod.rb', line 22

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

#to_sObject



26
27
28
29
30
# File 'lib/release_manager/control_mod.rb', line 26

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