Class: ControlMod
- Inherits:
-
Object
- Object
- ControlMod
- Defined in:
- lib/release_manager/control_mod.rb
Instance Attribute Summary collapse
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#repo ⇒ Object
readonly
Returns the value of attribute repo.
-
#version ⇒ Object
Returns the value of attribute version.
Instance Method Summary collapse
- #branch ⇒ Object
- #bump_major_version ⇒ Object
- #bump_minor_version ⇒ Object
- #bump_patch_version ⇒ Object
- #git_url ⇒ Object
-
#initialize(name, args) ⇒ ControlMod
constructor
A new instance of ControlMod.
- #pin_branch(name) ⇒ Object
- #pin_url(src) ⇒ Object
- #pin_version(v) ⇒ Object
- #to_json(state = nil) ⇒ Object
- #to_s ⇒ Object
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
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
2 3 4 |
# File 'lib/release_manager/control_mod.rb', line 2 def end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
2 3 4 |
# File 'lib/release_manager/control_mod.rb', line 2 def name @name end |
#repo ⇒ Object (readonly)
Returns the value of attribute repo.
2 3 4 |
# File 'lib/release_manager/control_mod.rb', line 2 def repo @repo end |
#version ⇒ Object
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
#branch ⇒ Object
18 19 20 |
# File 'lib/release_manager/control_mod.rb', line 18 def branch [:branch] end |
#bump_major_version ⇒ Object
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_version ⇒ Object
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_version ⇒ Object
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_url ⇒ Object
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_s ⇒ Object
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 |