Module: ModuleSync::Util

Defined in:
lib/modulesync/util.rb

Class Method Summary collapse

Class Method Details

.parse_config(config_file) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/modulesync/util.rb', line 11

def self.parse_config(config_file)
  if File.exist?(config_file)
    YAML.load_file(config_file) || {}
  else
    puts "No config file under #{config_file} found, using default values"
    {}
  end
end

.parse_list(option_value) ⇒ Object



20
21
22
23
24
25
26
27
28
29
# File 'lib/modulesync/util.rb', line 20

def self.parse_list(option_value)
  case option_value
  when String
    option_value.split(',')
  when Array
    option_value
  else
    []
  end
end

.symbolize_keys(hash) ⇒ Object



5
6
7
8
9
# File 'lib/modulesync/util.rb', line 5

def self.symbolize_keys(hash)
  hash.each_with_object({}) do |(k, v), memo|
    memo[k.to_sym] = v.is_a?(Hash) ? symbolize_keys(v) : v
  end
end