Module: ModuleSync::Util

Defined in:
lib/modulesync/util.rb

Class Method Summary collapse

Class Method Details

.parse_config(config_file) ⇒ Object



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

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



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

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



7
8
9
10
11
# File 'lib/modulesync/util.rb', line 7

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