figaro 0.7.0 → 1.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +6 -14
  2. data/.gitignore +1 -1
  3. data/.travis.yml +23 -18
  4. data/CHANGELOG.md +98 -0
  5. data/CONTRIBUTING.md +48 -0
  6. data/Gemfile +4 -6
  7. data/{LICENSE → LICENSE.txt} +0 -0
  8. data/README.md +184 -61
  9. data/Rakefile +1 -12
  10. data/bin/figaro +5 -0
  11. data/doc/title.png +0 -0
  12. data/figaro.gemspec +9 -5
  13. data/gemfiles/rails30.gemfile +3 -4
  14. data/gemfiles/rails31.gemfile +3 -4
  15. data/gemfiles/rails32.gemfile +3 -4
  16. data/gemfiles/rails40.gemfile +3 -7
  17. data/gemfiles/rails41.gemfile +11 -0
  18. data/lib/figaro.rb +16 -29
  19. data/lib/figaro/application.rb +91 -0
  20. data/lib/figaro/cli.rb +24 -0
  21. data/lib/figaro/cli/heroku_set.rb +29 -0
  22. data/lib/figaro/cli/task.rb +27 -0
  23. data/lib/figaro/env.rb +36 -7
  24. data/lib/figaro/error.rb +12 -0
  25. data/lib/figaro/rails.rb +9 -0
  26. data/lib/figaro/rails/application.rb +21 -0
  27. data/lib/figaro/rails/railtie.rb +9 -0
  28. data/lib/figaro/{tasks.rake → rails/tasks.rake} +0 -0
  29. data/lib/generators/figaro/install/install_generator.rb +1 -1
  30. data/lib/generators/figaro/install/templates/application.yml +10 -6
  31. data/spec/figaro/application_spec.rb +258 -0
  32. data/spec/figaro/cli/heroku_set_spec.rb +62 -0
  33. data/spec/figaro/env_spec.rb +167 -35
  34. data/spec/figaro/rails/application_spec.rb +43 -0
  35. data/spec/figaro_spec.rb +74 -36
  36. data/spec/rails_spec.rb +66 -0
  37. data/spec/spec_helper.rb +6 -3
  38. data/spec/support/aruba.rb +19 -0
  39. data/spec/support/bin/heroku +5 -0
  40. data/spec/support/command_helpers.rb +17 -0
  41. data/spec/support/command_interceptor.rb +33 -0
  42. data/spec/support/random.rb +3 -0
  43. data/spec/support/reset.rb +13 -0
  44. metadata +88 -44
  45. data/features/rails.feature +0 -97
  46. data/features/step_definitions/bundler_steps.rb +0 -7
  47. data/features/step_definitions/common_steps.rb +0 -19
  48. data/features/step_definitions/rails_steps.rb +0 -12
  49. data/features/support/aruba.rb +0 -12
  50. data/features/support/env.rb +0 -8
  51. data/lib/figaro/railtie.rb +0 -16
  52. data/lib/figaro/tasks.rb +0 -28
  53. data/spec/figaro/tasks_spec.rb +0 -71
  54. data/spec/support/rake.rb +0 -11
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- NzdlMWViMjZiNjk2MDk0MTE1YWZiNDcyMzU1ZmExOTAzYjI3ZTQyMA==
5
- data.tar.gz: !binary |-
6
- MzY4M2FhNmZkZTQ4ZWMxYTQ3NjFjYTUwYjM0YTgyYTNhNTk2YzY2OQ==
7
- !binary "U0hBNTEy":
8
- metadata.gz: !binary |-
9
- M2Y4NjlmNjJhNTZmOGM2MTAzODhlZjBmYzg3ZGNkMzQxNDFlMWI5ZTgxNzlj
10
- YmQ5YmY4NDlhZDI5ZTIyZDA0ODc4NDI0NmViNzVhYjdmMDI1YWM0YWU3Zjkw
11
- NTBkNDJmY2ZkYjdiMDk0NzQwZmI0ZmFlM2M4NDBmYTNhOTA1MTI=
12
- data.tar.gz: !binary |-
13
- YjBlYWZkZDU5MzA3NjJlNjc3N2FlZjE0OWIwZDA1YzA1MjRhM2NiNDI1MzA0
14
- MjQxNjYwNzRlYWFiNDM5YzYzY2Q0ODAzZDA3ZDVjZjVmMzcyMTk5Nzk2ZTRh
15
- ZDE0MDk1ZmJkZjRjMzkyNjk1ZmU3M2ExNjE5NmJlZGVjMmM0Y2Y=
2
+ SHA1:
3
+ metadata.gz: be2f663928712ac1479ead89e437afa4de7e36dd
4
+ data.tar.gz: 6343872755d9414093758aabc50a027bc4eedd6d
5
+ SHA512:
6
+ metadata.gz: 47fd66bb0def311e27c08271e0f03c0fe16886505882ec98fdfe5ec0b8862d800a6ce79b68f19d2fe741729b76774b98340ce845660712e2de5b264441a41105
7
+ data.tar.gz: 78fb3923162e6b3f79d23d9ab0e8118d6b267958da1c0401877c287cacdcccf2c90ac6a2ef8b8aee31ee8aa4ac848b81f4652b637afc529578e8107173461f5e
data/.gitignore CHANGED
@@ -1,4 +1,4 @@
1
- /.bundle
1
+ .bundle
2
2
  /Gemfile.lock
