Sedative
TODO: Write a gem description
Installation
Add this line to your application's Gemfile:
gem 'sedative'
And then execute:
$ bundle
Or install it yourself as:
$ gem install sedative
And run the generator:
$ rails g sedative:install
By default, it will create Settings
and Switches
variables. You can change this by adding arguments to the generator. For a single variable called Constants
, do this:
$ rails g sedative:install constants
Usage
Open up config/settings/settings.yml
, or whatever you named your settings variable to, and stick with the pattern. It's really DRY and convenient having all your settings in one file.
Beyond convenience, the settings also change based on your environment. I like to keep API information here. You can do something like this:
development:
mailchimp:
token: [Your development API token]
secret: [Your development API key]
production:
mailchimp:
token: [Your production API token]
secret: [Your production API secret]
When you need to connect to the service, using the settings is simple:
OAuth2::Client.new Settings.mailchimp.id,
Settings.mailchimp.secret,
site: 'https://login.mailchimp.com',
authorize_url: '/oauth2/authorize',
token_url: '/oauth2/token'
There you go.
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Added some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request