Confstruct::Rails

Integrate Confstruct with Rails!

Installation

Add this line to your application's Gemfile:

gem 'confstruct-rails'

And then execute:

$ bundle

Or install it yourself as:

$ gem install confstruct-rails

Usage

This Gem is an integration of confstruct with Rails

It reads your config from:

config/settings.yml
config/settings/#{environment}.yml
config/environments/#{environment}.yml

config/settings.local.yml
config/settings/#{environment}.local.yml
config/environments/#{environment}.local.yml

And exposes it globally as a Confsturct::Configuration object:

Conf
# => <Confsturct::Configuration:0x007fa87ae47300>
Conf.foo
# => bar
Conf[:foo]
# => bar
Conf.foo.bar
# => baz
Conf[:foo][:bar]
# => baz
Conf[:foo].bar
# => baz
Conf.bar[:foo]
# => baz

This object can be used anywhere in your application:

  • application.rb
  • environments/<enviroment>.rb
  • database.yml
  • views
  • helpers
  • anywhere!

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

Thanks

  • RailsJedi, author of rails_config, which this gem takes inspiration from (file locations/names).