YamlProperties
If you find yourself often setting app config in yaml files for different environments etc. Then this can be quite useful to simply access those variables.
Examples
#usual bundler install
gem 'yaml_config'
#usage in your code
YamlProperties.redis_port
YamlProperties.smtp_server
# data in config/properties.yml
redis_port: 1369
smtp_server: smtp.example.com
Also can be added to a module or class like
module YourFunkyConfigThing
extend YamlProperties
#Override filename like this
def self.yaml_file
ENV['SINATRA_ENV'] == 'development' ? 'config/properties.yml' : 'config/properties_production.yml'
end
end
#Always reload e.g. in Rails dev environment
YamlProperties.dev_environment = Rails.env.development?
For Cucumber etc
#features/support/env.rb
After do |scenario|
YamlProperties.reset!
end
#features/step_definitions/egg_steps.rb
Given /\AThere are \d+ eggs in a dozen\z/ |dozen|
YamlProperties.override_attribute :egg, dozen
end
Yadayada
Usual gem/bundler usage/contribution guidelines