lib/configliere/config_file.rb
def read_yaml yaml_str, options={}
      require 'yaml'
      new_data = YAML.load(yaml_str) || {}
      # Extract the :env (production/development/etc)
      if options[:env]
        new_data = new_data[options[:env]] || {}
      end
      deep_merge! new_data
      self
    end
# Load params from a YAML file, as a hash of handle => param_hash pairs
#
# @param filename [String] the file to read. If it does not contain a '/',
#   the filename is expanded relative to Configliere::DEFAULT_CONFIG_DIR
# @param options [Hash]
# @option options :env [String]
#   If an :env option is given, only the indicated subhash is merged. This
#   lets you for example specify production / environment / test settings
#
# @return [Configliere::Params] the Settings object
#
# @example
#     # Read from ~/.configliere/foo.yaml
#     Settings.read(foo.yaml)
#
# @example
#     # Read from config/foo.yaml and use settings appropriate for development/staging/production
#     Settings.read(App.root.join('config', 'environment.yaml'), :env => ENV['RACK_ENV'])
#
# The env option is *not* coerced to_sym, so make sure your key type matches the file's
Load params from a YAML file, as a hash of handle => param_hash pairs
Load params from a YAML file as a hash of handle = > param_hash pairs
def read_yaml yaml_str, options={}
      require 'yaml'
      new_data = YAML.load(yaml_str) || {}
      if options[:env]
        new_data = new_data[options[:env]] || {}
      end
      deep_merge! new_data
      self
    end
def read_yaml yaml_str , options = { } require 'yaml' new_data = YAML . load ( yaml_str ) || { } if options [ :env ] new_data = new_data [ options [ :env ] ] || { } end deep_merge! new_data self end
Load params from a YAML file, as a hash of handle => param_hash pairs
Load params from a YAML file as a hash of handle = > param_hash pairs
# Extract the :env (production/development/etc)
the Settings object
the Settings object
Configliere::Params
yaml_str
options
:env  If an :env option is given, only the indicated subhash is merged. This lets you for example specify production / environment / test settings
: env If an : env option is given only the indicated subhash is merged . This lets you for example specify production / environment / test settings
filename
the file to read. If it does not contain a '/', the filename is expanded relative to Configliere::DEFAULT_CONFIG_DIR
the file to read . If it does not contain a ' / ' the filename is expanded relative to Configliere :: DEFAULT_CONFIG_DIR
None
example
Read from ~/.configliere/foo.yaml Settings.read(foo.yaml)
Read from ~ / . configliere / foo . yaml Settings . read ( foo . yaml )
example
Read from config/foo.yaml and use settings appropriate for development/staging/production Settings.read(App.root.join('config', 'environment.yaml'), :env => ENV['RACK_ENV']) The env option is *not* coerced to_sym, so make sure your key type matches the file's
Read from config / foo . yaml and use settings appropriate for development / staging / production Settings . read ( App . root . join ( ' config ' ' environment . yaml ' ) : env = > ENV [ ' RACK_ENV ' ] ) The env option is * not * coerced to_sym so make sure your key type matches the file ' s