README.md in rails_config-0.5.0.beta1 vs README.md in rails_config-0.99.0
- old
+ new
@@ -1,8 +1,10 @@
-[![Build Status](https://api.travis-ci.org/railsconfig/rails_config.png?branch=master)](http://travis-ci.org/railsconfig/rails_config)
+[![Build Status](https://api.travis-ci.org/railsconfig/rails_config.svg?branch=master)](http://travis-ci.org/railsconfig/rails_config)
[![Gem Version](https://badge.fury.io/rb/rails_config.svg)](http://badge.fury.io/rb/rails_config)
-[![Dependency Status](https://gemnasium.com/railsjedi/rails_config.svg)](https://gemnasium.com/railsjedi/rails_config)
+[![Dependency Status](https://gemnasium.com/railsconfig/rails_config.svg)](https://gemnasium.com/railsconfig/rails_config)
+[![Code Climate](https://codeclimate.com/github/railsconfig/rails_config/badges/gpa.svg)](https://codeclimate.com/github/railsconfig/rails_config)
+[![Test Coverage](https://codeclimate.com/github/railsconfig/rails_config/badges/coverage.svg)](https://codeclimate.com/github/railsconfig/rails_config/coverage)
# RailsConfig
## Summary
@@ -15,10 +17,11 @@
* config files support inheritance
* access config information via convenient object member notation
## Compatibility
+* Ruby 2.x
* Rails 3.x and 4.x
* Padrino
* Sinatra
For older versions of Rails and other Ruby apps, use [AppConfig](http://github.com/fredwu/app_config).
@@ -29,10 +32,29 @@
```ruby
gem "rails_config"
```
+If you want to use Settings before rails application initialization process you can load RailsConfig railtie manually:
+
+```ruby
+module Appname
+ class Application < Rails::Application
+
+ Bundler.require(*Rails.groups)
+ RailsConfig::Integration::Rails::Railtie.preload
+
+ ...
+
+ config.time_zone = Settings.time_zone
+
+ ...
+
+ end
+end
+```
+
## Installing on Padrino
Add this to your `Gemfile`:
```ruby
@@ -172,10 +194,20 @@
Settings.reload!
```
This will use the given source.yml file and use its settings to overwrite any previous ones.
+On the other hand, you can prepend a YML file to the list of configuration files:
+
+```ruby
+Settings.prepend_source!("/path/to/source.yml")
+Settings.reload!
+```
+
+This will do the same as `add_source`, but the given YML file will be loaded first (instead of last) and its settings will be overwritten by any other configuration file.
+This is especially useful if you want to define defaults.
+
One thing I like to do for my Rails projects is provide a local.yml config file that is .gitignored (so its independent per developer). Then I create a new initializer in `config/initializers/add_local_config.rb` with the contents
```ruby
Settings.add_source!("#{Rails.root}/config/settings/local.yml")
Settings.reload!
@@ -190,18 +222,16 @@
## Accessing Configuration Settings
Consider the two following config files.
- #{Rails.root}/config/settings.yml:
-
+* ```#{Rails.root}/config/settings.yml```
```yaml
size: 1
server: google.com
```
- #{Rails.root}/config/environments/development.yml:
-
+* ```#{Rails.root}/config/environments/development.yml```
```yaml
size: 2
computed: <%= 1 + 2 + 3 %>
section:
size: 3