Sha256: 589b1660e899a0c63304423d099890eac7b16da6bbde6f58741719e5691b2e38
Contents?: true
Size: 973 Bytes
Versions: 3
Compression:
Stored size: 973 Bytes
Contents
module Eye::Patch class ProcessSet < Hash def initialize(group, processes) @group = group Array(processes).each do |process| parse_process(process) end end private def parse_process(process) if process[:count] parse_process_cluster(process) else parse_single_process(process[:name], process[:config]) end end def parse_process_cluster(process) process[:count].times do |index| name = "#{process[:name]}-#{index}" parse_single_process(name, indexed_config(process[:config], index)) end end def parse_single_process(name, config) self[name] = @group.merge(config).merge( name: name, group: @group[:name] ) end def indexed_config(config, index) config.each_with_object({}) do |(key, value), result| result[key] = value.is_a?(String) ? value.gsub("{ID}", index.to_s) : value end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
eye-patch-0.0.7 | lib/eye/patch/process_set.rb |
eye-patch-0.0.6 | lib/eye/patch/process_set.rb |
eye-patch-0.0.5 | lib/eye/patch/process_set.rb |