seielit-figaro 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +6 -0
  3. data/.rspec +3 -0
  4. data/.travis.yml +30 -0
  5. data/CHANGELOG.md +122 -0
  6. data/CONTRIBUTING.md +48 -0
  7. data/Gemfile +14 -0
  8. data/LICENSE.txt +22 -0
  9. data/README.md +350 -0
  10. data/Rakefile +6 -0
  11. data/bin/figaro +5 -0
  12. data/gemfiles/rails41.gemfile +12 -0
  13. data/gemfiles/rails42.gemfile +12 -0
  14. data/gemfiles/rails50.gemfile +13 -0
  15. data/gemfiles/rails51.gemfile +13 -0
  16. data/gemfiles/rails52.gemfile +14 -0
  17. data/gemfiles/rails60.gemfile +14 -0
  18. data/lib/figaro.rb +33 -0
  19. data/lib/figaro/application.rb +91 -0
  20. data/lib/figaro/cli.rb +42 -0
  21. data/lib/figaro/cli/heroku_set.rb +33 -0
  22. data/lib/figaro/cli/install.rb +32 -0
  23. data/lib/figaro/cli/install/application.yml +11 -0
  24. data/lib/figaro/cli/task.rb +33 -0
  25. data/lib/figaro/env.rb +45 -0
  26. data/lib/figaro/error.rb +17 -0
  27. data/lib/figaro/rails.rb +7 -0
  28. data/lib/figaro/rails/application.rb +21 -0
  29. data/lib/figaro/rails/railtie.rb +10 -0
  30. data/lib/figaro/rails/tasks.rake +6 -0
  31. data/lib/figaro/settings.rb +124 -0
  32. data/seielit-figaro.gemspec +23 -0
  33. data/spec/figaro/application_spec.rb +262 -0
  34. data/spec/figaro/cli/heroku_set_spec.rb +67 -0
  35. data/spec/figaro/cli/install_spec.rb +49 -0
  36. data/spec/figaro/env_spec.rb +195 -0
  37. data/spec/figaro/rails/application_spec.rb +47 -0
  38. data/spec/figaro/settings_spec.rb +109 -0
  39. data/spec/figaro_spec.rb +106 -0
  40. data/spec/rails_spec.rb +50 -0
  41. data/spec/spec_helper.rb +13 -0
  42. data/spec/support/aruba.rb +19 -0
  43. data/spec/support/bin/heroku +5 -0
  44. data/spec/support/command_helpers.rb +17 -0
  45. data/spec/support/command_interceptor.rb +33 -0
  46. data/spec/support/reset.rb +13 -0
  47. metadata +145 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: bb2371a68f48052f2b9c7fa880a0974f04d08f11b89ac15a7edcd57b8f9671bc
