spore-rails
Ruby/Rails gem to load Spore environment variables. See the Spore Website for more information.
Installation
Rails
Add this line to the top of your application's Gemfile:
gem 'spore-rails'
And then execute:
$ bundle
Note on load order
Spore is initialized in your Rails app during the before_configuration
callback, which is fired when the Application
constant is defined in config/application.rb
with class Application < Rails::Application
. If you need it to be initialized sooner, you can manually call Spore::Railtie.load
.
# config/application.rb
Bundler.require(*Rails.groups)
Spore::Railtie.load
HOSTNAME = ENV['HOSTNAME']
If you use gems that require environment variables to be set before they are loaded, then list spore-rails
in the Gemfile
before those other gems and require spore/rails-now
.
gem 'spore-rails', :require => 'spore/rails-now'
gem 'gem-that-requires-env-variables'
Sinatra or Plain ol' Ruby
Install the gem:
$ gem install spore
As early as possible in your application bootstrap process, load Spore:
require 'spore'
Spore.load
To ensure Spore is loaded in rake, load the tasks:
require 'spore/tasks'
task :mytask => :spore do
# things that require environment variables
end
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
Notes
The spore-rails
gem was based on dotenv
by Brandon Keepers.