0.0
No commit activity in last 3 years
No release in over 3 years
This gem reads and manage YAML config files
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
 Project Readme

Description¶ ↑

Simple wrapper for YAML config files.

Simple example¶ ↑

# File config/app_config.yml
# development:
#   app_host:
#     name: google.com
#     port: 80
# End of config/app_config.yml
require 'yaml_config'

config = YamlConfig.new(File.join(Rails.root, "config/app_config.yml"), :root => RAILS_ENV)
config.get(:app_host)[:name] # -> "google.com"
config.get(:app_host)[:port] # -> 80
config.get(:app_host)[:some] # -> NullProperty

Different initializations¶ ↑

# using filename
filename = File.join(Rails.root, "config/app_config.yml")
config = YamlConfig.new(filename, :root => RAILS_ENV)
# using open stream
File.open(filename, "r") do |file|
  config = YamlConfig.new(file, :root => RAILS_ENV)
end
# using data string
config = YamlConfig.new(File.read(filename), :root => RAILS_ENV)

Singleton version¶ ↑

In many cases (rails application is the best example) developer needs only one file for whole project. To accomplish this it possible to use singleton version of YamlConfig.

# environment.rb example:
require "yaml_config"
...
filename = File.join(Rails.root, "config/app_config.yml")
config = AppYamlConfig.instance.init!(filename, :root => RAILS_ENV)
...
# Usage
config.get(:username)

Known issues¶ ↑