README.md in anyway_config-0.1.0 vs README.md in anyway_config-0.2.0
- old
+ new
@@ -1,15 +1,17 @@
[](https://travis-ci.org/palkan/anyway_config)
# Anyway Config
-Rails plugin configuration using any source: YAML, _secrets_, environment.
+Rails plugin/application configuration using any source: YAML, _secrets_, environment.
-Requires Rails 4.
-## Installation
+Apps using Anyway Config:
+- [influxer](https://github.com/palkan/influxer).
+## Using with Gem
+
Configure your gemspec
```ruby
Gem::Specification.new do |s|
...
@@ -24,17 +26,16 @@
Or install it yourself as:
$ gem install anyway_config
-## Usage
+### Usage
-### Basic
-
Create configuration class:
```ruby
+require 'anyway'
module MyCoolGem
class Config < Anyway::Config
attr_config user: 'root', password: 'root', host: 'localhost'
end
end
@@ -59,22 +60,55 @@
attr_config user: 'root', password: 'root', host: 'localhost', options: {}
end
end
```
-### How to set env vars
+### Config clear and reload
+You can use `clear` and `reload` functions on your config (which do exactly what they state).
+
+
+## Using with Rails app
+
+In your Gemfile
+
+```ruby
+require 'anyway_config', "~>0.2"
+```
+
+In your code
+
+```ruby
+
+config = Anyway::Config.for(:my_app) # load data from config/my_app.yml, secrets.my_app, ENV["MYAPP_*"]
+
+```
+
+## `Rails.application.config_for` vs `Anyway::Config.for`
+
+Rails 4.2 introduces new feature: `Rails.application.config_for`. It looks very similar to
+`Anyway::Config.for`, but there are some differences:
+
+| Feature | Rails | Anyway |
+| ------------- |:-------------:| -----:|
+| load data from `config/app.yml` | yes | yes |
+| load data from `secrets` | no | yes |
+| load data from environment | no | yes |
+| return Hash with indifferent access | no | yes |
+| support ERB within `config/app.yml` | yes | no |
+| raise errors if file doesn't exist | yes | no |
+
+But the main advantage of Anyway::Config is that it's supported in Rails >= 3.2, Ruby >= 1.9.3.
+
+## How to set env vars
+
Environmental variables for your config should start with your module name (or config name if any), uppercased and underscore-free.
For example, if your module is called "MyCoolGem" then your env var "MYCOOLGEM_PASSWORD" is used as `config.password`.
*Anyway Config* supports nested (_hashed_) environmental variables. Just separate keys with double-underscore.
For example, "MYCOOLGEM_OPTIONS__VERBOSE" is transformed to `config.options.verbose`.
-
-### Config clear and reload
-
-You can use `clear` and `reload` functions on your config (which do exactly what they state).
## Contributing
1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
\ No newline at end of file