Module: Dployr::Commands::Utils
- Included in:
- Base
- Defined in:
- lib/dployr/commands/utils.rb
Class Method Summary collapse
Class Method Details
.parse_attributes(attributes) ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'lib/dployr/commands/utils.rb', line 28 def parse_attributes(attributes) if attributes.is_a? String if attributes[0] == '-' parse_flags attributes else parse_matrix attributes end end end |
.parse_flags(str) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/dployr/commands/utils.rb', line 16 def parse_flags(str) hash = {} str.gsub(/\s+/, ' ').strip.split(' ').each_slice(2) do |val| key = val.first if val.first.is_a? String key = key.gsub(/^\-+/, '').strip hash[key] = (val.last or '').strip end end if str.is_a? String hash end |
.parse_matrix(str) ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'lib/dployr/commands/utils.rb', line 7 def parse_matrix(str) hash = {} str.split(';').each do |val| val = val.split '=' hash[val.first.strip] = val.last.strip end if str.is_a? String hash end |