Use this gem to expose environment variables to your code, with clear defaults and error handling for when the environment variables are unset.
Add this line to your application's Gemfile:
gem 'service_config'
And then execute:
$ bundle
ENV['INTERNAL_SERVER'] = 'http://localhost:3000/'
provider = ServiceConfig::Provider.new(:raise_if_nil => false, :use_env => true) do |config|
config.provides :internal_server
config.provides :soundcloud_server, 'http://api.soundcloud.com/'
end
provider.internal_server # => 'http://localhost:3000/'
provider.soundcloud_server # => 'http://api.soundcloud.com/'
Configure mandatory options individually
ServiceConfig::Provider.new(:raise_if_nil => false) do |config|
config.provides :some_key, 'default', :raise_if_nil => true
end
- Fork it
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create new Pull Request