4
+ data.tar.gz: c34933f5fcc1447207baa7709d70e93d9cafaecbaef6cdc2d7babd19c596e959
5
+ SHA512:
6
+ metadata.gz: f71de50296dce3c6b7538425c14e1452d0876a717f2fac34b13adab62e945c08d80d793c6f9a605f00e6019e97f90793c6e60b845ebf14f88900ecc463f1bcd6
7
+ data.tar.gz: 39faf69363a61bb7ee8f7b3f8c122d3b4eec32a9262318e12e45cc9ce39ff7d7f2072184aebd674cf295f35801bd4e07bc13a0c0f7eb4c1c46361f18cf80c3d4
@@ -0,0 +1,6 @@
1
+ .bundle
2
+ /Gemfile.lock
3
+ /coverage
4
+ /gemfiles/*.gemfile.lock
5
+ /pkg
6
+ /tmp
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --color
2
+ --order random
3
+ --require spec_helper
@@ -0,0 +1,30 @@
1
+ before_install:
2
+ - gem update bundler rake
3
+ before_script:
4
+ - unset RAILS_ENV
5
+ - unset RACK_ENV
6
+ branches:
7
+ only:
8
+ - master
9
+ cache: bundler
10
+ env:
11
+ global:
12
+ secure: | # CODECLIMATE_REPO_TOKEN
13
+ Pm3j2/BtAzMtqRMP83rFvDtpUNeIAdLMzwH62In+3h/AE8gHDArGYS+jmChw
14
+ 2hKVjwzVUTWZlpSEocqAg/YIDB3BJzWmyc6UP+VA0gji6HsufXYTmKAVPSVY
15
+ TQ7mPPP7hm95e3SkFbLdLbGkQfLdjIKeMY5lY/knX+QKUCjO52Y=
16
+ gemfile:
17
+ - gemfiles/rails50.gemfile
18
+ - gemfiles/rails51.gemfile
19
+ - gemfiles/rails52.gemfile
20
+ - gemfiles/rails60.gemfile
21
+ language: ruby
22
+ matrix:
23
+ allow_failures:
24
+ - rvm: ruby-head
25
+ rvm:
26
+ - "2.5"
27
+ - "2.6"
28
+ - ruby-head
29
+ script: bundle exec rspec
30
+ sudo: false
@@ -0,0 +1,122 @@
1
+ ## 1.1.2 / 2019-08-27
2
+
3
+ * [ENHANCEMENT] Enable usage outside of Rails ([thanks to l8nite](https://github.com/laserlemon/figaro/pull/232))
4
+ * [ENHANCEMENT] Update Rails and Ruby supported versions and fix test scripts
5
+ * [FEATURE] Add Figaro::Settings DSL for abstracting data conversion and
6
+ manipulation
7
+
8
+ ## 1.1.1 / 2015-04-30
9
+
10
+ * [BUGFIX] Fix crash when environment-specific configuration is `nil`
11
+
12
+ ## 1.1.0 / 2015-01-27
13
+
14
+ * [FEATURE] Support --remote when setting Heroku configuration
15
+ * [ENHANCEMENT] Test against Rails 4.2 (stable)
16
+
17
+ ## 1.0.0 / 2014-09-17
18
+
19
+ * [BUGFIX] Make calls to Heroku with a clean Bundler environment
20
+ * [ENHANCEMENT] Remove Rails as a runtime dependency
21
+ * [FEATURE] Replace the Rails generator with the `figaro install` task
22
+ * [ENHANCEMENT] Rename the `Figaro.require` method to `Figaro.require_keys`
23
+ * [ENHANCEMENT] Begin to test against Rails 4.2 (beta)
24
+
25
+ ## 1.0.0.rc1 / 2014-04-17
26
+
27
+ * [FEATURE] Add bang and boolean methods to `Figaro.env`
28
+ * [ENHANCEMENT] Detach `Figaro.env` from the configuration file hash
29
+ * [FEATURE] Add the ability to swap Figaro's application adapter
30
+ * [FEATURE] Warn when configuration keys or values are not strings
31
+ * [FEATURE] Enable Figaro to load multiple times, overwriting previous values
32
+ * [FEATURE] Load Figaro configuration prior to database configuration
33
+ * [ENHANCEMENT] Test against Ruby 2.1
34
+ * [ENHANCEMENT] Test against Rails 4.1
35
+ * [FEATURE] Replace Rake task with `figaro` executable
36
+ * [BUGFIX] Fix character escaping for `figaro heroku:set` on Windows
37
+ * [FEATURE] Warn when a preexisting configuration key is skipped during load
38
+ * [FEATURE] Add the ability to fail fast in the absence of required keys
39
+ * [FEATURE] Tie into Rails' earliest possible `before_configuration` hook
40
+
41
+ ## 0.7.0 / 2013-06-27
42
+
43
+ * [FEATURE] Allow configuration values to be overridden on the system level
44
+ * [FEATURE] Enable ERB evaluation of the configuration file
45
+
46
+ ## 0.6.4 / 2013-05-01
47
+
48
+ * [BUGFIX] Make the configuration file path platform-independent
49
+ * [FEATURE] Make `Figaro.env` proxy method calls case-insensitive
50
+
51
+ ## 0.6.3 / 2013-03-10
52
+
53
+ * [BUGFIX] Run Heroku commands with a clean Bundler environment
54
+
55
+ ## 0.6.2 / 2013-03-07
56
+
57
+ * [ENHANCEMENT] Refactor `figaro:heroku` task into a unit-tested class
58
+ * [ENHANCEMENT] Relax development gem dependency version requirements
59
+ * [ENHANCEMENT] Track test coverage
60
+
61
+ ## 0.6.1 / 2013-02-27
62
+
63
+ * [ENHANCEMENT] Declare development gem dependencies in gemfiles
64
+ * [BUGFIX] Cast boolean configuration values to strings
65
+ * [ENHANCEMENT] Use RSpec `expect` syntax
66
+
67
+ ## 0.6.0 / 2013-02-26
68
+
69
+ * [ENHANCEMENT] Test against Ruby 2.0.0
70
+ * [ENHANCEMENT] Test against Rails 4.0
71
+
72
+ ## 0.5.4 / 2013-02-22
73
+
74
+ * [ENHANCEMENT] GitHub Ruby Styleguide conventions
75
+ * [ENHANCEMENT] Remove unnecessary development dependencies
76
+ * [FEATURE] Allow `nil` values in `Figaro.env`
77
+
78
+ ## 0.5.3 / 2013-01-12
79
+
80
+ * [BUGFIX] Fix `figaro:heroku` to properly capture standard output... again
81
+
82
+ ## 0.5.2 / 2013-01-07
83
+
84
+ * [BUGFIX] Escape special characters in the `figaro:heroku` task
85
+
86
+ ## 0.5.1 / 2013-01-07
87
+
88
+ * [BUGFIX] Fix `figaro:heroku` to properly capture standard output
89
+
90
+ ## 0.5.0 / 2012-10-28
91
+
92
+ * [BUGFIX] Automatically cast configuration keys and values to strings
93
+ * [FEATURE] Allow the `figaro:heroku` task to respect remote Rails environment
94
+ * [FEATURE] Enable `Figaro.env` to act as a proxy to `ENV`
95
+
96
+ ## 0.4.1 / 2012-04-25
97
+
98
+ * [BUGFIX] Fix `figaro:heroku` Rake task failures
99
+
100
+ ## 0.4.0 / 2012-04-20
101
+
102
+ * [FEATURE] Allow environment-specific configuration
103
+
104
+ ## 0.3.0 / 2012-04-20
105
+
106
+ * [ENHANCEMENT] Refactor the loading configuration into `ENV`
107
+ * [FEATURE] Add `figaro:heroku` Rake task
108
+
109
+ ## 0.2.0 / 2012-04-03
110
+
111
+ * [ENHANCEMENT] Test against multiple Rails versions (3.0, 3.1, 3.2)
112
+ * [FEATURE] Add `figaro:install` Rails generator
113
+ * [BUGFIX] Gracefully parse YAML files containing only comments
114
+
115
+ ## 0.1.1 / 2012-04-02
116
+
117
+ * [ENHANCEMENT] Remove RSpec development gem dependency
118
+ * [ENHANCEMENT] Introduce Figaro, the mascot
119
+
120
+ ## 0.1.0 / 2012-04-02
121
+
122
+ * 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 ADDED
@@ -0,0 +1,14 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
4
+
5
+ gem "rails", ">= 3.0.3", "< 6.1"
6
+ gem 'listen'
7
+
8
+ group :test do
9
+ gem "aruba", "~> 0.6.2"
10
+ gem "codeclimate-test-reporter", require: false
11
+ gem "rspec", "~> 3.1"
12
+ gem "sqlite3", "~> 1.4.0"
13
+ gem 'bootsnap', '1.4.4'
14
+ end
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Steve Richert
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,350 @@
1
+ # ![Figaro](https://raw.githubusercontent.com/laserlemon/figaro/1f6e709/doc/title.png)
2
+
3
+ Simple, Heroku-friendly Rails app configuration using `ENV` and a single YAML file.
4
+
5
+ This fork includes some enhancements, see below.
6
+
7
+ [![Gem Version](https://img.shields.io/gem/v/figaro.svg?style=flat-square)](http://badge.fury.io/rb/figaro)
8
+ [![Build Status](https://img.shields.io/travis/seielit/figaro/master.svg?style=flat-square)](https://travis-ci.org/seielit/figaro)
9
+ [![Code Climate](https://img.shields.io/codeclimate/github/seielit/figaro.svg?style=flat-square)](https://codeclimate.com/github/seielit/figaro)
10
+ [![Coverage Status](https://img.shields.io/codeclimate/coverage/github/seielit/figaro.svg?style=flat-square)](https://codeclimate.com/github/seielit/figaro)
11
+ [![Dependency Status](https://img.shields.io/gemnasium/seielit/figaro.svg?style=flat-square)](https://gemnasium.com/seielit/figaro)
12
+
13
+ **NOTE:** If you're using Figaro 0.7 or prior, please refer to the
14
+ [appropriate documentation](https://github.com/laserlemon/figaro/tree/0-stable#readme)
15
+ or [upgrade](#how-do-i-upgrade-to-figaro-10) to Figaro 1.0.
16
+
17
+ ## Fork Changes
18
+
19
+ * testing: remove support for EOL versions of Ruby and Rails, and add support
20
+ for newer versions (Rails: 5.1 - 6.0; Ruby: 2.5 - 2.6);
21
+ * incorporate laserlemon/figaro#232: Don't "require 'rails'" at require-time;
22
+ * [TODO] add Settings DSL;
23
+
24
+ ## Why does Figaro exist?
25
+
26
+ Figaro was written to make it easy to securely configure Rails applications.
27
+
28
+ Configuration values often include sensitive information. Figaro strives to be
29
+ secure by default by encouraging a convention that keeps configuration out of
30
+ Git.
31
+
32
+ ## How does Figaro work?
33
+
34
+ Figaro is inspired by the [Twelve-Factor App](http://12factor.net) methodology,
35
+ which states:
36
+
37
+ > 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.
38
+
39
+ This is straightforward in production environments but local development
40
+ environments are often shared between multiple applications, requiring multiple
41
+ configurations.
42
+
43
+ Figaro parses a Git-ignored YAML file in your application and loads its values
44
+ into `ENV`.
45
+
46
+ ### Getting Started
47
+
48
+ Add Figaro to your Gemfile and `bundle install`:
49
+
50
+ ```ruby
51
+ gem "figaro"
52
+ ```
53
+
54
+ Figaro installation is easy:
55
+
56
+ ```bash
57
+ $ bundle exec figaro install
58
+ ```
59
+
60
+ This creates a commented `config/application.yml` file and adds it to your
61
+ `.gitignore`. Add your own configuration to this file and you're done!
62
+
63
+ ### Example
64
+
65
+ Given the following configuration file:
66
+
67
+ ```yaml
68
+ # config/application.yml
69
+
70
+ pusher_app_id: "2954"
71
+ pusher_key: "7381a978f7dd7f9a1117"
72
+ pusher_secret: "abdc3b896a0ffb85d373"
73
+ ```
74
+
75
+ You can configure [Pusher](http://pusher.com) in an initializer:
76
+
77
+ ```ruby
78
+ # config/initializers/pusher.rb
79
+
80
+ Pusher.app_id = ENV["pusher_app_id"]
81
+ Pusher.key = ENV["pusher_key"]
82
+ Pusher.secret = ENV["pusher_secret"]
83
+ ```
84
+
85
+ **Please note:** `ENV` is a simple key/value store. All values will be converted
86
+ to strings. Deeply nested configuration structures are not possible.
87
+
88
+ ### Environment-Specific Configuration
89
+
90
+ Oftentimes, local configuration values change depending on Rails environment. In
91
+ such cases, you can add environment-specific values to your configuration file:
92
+
93
+ ```yaml
94
+ # config/application.yml
95
+
96
+ pusher_app_id: "2954"
97
+ pusher_key: "7381a978f7dd7f9a1117"
98
+ pusher_secret: "abdc3b896a0ffb85d373"
99
+
100
+ test:
101
+ pusher_app_id: "5112"
102
+ pusher_key: "ad69caf9a44dcac1fb28"
103
+ pusher_secret: "83ca7aa160fedaf3b350"
104
+ ```
105
+
106
+ You can also nullify configuration values for a specific environment:
107
+
108
+ ```yaml
109
+ # config/application.yml
110
+
111
+ google_analytics_key: "UA-35722661-5"
112
+
113
+ test:
114
+ google_analytics_key: ~
115
+ ```
116
+
117
+ ### Using `Figaro.env`
118
+
119
+ `Figaro.env` is a convenience that acts as a proxy to `ENV`.
120
+
121
+ In testing, it is sometimes more convenient to stub and unstub `Figaro.env` than
122
+ to set and reset `ENV`. Whether your application uses `ENV` or `Figaro.env` is
123
+ entirely a matter of personal preference.
124
+
125
+ ```yaml
126
+ # config/application.yml
127
+
128
+ stripe_api_key: "sk_live_dSqzdUq80sw9GWmuoI0qJ9rL"
129
+ ```
130
+
131
+ ```ruby
132
+ ENV["stripe_api_key"] # => "sk_live_dSqzdUq80sw9GWmuoI0qJ9rL"
133
+ ENV.key?("stripe_api_key") # => true
134
+ ENV["google_analytics_key"] # => nil
135
+ ENV.key?("google_analytics_key") # => false
136
+
137
+ Figaro.env.stripe_api_key # => "sk_live_dSqzdUq80sw9GWmuoI0qJ9rL"
138
+ Figaro.env.stripe_api_key? # => true
139
+ Figaro.env.google_analytics_key # => nil
140
+ Figaro.env.google_analytics_key? # => false
141
+ ```
142
+
143
+ ### Required Keys
144
+
145
+ If a particular configuration value is required but not set, it's appropriate to
146
+ raise an error. With Figaro, you can either raise these errors proactively or
147
+ lazily.
148
+
149
+ To proactively require configuration keys:
150
+
151
+ ```ruby
152
+ # config/initializers/figaro.rb
153
+
154
+ Figaro.require_keys("pusher_app_id", "pusher_key", "pusher_secret")
155
+ ```
156
+
157
+ If any of the configuration keys above are not set, your application will raise
158
+ an error during initialization. This method is preferred because it prevents
159
+ runtime errors in a production application due to improper configuration.
160
+
161
+ To require configuration keys lazily, reference the variables via "bang" methods
162
+ on `Figaro.env`:
163
+
164
+ ```ruby
165
+ # config/initializers/pusher.rb
166
+
167
+ Pusher.app_id = Figaro.env.pusher_app_id!
168
+ Pusher.key = Figaro.env.pusher_key!
169
+ Pusher.secret = Figaro.env.pusher_secret!
170
+ ```
171
+
172
+ ### Deployment
173
+
174
+ Figaro is written with deployment in mind. In fact, [Heroku](https://www.heroku.com)'s
175
+ use of `ENV` for application configuration was the original inspiration for
176
+ Figaro.
177
+
178
+ #### Heroku
179
+
180
+ Heroku already makes setting application configuration easy:
181
+
182
+ ```bash
183
+ $ heroku config:set google_analytics_key=UA-35722661-5
184
+ ```
185
+
186
+ Using the `figaro` command, you can set values from your configuration file all
187
+ at once:
188
+
189
+ ```bash
190
+ $ figaro heroku:set -e production
191
+ ```
192
+
193
+ For more information:
194
+
195
+ ```bash
196
+ $ figaro help heroku:set
197
+ ```
198
+
199
+ #### Other Hosts
200
+
201
+ If you're not deploying to Heroku, you have two options:
202
+
203
+ * Generate a remote configuration file
204
+ * Set `ENV` variables directly
205
+
206
+ Generating a remote configuration file is preferred because of:
207
+
208
+ * familiarity – Management of `config/application.yml` is like that of `config/database.yml`.
209
+ * isolation – Multiple applications on the same server will not produce configuration key collisions.
210
+
211
+ ## Is Figaro like [dotenv](https://github.com/bkeepers/dotenv)?
212
+
213
+ Yes. Kind of.
214
+
215
+ Figaro and dotenv were written around the same time to solve similar problems.
216
+
217
+ ### Similarities
218
+
219
+ * Both libraries are useful for Ruby application configuration.
220
+ * Both are popular and well maintained.
221
+ * Both are inspired by Twelve-Factor App's concept of proper [configuration](http://12factor.net/config).
222
+ * Both store configuration values in `ENV`.
223
+
224
+ ### Differences
225
+
226
+ * Configuration File
227
+ * Figaro expects a single file.
228
+ * Dotenv supports separate files for each environment.
229
+ * Configuration File Format
230
+ * Figaro expects YAML containing key/value pairs.
231
+ * Dotenv convention is a collection of `KEY=VALUE` pairs.
232
+ * Security vs. Convenience
233
+ * Figaro convention is to never commit configuration files.
234
+ * Dotenv encourages committing configuration files containing development values.
235
+ * Framework Focus
236
+ * Figaro was written with a focus on Rails development and conventions.
237
+ * Dotenv was written to accommodate any type of Ruby application.
238
+
239
+ Either library may suit your configuration needs. It often boils down to
240
+ personal preference.
241
+
242
+ ## 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)?
243
+
244
+ Yes. Kind of.
245
+
246
+ Rails 4.1 introduced the `secrets.yml` convention for Rails application
247
+ configuration. Figaro predated the Rails 4.1 release by two years.
248
+
249
+ ### Similarities
250
+
251
+ * Both are useful for Rails application configuration.
252
+ * Both are popular and well maintained.
253
+ * Both expect a single YAML file.
254
+
255
+ ### Differences
256
+
257
+ * Configuration Access
258
+ * Figaro stores configuration values in `ENV`.
259
+ * Rails stores configuration values in `Rails.application.secrets`.
260
+ * Configuration File Structure
261
+ * Figaro expects YAML containing key/value string pairs.
262
+ * Secrets may contain nested structures with rich objects.
263
+ * Security vs. Convenience
264
+ * Figaro convention is to never commit configuration files.
265
+ * Secrets are committed by default.
266
+ * Consistency
267
+ * Figaro uses `ENV` for configuration in every environment.
268
+ * Secrets encourage using `ENV` for production only.
269
+ * Approach
270
+ * Figaro is inspired by Twelve-Factor App's concept of proper [configuration](http://12factor.net/config).
271
+ * Secrets are… not.
272
+
273
+ The emergence of a configuration convention for Rails is an important step, but
274
+ as long as the last three differences above exist, Figaro will continue to be
275
+ developed as a more secure, more consistent, and more standards-compliant
276
+ alternative to `secrets.yml`.
277
+
278
+ 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.
279
+
280
+ ## How do I upgrade to Figaro 1.0?
281
+
282
+ In most cases, upgrading from Figaro 0.7 to 1.0 is painless. The format
283
+ expectations for `application.yml` are the same in 1.0 and values from
284
+ `application.yml` are loaded into `ENV` as they were in 0.7.
285
+
286
+ However, there are breaking changes:
287
+
288
+ ### `Figaro.env`
289
+
290
+ In Figaro 0.7, calling a method on the `Figaro.env` proxy would raise an error
291
+ if a corresponding key were not set in `ENV`.
292
+
293
+ In Figaro 1.0, calling a method on `Figaro.env` corresponding to an unset key
294
+ will return `nil`. To emulate the behavior of Figaro 0.7, use "bang" methods as
295
+ described in the [Required Keys](#required-keys) section.
296
+
297
+ **NOTE:** In Figaro 0.7, `Figaro.env` inherited from `Hash` but in Figaro 1.0,
298
+ hash access has been removed.
299
+
300
+ ### Heroku Configuration
301
+
302
+ In Figaro 0.7, a Rake task existed to set remote Heroku configuration according
303
+ to values in `application.yml`.
304
+
305
+ In Figaro 1.0, the Rake task was replaced by a command for the `figaro`
306
+ executable:
307
+
308
+ ```bash
309
+ $ figaro heroku:set -e production
310
+ ```
311
+
312
+ For more information:
313
+
314
+ ```bash
315
+ $ figaro help heroku:set
316
+ ```
317
+
318
+ **NOTE:** The environment option is required for the `heroku:set` command. The
319
+ Rake task in Figaro 0.7 used the default of "development" if unspecified.
320
+
321
+ ### Spring Configuration
322
+
323
+ If you're using Spring, either [stop](http://collectiveidea.com/blog/archives/2015/02/04/spring-is-dead-to-me)
324
+ or add `config/application.yml` to the watch list:
325
+
326
+ ```rb
327
+ # config/spring.rb
328
+
329
+ %w(
330
+ ...
331
+ config/application.yml
332
+ ).each { |path| Spring.watch(path) }
333
+ ```
334
+
335
+ ## Who wrote Figaro?
336
+
337
+ My name is Steve Richert and I wrote Figaro in March, 2012 with overwhelming
338
+ encouragement from my employer, [Collective Idea](http://www.collectiveidea.com).
339
+ Figaro has improved very much since then, thanks entirely to [inspiration](https://github.com/laserlemon/figaro/issues)
340
+ and [contribution](https://github.com/laserlemon/figaro/graphs/contributors)
341
+ from developers everywhere.
342
+
343
+ **Thank you!**
344
+
345
+ ## How can I help?
346
+
347
+ Figaro is open source and contributions from the community are encouraged! No
348
+ contribution is too small.
349
+
350
+ See Figaro's [contribution guidelines](CONTRIBUTING.md) for more information.