3
3
  /coverage
4
4
  /gemfiles/*.gemfile.lock
@@ -1,27 +1,32 @@
1
- branches: master
1
+ before_script:
2
+ - unset RAILS_ENV
3
+ - unset RACK_ENV
4
+ branches:
5
+ only:
6
+ - master
7
+ env:
8
+ global:
9
+ secure: | # CODECLIMATE_REPO_TOKEN
10
+ Pm3j2/BtAzMtqRMP83rFvDtpUNeIAdLMzwH62In+3h/AE8gHDArGYS+jmChw
11
+ 2hKVjwzVUTWZlpSEocqAg/YIDB3BJzWmyc6UP+VA0gji6HsufXYTmKAVPSVY
12
+ TQ7mPPP7hm95e3SkFbLdLbGkQfLdjIKeMY5lY/knX+QKUCjO52Y=
2
13
  gemfile:
3
14
  - gemfiles/rails30.gemfile
4
15
  - gemfiles/rails31.gemfile
5
16
  - gemfiles/rails32.gemfile
6
17
  - gemfiles/rails40.gemfile
18
+ - gemfiles/rails41.gemfile
7
19
  language: ruby
8
- rvm:
9
- - 1.8.7
10
- - 1.9.2
11
- - 1.9.3
12
- - 2.0.0
13
- before_install:
14
- - gem update bundler
15
- before_script:
16
- - unset RAILS_ENV
17
- - unset RACK_ENV
18
20
  matrix:
19
- exclude:
20
- - gemfile: gemfiles/rails40.gemfile
21
- rvm: 1.8.7
22
- - gemfile: gemfiles/rails40.gemfile
23
- rvm: 1.9.2
21
+ allow_failures:
22
+ - rvm: ruby-head
24
23
  include:
25
- - gemfile: gemfiles/rails40.gemfile
26
- rvm: 2.0.0
24
+ - gemfile: Gemfile
25
+ rvm: "2.1"
27
26
  env: COVERAGE=1
27
+ rvm:
28
+ - 1.9.3
29
+ - 2.0.0
30
+ - "2.1"
31
+ - ruby-head
32
+ script: bundle exec rspec
@@ -0,0 +1,98 @@
1
+ ## 1.0.0.rc1 / Unreleased
2
+
3
+ * [FEATURE] Add bang and boolean methods to `Figaro.env`
4
+ * [ENHANCEMENT] Detach `Figaro.env` from the configuration file hash
5
+ * [FEATURE] Add the ability to swap Figaro's application adapter
6
+ * [FEATURE] Warn when configuration keys or values are not strings
7
+ * [FEATURE] Enable Figaro to load multiple times, overwriting previous values
8
+ * [FEATURE] Load Figaro configuration prior to database configuration
9
+ * [ENHANCEMENT] Test against Ruby 2.1
10
+ * [ENHANCEMENT] Test against Rails 4.1
11
+ * [FEATURE] Replace Rake task with `figaro` executable
12
+ * [BUGFIX] Fix character escaping for `figaro heroku:set` on Windows
13
+ * [FEATURE] Warn when a preexisting configuration key is skipped during load
14
+ * [FEATURE] Add the ability to fail fast in the absence of required keys
15
+ * [FEATURE] Tie into Rails' earliest possible `before_configuration` hook
16
+
17
+ ## 0.7.0 / 2013-06-27
18
+
19
+ * [FEATURE] Allow configuration values to be overridden on the system level
20
+ * [FEATURE] Enable ERB evaluation of the configuration file
21
+
22
+ ## 0.6.4 / 2013-05-01
23
+
24
+ * [BUGFIX] Make the configuration file path platform-independent
25
+ * [FEATURE] Make `Figaro.env` proxy method calls case-insensitive
26
+
27
+ ## 0.6.3 / 2013-03-10
28
+
29
+ * [BUGFIX] Run Heroku commands with a clean Bundler environment
30
+
31
+ ## 0.6.2 / 2013-03-07
32
+
33
+ * [ENHANCEMENT] Refactor `figaro:heroku` task into a unit-tested class
34
+ * [ENHANCEMENT] Relax development gem dependency version requirements
35
+ * [ENHANCEMENT] Track test coverage
36
+
37
+ ## 0.6.1 / 2013-02-27
38
+
39
+ * [ENHANCEMENT] Declare development gem dependencies in gemfiles
40
+ * [BUGFIX] Cast boolean configuration values to strings
41
+ * [ENHANCEMENT] Use RSpec `expect` syntax
42
+
43
+ ## 0.6.0 / 2013-02-26
44
+
45
+ * [ENHANCEMENT] Test against Ruby 2.0.0
46
+ * [ENHANCEMENT] Test against Rails 4.0
47
+
48
+ ## 0.5.4 / 2013-02-22
49
+
50
+ * [ENHANCEMENT] GitHub Ruby Styleguide conventions
51
+ * [ENHANCEMENT] Remove unnecessary development dependencies
52
+ * [FEATURE] Allow `nil` values in `Figaro.env`
53
+
54
+ ## 0.5.3 / 2013-01-12
55
+
56
+ * [BUGFIX] Fix `figaro:heroku` to properly capture standard output... again
57
+
58
+ ## 0.5.2 / 2013-01-07
59
+
60
+ * [BUGFIX] Escape special characters in the `figaro:heroku` task
61
+
62
+ ## 0.5.1 / 2013-01-07
63
+
64
+ * [BUGFIX] Fix `figaro:heroku` to properly capture standard output
65
+
66
+ ## 0.5.0 / 2012-10-28
67
+
68
+ * [BUGFIX] Automatically cast configuration keys and values to strings
69
+ * [FEATURE] Allow the `figaro:heroku` task to respect remote Rails environment
70
+ * [FEATURE] Enable `Figaro.env` to act as a proxy to `ENV`
71
+
72
+ ## 0.4.1 / 2012-04-25
73
+
74
+ * [BUGFIX] Fix `figaro:heroku` Rake task failures
75
+
76
+ ## 0.4.0 / 2012-04-20
77
+
78
+ * [FEATURE] Allow environment-specific configuration
79
+
80
+ ## 0.3.0 / 2012-04-20
81
+
82
+ * [ENHANCEMENT] Refactor the loading configuration into `ENV`
83
+ * [FEATURE] Add `figaro:heroku` Rake task
84
+
85
+ ## 0.2.0 / 2012-04-03
86
+
87
+ * [ENHANCEMENT] Test against multiple Rails versions (3.0, 3.1, 3.2)
88
+ * [FEATURE] Add `figaro:install` Rails generator
89
+ * [BUGFIX] Gracefully parse YAML files containing only comments
90
+
91
+ ## 0.1.1 / 2012-04-02
92
+
93
+ * [ENHANCEMENT] Remove RSpec development gem dependency
94
+ * [ENHANCEMENT] Introduce Figaro, the mascot
95
+
96
+ ## 0.1.0 / 2012-04-02
97
+
98
+ * Initial release!
@@ -0,0 +1,48 @@
1
+ # Contributing to Figaro
2
+
3
+ Figaro is open source and contributions from the community are encouraged! No
4
+ contribution is too small.
5
+
6
+ Please consider:
7
+
8
+ * Adding a feature
9
+ * Squashing a bug
10
+ * Writing documentation
11
+ * Fixing a typo
12
+ * Correcting [style](https://github.com/styleguide/ruby)
13
+
14
+ ## How do I contribute?
15
+
16
+ For the best chance of having your changes merged, please:
17
+
18
+ 1. [Fork](https://github.com/laserlemon/figaro/fork) the project.
19
+ 2. [Write](http://en.wikipedia.org/wiki/Test-driven_development) a failing test.
20
+ 3. [Commit](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html) changes that fix the tests.
21
+ 4. [Submit](https://github.com/laserlemon/figaro/pulls) a pull request with *at least* one animated GIF.
22
+ 5. Be patient.
23
+
24
+ If your proposed changes only affect documentation, include the following on a
25
+ new line in each of your commit messages:
26
+
27
+ ```
28
+ [ci skip]
29
+ ```
30
+
31
+ This will signal [Travis](https://travis-ci.org) that running the test suite is
32
+ not necessary for these changes.
33
+
34
+ ## Bug Reports
35
+
36
+ If you are experiencing unexpected behavior and, after having read Figaro's
37
+ documentation, are convinced this behavior is a bug, please:
38
+
39
+ 1. [Search](https://github.com/laserlemon/figaro/issues) existing issues.
40
+ 2. Collect enough information to reproduce the issue:
41
+ * Figaro version
42
+ * Ruby version
43
+ * Rails version
44
+ * Specific setup conditions
45
+ * Description of expected behavior
46
+ * Description of actual behavior
47
+ 3. [Submit](https://github.com/laserlemon/figaro/issues/new) an issue.
48
+ 4. Be patient.
data/Gemfile CHANGED
@@ -2,13 +2,11 @@ source "https://rubygems.org"
2
2
 
3
3
  gemspec
4
4
 
5
- gem "rails", ">= 3.0.2", "< 5"
5
+ gem "rails", ">= 3.0.3", "< 5"
6
6
 
7
7
  group :test do
8
8
  gem "aruba", "~> 0.5"
9
- gem "coveralls", "~> 0.6", :require => false
10
- gem "cucumber", "~> 1.3"
11
- gem "rake", "~> 10.0"
12
- gem "rspec", "~> 2.13"
13
- gem "simplecov", "~> 0.7", :require => false
9
+ gem "codeclimate-test-reporter", "~> 0.3.0", require: false
10
+ gem "rspec", "~> 2.14"
11
+ gem "sqlite3", "~> 1.3"
14
12
  end
File without changes
data/README.md CHANGED
@@ -1,114 +1,237 @@
1
- # Figaro
2
- [![Gem Version](https://badge.fury.io/rb/figaro.png)](http://badge.fury.io/rb/figaro)
3
- [![Build Status](https://travis-ci.org/laserlemon/figaro.png?branch=master)](https://travis-ci.org/laserlemon/figaro)
4
- [![Code Climate](https://codeclimate.com/github/laserlemon/figaro.png)](https://codeclimate.com/github/laserlemon/figaro)
5
- [![Coverage Status](https://coveralls.io/repos/laserlemon/figaro/badge.png?branch=master)](https://coveralls.io/r/laserlemon/figaro)
6
- [![Dependency Status](https://gemnasium.com/laserlemon/figaro.png)](https://gemnasium.com/laserlemon/figaro)
1
+ # ![Figaro](doc/title.png)
7
2
 
8
- Simple Rails app configuration
3
+ Simple, Heroku-friendly Rails app configuration using `ENV` and a single YAML file
9
4
 
10
- ## What is this for?
5
+ [![Gom Version](https://img.shields.io/gem/v/figaro.svg)](http://badge.fury.io/rb/figaro)
6
+ [![Build Status](https://img.shields.io/travis/laserlemon/figaro/master.svg)](https://travis-ci.org/laserlemon/figaro)
7
+ [![Code Climate](https://img.shields.io/codeclimate/github/laserlemon/figaro.svg)](https://codeclimate.com/github/laserlemon/figaro)
8
+ [![Coverage Status](https://img.shields.io/codeclimate/coverage/github/laserlemon/figaro.svg)](https://codeclimate.com/github/laserlemon/figaro)
9
+ [![Dependency Status](https://img.shields.io/gemnasium/laserlemon/figaro.svg)](https://gemnasium.com/laserlemon/figaro)
11
10
 
12
- Figaro is for configuring Rails (3 and 4) apps, especially open source Rails apps.
11
+ ## Why does Figaro exist?
13
12
 
14
- Open sourcing a Rails app can be a little tricky when it comes to sensitive configuration information like [Pusher](http://pusher.com/) or [Stripe](https://stripe.com/) credentials. You don't want to check private credentials into the repo but what other choice is there?
13
+ Figaro was written to make it easy to securely configure Rails applications.
15
14
 
16
- Figaro provides a clean and simple way to configure your app and keep the private stuff… private.
15
+ Configuration values often include sensitive information. Figaro strives to be secure by default by encouraging a convention that keeps configuration out of Git.
17
16
 
18
- ## How does it work?
17
+ ## How does Figaro work?
19
18
 
20
- There are a few similar solutions out there, and a lot of homegrown attempts. Most namespace your configuration under a `Config` (or similar) namespace. That's fine, but there's already a place to describe the application environment… `ENV`!
19
+ Figaro is inspired by the [Twelve-Factor App](http://12factor.net) methodology, which states:
21
20
 
22
- `ENV` is a collection of simple string key/value pairs and it works just great for application configuration.
21
+ > The twelve-factor app stores config in environment variables (often shortened to env vars or env). Env vars are easy to change between deploys without changing any code; unlike config files, there is little chance of them being checked into the code repo accidentally; and unlike custom config files, or other config mechanisms such as Java System Properties, they are a language- and OS-agnostic standard.
23
22
 
24
- As an added bonus, this is exactly how apps on [Heroku](http://www.heroku.com/) are configured. So if you configure your Rails app using `ENV`, you're already set to deploy to Heroku.
23
+ This is straightforward in production environments but local development environments are often shared between multiple applications, requiring multiple configurations.
25
24
 
26
- ## Give me an example.
25
+ Figaro parses a Git-ignored YAML file in your application and loads its values into `ENV`.
27
26
 
28
- Okay. Add Figaro to your Gemfile and run the `bundle` command to install it:
27
+ ### Example
28
+
29
+ Given the following configuration file:
30
+
31
+ ```yaml
32
+ # config/application.yml
33
+
34
+ pusher_app_id: "2954"
35
+ pusher_key: "7381a978f7dd7f9a1117"
36
+ pusher_secret: "abdc3b896a0ffb85d373"
37
+ ```
38
+
39
+ You can configure [Pusher](http://pusher.com) in an initializer:
29
40
 
30
41
  ```ruby
31
- gem "figaro"
42
+ # config/initializers/pusher.rb
43
+
44
+ Pusher.app_id = ENV["pusher_app_id"]
45
+ Pusher.key = ENV["pusher_key"]
46
+ Pusher.secret = ENV["pusher_secret"]
32
47
  ```
33
48
 
34
- Next up, use the generator provided by Figaro:
49
+ **Please note:** `ENV` is a simple key/value store. All values will be converted to strings. Deeply nested configuration structures are not possible.
35
50
 
36
- ```bash
37
- rails generate figaro:install
51
+ ### Environment-Specific Configuration
52
+
53
+ Oftentimes, local configuration values change depending on Rails environment. In such cases, you can add environment-specific values to your configuration file:
54
+
55
+ ```yaml
56
+ # config/application.yml
57
+
58
+ pusher_app_id: "2954"
59
+ pusher_key: "7381a978f7dd7f9a1117"
60
+ pusher_secret: "abdc3b896a0ffb85d373"
61
+
62
+ test:
63
+ pusher_app_id: "5112"
64
+ pusher_key: "ad69caf9a44dcac1fb28"
65
+ pusher_secret: "83ca7aa160fedaf3b350"
38
66
  ```
39
67
 
40
- This creates a commented `config/application.yml` file and ignores it in your `.gitignore`. Add your own configuration to this file and you're done!
68
+ You can also nullify configuration values for a specific environment:
41
69
 
42
- Your configuration will be available as key/value pairs in `ENV`. For example, here's `config/initializers/pusher.rb`:
70
+ ```yaml
71
+ # config/application.yml
72
+
73
+ google_analytics_key: "UA-35722661-5"
74
+
75
+ test:
76
+ google_analytics_key: ~
77
+ ```
78
+
79
+ ### Using `Figaro.env`
80
+
81
+ `Figaro.env` is a convenience that acts as a proxy to `ENV`.
82
+
83
+ In testing, it is sometimes more convenient to stub and unstub `Figaro.env` than to set and reset `ENV`. Whether your application uses `ENV` or `Figaro.env` is entirely a matter of personal preference.
84
+
85
+ ```yaml
86
+ # config/application.yml
87
+
88
+ stripe_api_key: "sk_live_dSqzdUq80sw9GWmuoI0qJ9rL"
89
+ ```
43
90
 
44
91
  ```ruby
45
- Pusher.app_id = ENV["PUSHER_APP_ID"]
46
- Pusher.key = ENV["PUSHER_KEY"]
47
- Pusher.secret = ENV["PUSHER_SECRET"]
92
+ ENV["stripe_api_key"] # => "sk_live_dSqzdUq80sw9GWmuoI0qJ9rL"
93
+ ENV.key?("stripe_api_key") # => true
94
+ ENV["google_analytics_key"] # => nil
95
+ ENV.key?("google_analytics_key") # => false
96
+
97
+ Figaro.env.stripe_api_key # => "sk_live_dSqzdUq80sw9GWmuoI0qJ9rL"
98
+ Figaro.env.stripe_api_key? # => true
99
+ Figaro.env.google_analytics_key # => nil
100
+ Figaro.env.google_analytics_key? # => false
48
101
  ```
49
102
 
50
- In addition, you can access these same configuration values through Figaro itself:
103
+ ### Required Keys
104
+
105
+ If a particular configuration value is required but not set, it's appropriate to raise an error. With Figaro, you can either raise these errors proactively or lazily.
106
+
107
+ To proactively require configuration keys:
51
108
 
52
109
  ```ruby
53
- Pusher.app_id = Figaro.env.pusher_app_id
54
- Pusher.key = Figaro.env.pusher_key
55
- Pusher.secret = Figaro.env.pusher_secret
110
+ # config/initializers/figaro.rb
111
+
112
+ Figaro.require("pusher_app_id", "pusher_key", "pusher_secret")
56
113
  ```
57
114
 
58
- But wait… I thought configuration via constant was bad! Well, this is different. Rather than storing a _copy_ of `ENV` internally, `Figaro.env` passes directly through to `ENV`, making it just like using `ENV` itself. So why two approaches? Having your configurations available via method calls makes it easy to stub them out in tests. Either way is fine. The choice is yours!
115
+ If any of the configuration keys above are not set, your application will raise an error during initialization. This method is preferred because it prevents runtime errors in a production application due to improper configuration.
59
116
 
60
- If your app requires Rails-environment-specific configuration, you can also namespace your configuration under a key for `Rails.env`.
117
+ To require configuration keys lazily, reference the variables via "bang" methods on `Figaro.env`:
61
118
 
62
- ```yaml
63
- HELLO: world
64
- development:
65
- HELLO: developers
66
- production:
67
- HELLO: users
119
+ ```ruby
120
+ # config/initializers/pusher.rb
121
+
122
+ Pusher.app_id = Figaro.env.pusher_app_id!
123
+ Pusher.key = Figaro.env.pusher_key!
124
+ Pusher.secret = Figaro.env.pusher_secret!
68
125
  ```
69
126
 
70
- In this case, `ENV["HELLO"]` will produce `"developers"` in development, `"users"` in production and `"world"` otherwise.
127
+ ### Deployment
71
128
 
72
- ## How does it work with Heroku?
129
+ Figaro is written with deployment in mind. In fact, [Heroku](https://www.heroku.com)'s use of `ENV` for application configuration was the original inspiration for Figaro.
73
130
 
74
- Heroku's beautifully simple application configuration was the [inspiration](http://laserlemon.com/blog/2011/03/08/heroku-friendly-application-configuration/) for Figaro.
131
+ #### Heroku
75
132
 
76
- Typically, to configure your application `ENV` on Heroku, you would do the following from the command line using the `heroku` gem:
133
+ Heroku already makes setting application configuration easy:
77
134
 
78
135
  ```bash
79
- heroku config:add PUSHER_APP_ID=8926
80
- heroku config:add PUSHER_KEY=0463644d89a340ff1132
81
- heroku config:add PUSHER_SECRET=0eadfd9847769f94367b
82
- heroku config:add STRIPE_API_KEY=jHXKPPE0dUW84xJNYzn6CdWM2JfrCbPE
83
- heroku config:add STRIPE_PUBLIC_KEY=pk_HHtUKJwlN7USCT6nE5jiXgoduiNl3
136
+ $ heroku config:set google_analytics_key=UA-35722661-5
84
137
  ```
85
138
 
86
- But Figaro provides a rake task to do just that! Just run:
139
+ Using the `figaro` command, you can set values from your configuration file all at once:
87
140
 
88
141
  ```bash
89
- rake figaro:heroku
142
+ $ figaro heroku:set -e production
90
143
  ```
91
144
 
92
- Optionally, you can pass in the name of the Heroku app:
145
+ For more information:
93
146
 
94
147
  ```bash
95
- rake figaro:heroku[my-awesome-app]
148
+ $ figaro help heroku:set
96
149
  ```
97
150
 
98
- Additionally, if `RAILS_ENV` is configured on your Heroku server, Figaro will use that environment automatically in determining your proper configuration.
151
+ #### Other Hosts
152
+
153
+ If you're not deploying to Heroku, you have two options:
154
+
155
+ * Generate a remote configuration file
156
+ * Set `ENV` variables directly
157
+
158
+ Generating a remote configuration file is preferred because of:
159
+
160
+ * familiarity – Management of `config/application.yml` is like that of `config/database.yml`.
161
+ * isolation – Multiple applications on the same server will not produce configuration key collisions.
162
+
163
+ ## Is Figaro like [dotenv](https://github.com/bkeepers/dotenv)?
164
+
165
+ Yes. Kind of.
166
+
167
+ Figaro and dotenv were written around the same time to solve similar problems.
168
+
169
+ ### Similarities
170
+
171
+ * Both libraries are useful for Ruby application configuration.
172
+ * Both are popular and well maintained.
173
+ * Both are inspired by Twelve-Factor App's concept of proper [configuration](http://12factor.net/config).
174
+ * Both store configuration values in `ENV`.
175
+
176
+ ### Differences
177
+
178
+ * Configuration File
179
+ * Figaro expects a single file.
180
+ * Dotenv supports separate files for each environment.
181
+ * Configuration File Format
182
+ * Figaro expects YAML containing key/value pairs.
183
+ * Dotenv convention is a collection of `KEY=VALUE` pairs.
184
+ * Security vs. Convenience
185
+ * Figaro convention is to never commit configuration files.
186
+ * Dotenv encourages committing configuration files containing development values.
187
+ * Framework Focus
188
+ * Figaro was written with a focus on Rails development and conventions.
189
+ * Dotenv was written to accommodate any type of Ruby application.
190
+
191
+ Either library may suit your configuration needs. It often boils down to personal preference.
192
+
193
+ ## Is application.yml like [secrets.yml](https://github.com/rails/rails/blob/v4.1.0/railties/lib/rails/generators/rails/app/templates/config/secrets.yml)?
194
+
195
+ Yes. Kind of.
196
+
197
+ Rails 4.1 introduced the `secrets.yml` convention for Rails application configuration. Figaro predated the Rails 4.1 release by two years.
198
+
199
+ ### Similarities
200
+
201
+ * Both are useful for Rails application configuration.
202
+ * Both are popular and well maintained.
203
+ * Both expect a single YAML file.
204
+
205
+ ### Differences
206
+
207
+ * Configuration Access
208
+ * Figaro stores configuration values in `ENV`.
209
+ * Rails stores configuration values in `Rails.application.secrets`.
210
+ * Configuration File Structure
211
+ * Figaro expects YAML containing key/value string pairs.
212
+ * Secrets may contain nested structures with rich objects.
213
+ * Security vs. Convenience
214
+ * Figaro convention is to never commit configuration files.
215
+ * Secrets are committed by default.
216
+ * Consistency
217
+ * Figaro uses `ENV` for configuration in every environment.
218
+ * Secrets encourage using `ENV` for production only.
219
+ * Approach
220
+ * Figaro is inspired by Twelve-Factor App's concept of proper [configuration](http://12factor.net/config).
221
+ * Secrets are… not.
222
+
223
+ The emergence of a configuration convention for Rails is an important step, but as long as the last three differences above exist, Figaro will continue to be developed as a more secure, more consistent, and more standards-compliant alternative to `secrets.yml`.
99
224
 
100
- ## What if I'm not using Heroku?
225
+ For more information, read the original [The Marriage of Figaro… and Rails](http://www.collectiveidea.com/blog/archives/2013/12/18/the-marriage-of-figaro-and-rails/) blog post.
101
226
 
102
- No problem. Just add `config/application.yml` to your production app on the server.
227
+ ## Who wrote Figaro?
103
228
 
104
- ## This sucks. How can I make it better?
229
+ My name is Steve Richert and I wrote Figaro in March, 2012 with overwhelming encouragement from my employer, [Collective Idea](http://www.collectiveidea.com). Figaro has improved very much since then, thanks entirely to [inspiration](https://github.com/laserlemon/figaro/issues) and [contribution](https://github.com/laserlemon/figaro/graphs/contributors) from developers everywhere.
105
230
 
106
- 1. Fork it.
107
- 2. Make it better.
108
- 3. Send me a pull request.
231
+ **Thank you!**
109
232
 
110
- ## Does Figaro have a mascot?
233
+ ## How can I help?
111
234
 
112
- Yes.
235
+ Figaro is open source and contributions from the community are encouraged! No contribution is too small.
113
236
 
114
- [![Figaro](http://images2.wikia.nocookie.net/__cb20100628192722/disney/images/5/53/Pinocchio-pinocchio-4947890-960-720.jpg "Figaro's mascot: Figaro")](http://en.wikipedia.org/wiki/Figaro_(Disney\))
237
+ See Figaro's [contribution guidelines](CONTRIBUTING.md) for more information.