Module: Yutani::Utils
- Defined in:
- lib/yutani/utils.rb
Class Method Summary collapse
- .convert_nested_hash_to_indifferent_access(v) ⇒ Object
- .convert_symbols_to_strings_in_flat_hash(h) ⇒ Object
- .run_tf_command(cmd, *args) ⇒ Object
Class Method Details
.convert_nested_hash_to_indifferent_access(v) ⇒ Object
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/yutani/utils.rb', line 36 def convert_nested_hash_to_indifferent_access(v) case v when Array v.map{|i| convert_nested_hash_to_indifferent_access(i) } when Hash IndifferentHash.new(v) else v end end |
.convert_symbols_to_strings_in_flat_hash(h) ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/yutani/utils.rb', line 27 def convert_symbols_to_strings_in_flat_hash(h) h.inject({}) do |h, (k,v)| k = k.is_a?(Symbol) ? k.to_s : k v = v.is_a?(Symbol) ? v.to_s : v h[k] = v h end end |
.run_tf_command(cmd, *args) ⇒ Object
21 22 23 24 25 |
# File 'lib/yutani/utils.rb', line 21 def run_tf_command(cmd, *args) command = ENV.fetch('TERRAFORM', 'terraform') + ' ' + cmd + ' ' + args.join(' ') Yutani.logger.info command exec(command) end |