Sha256: 7188a41df77d68d6b3169737cd1bde3838567ac0a0783e7499fb58250240b078

Contents?: true

Size: 665 Bytes

Versions: 6

Compression:

Stored size: 665 Bytes

Contents

require 'yaml'

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

    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

    def self.parse_list(option_value)
      if option_value.is_a? String
        option_value.split(',')
      elsif option_value.is_a? Array
        option_value
      else
        []
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
modulesync-2.2.0 lib/modulesync/util.rb
modulesync-2.1.1 lib/modulesync/util.rb
modulesync-2.1.0 lib/modulesync/util.rb
modulesync-2.0.2 lib/modulesync/util.rb
modulesync-2.0.1 lib/modulesync/util.rb
modulesync-2.0.0 lib/modulesync/util.rb