Class: Minos::Utils

Inherits:
Object
  • Object
show all
Defined in:
lib/minos/utils.rb

Class Method Summary collapse

Class Method Details

.to_args(args) ⇒ Object

Flatten args as an array, hash or string into CLI args.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/minos/utils.rb', line 6

def self.to_args(args)
  args.map do |key, value|
    case value
    when Array
      value.map do |v|
        "--#{key.underscore.gsub('_', '-')} #{v}"
      end
    when Hash
      value.map do |k, v|
        "--#{key.underscore.gsub('_', '-')} #{k}=#{v}"
      end
    else
      "--#{key.underscore.gsub('_', '-')} #{value}"
    end
  end.flatten.join(' ')
end

.to_envs(env) ⇒ Object

Flatten env as hash into shell’s environment variables.



24
25
26
# File 'lib/minos/utils.rb', line 24

def self.to_envs(env)
  env.map { |k, v| "#{k}=\"#{v}\"" }.join(' ')
end