class Localer::Config

Loads and parse Localer config file `.localer.yml`

Constants

APP_PATH
CONFIG_FILENAME

Public Class Methods

file_config(filename, path) click to toggle source
# File lib/localer/config.rb, line 29
def file_config(filename, path)
  filename = File.expand_path(filename, path)
  return {} unless File.exist?(filename)
  return {} if File.zero?(filename)

  YAML
    .load_file(filename)
    .deep_downcase_keys
    .deep_symbolize_keys
end
load(options = {}) click to toggle source
# File lib/localer/config.rb, line 22
def load(options = {})
  opts = options.deep_symbolize_keys
  app_path = opts.fetch(:app_path, APP_PATH)
  file_options = file_config(CONFIG_FILENAME, app_path)
  new(file_options.deep_merge(opts).deep_symbolize_keys)
end
parse_locales(hash) click to toggle source
# File lib/localer/config.rb, line 40
def parse_locales(hash)
  hash.each_with_object(Hash.new(Locale.new)) do |(l, v), h|
    h[l] = Locale.new(v)
  end
end