figaro 1.0.0.rc1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +3 -0
- data/.travis.yml +4 -5
- data/CHANGELOG.md +9 -1
- data/Gemfile +4 -4
- data/README.md +67 -7
- data/figaro.gemspec +3 -4
- data/gemfiles/rails30.gemfile +5 -4
- data/gemfiles/rails31.gemfile +4 -3
- data/gemfiles/rails32.gemfile +4 -3
- data/gemfiles/rails40.gemfile +4 -3
- data/gemfiles/rails41.gemfile +4 -3
- data/gemfiles/rails42.gemfile +12 -0
- data/lib/figaro.rb +1 -1
- data/lib/figaro/cli.rb +17 -2
- data/lib/figaro/cli/install.rb +32 -0
- data/lib/{generators/figaro/install/templates → figaro/cli/install}/application.yml +0 -0
- data/lib/figaro/cli/task.rb +6 -0
- data/lib/figaro/env.rb +1 -1
- data/lib/figaro/error.rb +6 -1
- data/spec/figaro/application_spec.rb +13 -17
- data/spec/figaro/cli/heroku_set_spec.rb +0 -4
- data/spec/figaro/cli/install_spec.rb +49 -0
- data/spec/figaro/env_spec.rb +3 -5
- data/spec/figaro/rails/application_spec.rb +5 -7
- data/spec/figaro_spec.rb +8 -10
- data/spec/rails_spec.rb +0 -16
- data/spec/spec_helper.rb +5 -6
- metadata +14 -33
- data/doc/title.png +0 -0
- data/lib/generators/figaro/install/install_generator.rb +0 -23
- data/spec/support/random.rb +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 04f2e8237250785bd14ebb3e634c2f7afea59cdf
|
4
|
+
data.tar.gz: 0478508fe6d204da9469b2d75f33c189b9a942a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 943e3f1d477a46a7d6b5a607db95880edda5bf4ba5b2c46776c9e48161ef31455b3a3c1e3bd723d7ff7b4c2515f90509c476b88f0edcd7d5c006349c8fcc6930
|
7
|
+
data.tar.gz: efeac0febe7dbee1495d5a2a9c8d667a3745be82c6b29242ac912cbc1a70f9a1f5190731304ec4f7b86a49d1b277f863457311133cef8d9f4edda247d9fad608
|
data/.rspec
ADDED
data/.travis.yml
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
before_install:
|
2
|
+
- gem update bundler rake
|
1
3
|
before_script:
|
2
4
|
- unset RAILS_ENV
|
3
5
|
- unset RACK_ENV
|
@@ -16,17 +18,14 @@ gemfile:
|
|
16
18
|
- gemfiles/rails32.gemfile
|
17
19
|
- gemfiles/rails40.gemfile
|
18
20
|
- gemfiles/rails41.gemfile
|
21
|
+
- gemfiles/rails42.gemfile
|
19
22
|
language: ruby
|
20
23
|
matrix:
|
21
24
|
allow_failures:
|
22
25
|
- rvm: ruby-head
|
23
|
-
include:
|
24
|
-
- gemfile: Gemfile
|
25
|
-
rvm: "2.1"
|
26
|
-
env: COVERAGE=1
|
27
26
|
rvm:
|
28
27
|
- 1.9.3
|
29
|
-
- 2.0
|
28
|
+
- "2.0"
|
30
29
|
- "2.1"
|
31
30
|
- ruby-head
|
32
31
|
script: bundle exec rspec
|
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,12 @@
|
|
1
|
-
## 1.0.0
|
1
|
+
## 1.0.0 / 2014-09-17
|
2
|
+
|
3
|
+
* [BUGFIX] Make calls to Heroku with a clean Bundler environment
|
4
|
+
* [ENHANCEMENT] Remove Rails as a runtime dependency
|
5
|
+
* [FEATURE] Replace the Rails generator with the `figaro install` task
|
6
|
+
* [ENHANCEMENT] Rename the `Figaro.require` method to `Figaro.require_keys`
|
7
|
+
* [ENHANCEMENT] Begin to test against Rails 4.2 (beta)
|
8
|
+
|
9
|
+
## 1.0.0.rc1 / 2014-04-17
|
2
10
|
|
3
11
|
* [FEATURE] Add bang and boolean methods to `Figaro.env`
|
4
12
|
* [ENHANCEMENT] Detach `Figaro.env` from the configuration file hash
|
data/Gemfile
CHANGED
@@ -2,11 +2,11 @@ source "https://rubygems.org"
|
|
2
2
|
|
3
3
|
gemspec
|
4
4
|
|
5
|
-
gem "rails", ">= 3.0.3", "<
|
5
|
+
gem "rails", ">= 3.0.3", "< 4.3"
|
6
6
|
|
7
7
|
group :test do
|
8
|
-
gem "aruba", "~> 0.
|
9
|
-
gem "codeclimate-test-reporter",
|
10
|
-
gem "rspec", "~>
|
8
|
+
gem "aruba", "~> 0.6.1"
|
9
|
+
gem "codeclimate-test-reporter", require: false
|
10
|
+
gem "rspec", "~> 3.1"
|
11
11
|
gem "sqlite3", "~> 1.3"
|
12
12
|
end
|
data/README.md
CHANGED
@@ -1,12 +1,14 @@
|
|
1
|
-
# ![Figaro](doc/title.png)
|
1
|
+
# ![Figaro](https://raw.githubusercontent.com/laserlemon/figaro/1f6e709/doc/title.png)
|
2
2
|
|
3
3
|
Simple, Heroku-friendly Rails app configuration using `ENV` and a single YAML file
|
4
4
|
|
5
|
-
[![
|
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)
|
5
|
+
[![Gem Version](https://img.shields.io/gem/v/figaro.svg?style=flat-square)](http://badge.fury.io/rb/figaro)
|
6
|
+
[![Build Status](https://img.shields.io/travis/laserlemon/figaro/master.svg?style=flat-square)](https://travis-ci.org/laserlemon/figaro)
|
7
|
+
[![Code Climate](https://img.shields.io/codeclimate/github/laserlemon/figaro.svg?style=flat-square)](https://codeclimate.com/github/laserlemon/figaro)
|
8
|
+
[![Coverage Status](https://img.shields.io/codeclimate/coverage/github/laserlemon/figaro.svg?style=flat-square)](https://codeclimate.com/github/laserlemon/figaro)
|
9
|
+
[![Dependency Status](https://img.shields.io/gemnasium/laserlemon/figaro.svg?style=flat-square)](https://gemnasium.com/laserlemon/figaro)
|
10
|
+
|
11
|
+
**NOTE:** If you're using Figaro 0.7 or prior, please refer to the [appropriate documentation](https://github.com/laserlemon/figaro/tree/0-stable#readme) or [upgrade](#how-do-i-upgrade-to-figaro-10) to Figaro 1.0.
|
10
12
|
|
11
13
|
## Why does Figaro exist?
|
12
14
|
|
@@ -24,6 +26,23 @@ This is straightforward in production environments but local development environ
|
|
24
26
|
|
25
27
|
Figaro parses a Git-ignored YAML file in your application and loads its values into `ENV`.
|
26
28
|
|
29
|
+
### Getting Started
|
30
|
+
|
31
|
+
Add Figaro to your Gemfile and `bundle install`:
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
gem "figaro"
|
35
|
+
```
|
36
|
+
|
37
|
+
Figaro installation is easy:
|
38
|
+
|
39
|
+
|
40
|
+
```bash
|
41
|
+
$ figaro install
|
42
|
+
```
|
43
|
+
|
44
|
+
This creates a commented `config/application.yml` file and adds it to your `.gitignore`. Add your own configuration to this file and you're done!
|
45
|
+
|
27
46
|
### Example
|
28
47
|
|
29
48
|
Given the following configuration file:
|
@@ -109,7 +128,7 @@ To proactively require configuration keys:
|
|
109
128
|
```ruby
|
110
129
|
# config/initializers/figaro.rb
|
111
130
|
|
112
|
-
Figaro.
|
131
|
+
Figaro.require_keys("pusher_app_id", "pusher_key", "pusher_secret")
|
113
132
|
```
|
114
133
|
|
115
134
|
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.
|
@@ -224,6 +243,47 @@ The emergence of a configuration convention for Rails is an important step, but
|
|
224
243
|
|
225
244
|
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.
|
226
245
|
|
246
|
+
## How do I upgrade to Figaro 1.0?
|
247
|
+
|
248
|
+
In most cases, upgrading from Figaro 0.7 to 1.0 is painless. The format
|
249
|
+
expectations for `application.yml` are the same in 1.0 and values from
|
250
|
+
`application.yml` are loaded into `ENV` as they were in 0.7.
|
251
|
+
|
252
|
+
However, there are breaking changes:
|
253
|
+
|
254
|
+
### `Figaro.env`
|
255
|
+
|
256
|
+
In Figaro 0.7, calling a method on the `Figaro.env` proxy would raise an error
|
257
|
+
if a corresponding key were not set in `ENV`.
|
258
|
+
|
259
|
+
In Figaro 1.0, calling a method on `Figaro.env` corresponding to an unset key
|
260
|
+
will return `nil`. To emulate the behavior of Figaro 0.7, use "bang" methods as
|
261
|
+
described in the [Required Keys](#required-keys) section.
|
262
|
+
|
263
|
+
**NOTE:** In Figaro 0.7, `Figaro.env` inherited from `Hash` but in Figaro 1.0,
|
264
|
+
hash access has been removed.
|
265
|
+
|
266
|
+
### Heroku Configuration
|
267
|
+
|
268
|
+
In Figaro 0.7, a Rake task existed to set remote Heroku configuration according
|
269
|
+
to values in `application.yml`.
|
270
|
+
|
271
|
+
In Figaro 1.0, the Rake task was replaced by a command for the `figaro`
|
272
|
+
executable:
|
273
|
+
|
274
|
+
```bash
|
275
|
+
$ figaro heroku:set -e production
|
276
|
+
```
|
277
|
+
|
278
|
+
For more information:
|
279
|
+
|
280
|
+
```bash
|
281
|
+
$ figaro help heroku:set
|
282
|
+
```
|
283
|
+
|
284
|
+
**NOTE:** The environment option is required for the `heroku:set` command. The
|
285
|
+
Rake task in Figaro 0.7 used the default of "development" if unspecified.
|
286
|
+
|
227
287
|
## Who wrote Figaro?
|
228
288
|
|
229
289
|
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.
|
data/figaro.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |gem|
|
4
4
|
gem.name = "figaro"
|
5
|
-
gem.version = "1.0.0
|
5
|
+
gem.version = "1.0.0"
|
6
6
|
|
7
7
|
gem.author = "Steve Richert"
|
8
8
|
gem.email = "steve.richert@gmail.com"
|
@@ -11,11 +11,10 @@ Gem::Specification.new do |gem|
|
|
11
11
|
gem.homepage = "https://github.com/laserlemon/figaro"
|
12
12
|
gem.license = "MIT"
|
13
13
|
|
14
|
-
gem.add_dependency "rails", ">= 3", "< 5"
|
15
14
|
gem.add_dependency "thor", "~> 0.14"
|
16
15
|
|
17
|
-
gem.add_development_dependency "bundler", "~> 1.
|
18
|
-
gem.add_development_dependency "rake", "~> 10.
|
16
|
+
gem.add_development_dependency "bundler", "~> 1.7"
|
17
|
+
gem.add_development_dependency "rake", "~> 10.3"
|
19
18
|
|
20
19
|
gem.files = `git ls-files`.split($\)
|
21
20
|
gem.test_files = gem.files.grep(/^spec/)
|
data/gemfiles/rails30.gemfile
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
source "https://rubygems.org"
|
2
2
|
|
3
|
-
gemspec path: "
|
3
|
+
gemspec path: ".."
|
4
4
|
|
5
|
-
gem "rails", "~> 3.0.
|
5
|
+
gem "rails", "~> 3.0.3"
|
6
6
|
|
7
7
|
group :test do
|
8
|
-
gem "aruba", "~> 0.
|
9
|
-
gem "
|
8
|
+
gem "aruba", "~> 0.6.1"
|
9
|
+
gem "codeclimate-test-reporter", require: false
|
10
|
+
gem "rspec", "~> 3.1"
|
10
11
|
gem "sqlite3", "~> 1.3"
|
11
12
|
end
|
data/gemfiles/rails31.gemfile
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
source "https://rubygems.org"
|
2
2
|
|
3
|
-
gemspec path: "
|
3
|
+
gemspec path: ".."
|
4
4
|
|
5
5
|
gem "rails", "~> 3.1.0"
|
6
6
|
|
7
7
|
group :test do
|
8
|
-
gem "aruba", "~> 0.
|
9
|
-
gem "
|
8
|
+
gem "aruba", "~> 0.6.1"
|
9
|
+
gem "codeclimate-test-reporter", require: false
|
10
|
+
gem "rspec", "~> 3.1"
|
10
11
|
gem "sqlite3", "~> 1.3"
|
11
12
|
end
|
data/gemfiles/rails32.gemfile
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
source "https://rubygems.org"
|
2
2
|
|
3
|
-
gemspec path: "
|
3
|
+
gemspec path: ".."
|
4
4
|
|
5
5
|
gem "rails", "~> 3.2.0"
|
6
6
|
|
7
7
|
group :test do
|
8
|
-
gem "aruba", "~> 0.
|
9
|
-
gem "
|
8
|
+
gem "aruba", "~> 0.6.1"
|
9
|
+
gem "codeclimate-test-reporter", require: false
|
10
|
+
gem "rspec", "~> 3.1"
|
10
11
|
gem "sqlite3", "~> 1.3"
|
11
12
|
end
|
data/gemfiles/rails40.gemfile
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
source "https://rubygems.org"
|
2
2
|
|
3
|
-
gemspec path: "
|
3
|
+
gemspec path: ".."
|
4
4
|
|
5
5
|
gem "rails", "~> 4.0.0"
|
6
6
|
|
7
7
|
group :test do
|
8
|
-
gem "aruba", "~> 0.
|
9
|
-
gem "
|
8
|
+
gem "aruba", "~> 0.6.1"
|
9
|
+
gem "codeclimate-test-reporter", require: false
|
10
|
+
gem "rspec", "~> 3.1"
|
10
11
|
gem "sqlite3", "~> 1.3"
|
11
12
|
end
|
data/gemfiles/rails41.gemfile
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
source "https://rubygems.org"
|
2
2
|
|
3
|
-
gemspec path: "
|
3
|
+
gemspec path: ".."
|
4
4
|
|
5
5
|
gem "rails", "~> 4.1.0"
|
6
6
|
|
7
7
|
group :test do
|
8
|
-
gem "aruba", "~> 0.
|
9
|
-
gem "
|
8
|
+
gem "aruba", "~> 0.6.1"
|
9
|
+
gem "codeclimate-test-reporter", require: false
|
10
|
+
gem "rspec", "~> 3.1"
|
10
11
|
gem "sqlite3", "~> 1.3"
|
11
12
|
end
|
data/lib/figaro.rb
CHANGED
data/lib/figaro/cli.rb
CHANGED
@@ -1,9 +1,23 @@
|
|
1
1
|
require "thor"
|
2
2
|
|
3
|
-
require "figaro/cli/heroku_set"
|
4
|
-
|
5
3
|
module Figaro
|
6
4
|
class CLI < Thor
|
5
|
+
# figaro install
|
6
|
+
|
7
|
+
desc "install", "Install Figaro"
|
8
|
+
|
9
|
+
method_option "path",
|
10
|
+
aliases: ["-p"],
|
11
|
+
default: "config/application.yml",
|
12
|
+
desc: "Specify a configuration file path"
|
13
|
+
|
14
|
+
def install
|
15
|
+
require "figaro/cli/install"
|
16
|
+
Install.start
|
17
|
+
end
|
18
|
+
|
19
|
+
# figaro heroku:set
|
20
|
+
|
7
21
|
desc "heroku:set", "Send Figaro configuration to Heroku"
|
8
22
|
|
9
23
|
method_option "app",
|
@@ -18,6 +32,7 @@ module Figaro
|
|
18
32
|
desc: "Specify a configuration file path"
|
19
33
|
|
20
34
|
define_method "heroku:set" do
|
35
|
+
require "figaro/cli/heroku_set"
|
21
36
|
HerokuSet.run(options)
|
22
37
|
end
|
23
38
|
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require "thor/group"
|
2
|
+
|
3
|
+
module Figaro
|
4
|
+
class CLI < Thor
|
5
|
+
class Install < Thor::Group
|
6
|
+
include Thor::Actions
|
7
|
+
|
8
|
+
class_option "path",
|
9
|
+
aliases: ["-p"],
|
10
|
+
default: "config/application.yml",
|
11
|
+
desc: "Specify a configuration file path"
|
12
|
+
|
13
|
+
def self.source_root
|
14
|
+
File.expand_path("../install", __FILE__)
|
15
|
+
end
|
16
|
+
|
17
|
+
def create_configuration
|
18
|
+
copy_file("application.yml", options[:path])
|
19
|
+
end
|
20
|
+
|
21
|
+
def ignore_configuration
|
22
|
+
if File.exists?(".gitignore")
|
23
|
+
append_to_file(".gitignore", <<-EOF)
|
24
|
+
|
25
|
+
# Ignore application configuration
|
26
|
+
/#{options[:path]}
|
27
|
+
EOF
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
File without changes
|
data/lib/figaro/cli/task.rb
CHANGED
data/lib/figaro/env.rb
CHANGED
data/lib/figaro/error.rb
CHANGED
@@ -2,7 +2,12 @@ module Figaro
|
|
2
2
|
class Error < StandardError; end
|
3
3
|
|
4
4
|
class RailsNotInitialized < Error; end
|
5
|
-
|
5
|
+
|
6
|
+
class MissingKey < Error
|
7
|
+
def initialize(key)
|
8
|
+
super("Missing required configuration key: #{key.inspect}")
|
9
|
+
end
|
10
|
+
end
|
6
11
|
|
7
12
|
class MissingKeys < Error
|
8
13
|
def initialize(keys)
|
@@ -1,14 +1,10 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
1
|
require "tempfile"
|
4
2
|
|
5
3
|
module Figaro
|
6
4
|
describe Application do
|
7
5
|
before do
|
8
|
-
Application.
|
9
|
-
|
10
|
-
default_environment: "development"
|
11
|
-
)
|
6
|
+
allow_any_instance_of(Application).to receive(:default_path) { "/path/to/app/config/application.yml" }
|
7
|
+
allow_any_instance_of(Application).to receive(:default_environment) { "development" }
|
12
8
|
end
|
13
9
|
|
14
10
|
describe "#path" do
|
@@ -42,7 +38,7 @@ module Figaro
|
|
42
38
|
application = Application.new
|
43
39
|
|
44
40
|
expect {
|
45
|
-
application.
|
41
|
+
allow(application).to receive(:default_path) { "/app/env.yml" }
|
46
42
|
}.to change {
|
47
43
|
application.path
|
48
44
|
}.from("/path/to/app/config/application.yml").to("/app/env.yml")
|
@@ -86,7 +82,7 @@ module Figaro
|
|
86
82
|
application = Application.new
|
87
83
|
|
88
84
|
expect {
|
89
|
-
application.
|
85
|
+
allow(application).to receive(:default_environment) { "test" }
|
90
86
|
}.to change {
|
91
87
|
application.environment
|
92
88
|
}.from("development").to("test")
|
@@ -164,10 +160,10 @@ YAML
|
|
164
160
|
path_2 = yaml_to_path("foo: baz")
|
165
161
|
|
166
162
|
application = Application.new
|
167
|
-
application.
|
163
|
+
allow(application).to receive(:default_path) { path_1 }
|
168
164
|
|
169
165
|
expect {
|
170
|
-
application.
|
166
|
+
allow(application).to receive(:default_path) { path_2 }
|
171
167
|
}.to change {
|
172
168
|
application.configuration
|
173
169
|
}.from("foo" => "bar").to("foo" => "baz")
|
@@ -179,10 +175,10 @@ foo: bar
|
|
179
175
|
test:
|
180
176
|
foo: baz
|
181
177
|
YAML
|
182
|
-
application.
|
178
|
+
allow(application).to receive(:default_environment) { "development" }
|
183
179
|
|
184
180
|
expect {
|
185
|
-
application.
|
181
|
+
allow(application).to receive(:default_environment) { "test" }
|
186
182
|
}.to change {
|
187
183
|
application.configuration
|
188
184
|
}.from("foo" => "bar").to("foo" => "baz")
|
@@ -193,7 +189,7 @@ YAML
|
|
193
189
|
let!(:application) { Application.new }
|
194
190
|
|
195
191
|
before do
|
196
|
-
application.
|
192
|
+
allow(application).to receive(:configuration) { { "foo" => "bar" } }
|
197
193
|
end
|
198
194
|
|
199
195
|
it "merges values into ENV" do
|
@@ -219,7 +215,7 @@ YAML
|
|
219
215
|
it "sets keys that have already been set internally" do
|
220
216
|
application.load
|
221
217
|
|
222
|
-
application.
|
218
|
+
allow(application).to receive(:configuration) { { "foo" => "baz" } }
|
223
219
|
|
224
220
|
expect {
|
225
221
|
application.load
|
@@ -229,7 +225,7 @@ YAML
|
|
229
225
|
end
|
230
226
|
|
231
227
|
it "warns when a key isn't a string" do
|
232
|
-
application.
|
228
|
+
allow(application).to receive(:configuration) { { foo: "bar" } }
|
233
229
|
|
234
230
|
expect(application).to receive(:warn)
|
235
231
|
|
@@ -237,7 +233,7 @@ YAML
|
|
237
233
|
end
|
238
234
|
|
239
235
|
it "warns when a value isn't a string" do
|
240
|
-
application.
|
236
|
+
allow(application).to receive(:configuration) { { "foo" => ["bar"] } }
|
241
237
|
|
242
238
|
expect(application).to receive(:warn)
|
243
239
|
|
@@ -245,7 +241,7 @@ YAML
|
|
245
241
|
end
|
246
242
|
|
247
243
|
it "allows nil values" do
|
248
|
-
application.
|
244
|
+
allow(application).to receive(:configuration) { { "foo" => nil } }
|
249
245
|
|
250
246
|
expect {
|
251
247
|
application.load
|
@@ -0,0 +1,49 @@
|
|
1
|
+
describe "figaro install" do
|
2
|
+
before do
|
3
|
+
create_dir("example")
|
4
|
+
cd("example")
|
5
|
+
end
|
6
|
+
|
7
|
+
it "creates a configuration file" do
|
8
|
+
run_simple("figaro install")
|
9
|
+
|
10
|
+
check_file_presence(["config/application.yml"], true)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "respects path" do
|
14
|
+
run_simple("figaro install -p env.yml")
|
15
|
+
|
16
|
+
check_file_presence(["env.yml"], true)
|
17
|
+
end
|
18
|
+
|
19
|
+
context "with a .gitignore file" do
|
20
|
+
before do
|
21
|
+
write_file(".gitignore", <<-EOF)
|
22
|
+
/foo
|
23
|
+
/bar
|
24
|
+
EOF
|
25
|
+
end
|
26
|
+
|
27
|
+
it "Git-ignores the configuration file if applicable" do
|
28
|
+
run_simple("figaro install")
|
29
|
+
|
30
|
+
check_file_content(".gitignore", %r(^/foo$), true)
|
31
|
+
check_file_content(".gitignore", %r(^/bar$), true)
|
32
|
+
check_file_content(".gitignore", %r(^/config/application\.yml$), true)
|
33
|
+
end
|
34
|
+
|
35
|
+
it "respects path" do
|
36
|
+
run_simple("figaro install -p env.yml")
|
37
|
+
|
38
|
+
check_file_content(".gitignore", %r(^/env\.yml$), true)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
context "without a .gitignore file" do
|
43
|
+
it "doesn't generate a new .gitignore file" do
|
44
|
+
run_simple("figaro install")
|
45
|
+
|
46
|
+
check_file_presence([".gitignore"], false)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
data/spec/figaro/env_spec.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
1
|
describe Figaro::ENV do
|
4
2
|
subject(:env) { Figaro::ENV }
|
5
3
|
|
@@ -30,7 +28,7 @@ describe Figaro::ENV do
|
|
30
28
|
end
|
31
29
|
|
32
30
|
it "respects a stubbed plain method" do
|
33
|
-
env.
|
31
|
+
allow(env).to receive(:bar) { "baz" }
|
34
32
|
expect(env.bar).to eq("baz")
|
35
33
|
end
|
36
34
|
end
|
@@ -56,7 +54,7 @@ describe Figaro::ENV do
|
|
56
54
|
end
|
57
55
|
|
58
56
|
it "respects a stubbed plain method" do
|
59
|
-
env.
|
57
|
+
allow(env).to receive(:bar) { "baz" }
|
60
58
|
expect { expect(env.bar!).to eq("baz") }.not_to raise_error
|
61
59
|
end
|
62
60
|
end
|
@@ -82,7 +80,7 @@ describe Figaro::ENV do
|
|
82
80
|
end
|
83
81
|
|
84
82
|
it "respects a stubbed plain method" do
|
85
|
-
env.
|
83
|
+
allow(env).to receive(:bar) { "baz" }
|
86
84
|
expect(env.bar?).to eq(true)
|
87
85
|
end
|
88
86
|
end
|
@@ -1,5 +1,3 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
1
|
module Figaro
|
4
2
|
module Rails
|
5
3
|
describe Application do
|
@@ -7,17 +5,17 @@ module Figaro
|
|
7
5
|
let!(:application) { Application.new }
|
8
6
|
|
9
7
|
it "defaults to config/application.yml in Rails.root" do
|
10
|
-
::Rails.
|
8
|
+
allow(::Rails).to receive(:root) { Pathname.new("/path/to/app") }
|
11
9
|
|
12
10
|
expect {
|
13
|
-
::Rails.
|
11
|
+
allow(::Rails).to receive(:root) { Pathname.new("/app") }
|
14
12
|
}.to change {
|
15
13
|
application.send(:default_path).to_s
|
16
14
|
}.from("/path/to/app/config/application.yml").to("/app/config/application.yml")
|
17
15
|
end
|
18
16
|
|
19
17
|
it "raises an error when Rails.root isn't set yet" do
|
20
|
-
::Rails.
|
18
|
+
allow(::Rails).to receive(:root) { nil }
|
21
19
|
|
22
20
|
expect {
|
23
21
|
application.send(:default_path)
|
@@ -29,10 +27,10 @@ module Figaro
|
|
29
27
|
let!(:application) { Application.new }
|
30
28
|
|
31
29
|
it "defaults to Rails.env" do
|
32
|
-
::Rails.
|
30
|
+
allow(::Rails).to receive(:env) { "development" }
|
33
31
|
|
34
32
|
expect {
|
35
|
-
::Rails.
|
33
|
+
allow(::Rails).to receive(:env) { "test" }
|
36
34
|
}.to change {
|
37
35
|
application.send(:default_environment).to_s
|
38
36
|
}.from("development").to("test")
|
data/spec/figaro_spec.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
1
|
describe Figaro do
|
4
2
|
describe ".env" do
|
5
3
|
it "falls through to Figaro::ENV" do
|
@@ -29,8 +27,8 @@ describe Figaro do
|
|
29
27
|
let(:custom_application) { double(:custom_application) }
|
30
28
|
|
31
29
|
before do
|
32
|
-
Figaro.
|
33
|
-
adapter.
|
30
|
+
allow(Figaro).to receive(:adapter) { adapter }
|
31
|
+
allow(adapter).to receive(:new).with(no_args) { application }
|
34
32
|
end
|
35
33
|
|
36
34
|
it "defaults to a new adapter application" do
|
@@ -50,7 +48,7 @@ describe Figaro do
|
|
50
48
|
let(:application) { double(:application) }
|
51
49
|
|
52
50
|
before do
|
53
|
-
Figaro.
|
51
|
+
allow(Figaro).to receive(:application) { application }
|
54
52
|
end
|
55
53
|
|
56
54
|
it "loads the application configuration" do
|
@@ -60,7 +58,7 @@ describe Figaro do
|
|
60
58
|
end
|
61
59
|
end
|
62
60
|
|
63
|
-
describe ".
|
61
|
+
describe ".require_keys" do
|
64
62
|
before do
|
65
63
|
::ENV["foo"] = "bar"
|
66
64
|
::ENV["hello"] = "world"
|
@@ -69,13 +67,13 @@ describe Figaro do
|
|
69
67
|
context "when no keys are missing" do
|
70
68
|
it "does nothing" do
|
71
69
|
expect {
|
72
|
-
Figaro.
|
70
|
+
Figaro.require_keys("foo", "hello")
|
73
71
|
}.not_to raise_error
|
74
72
|
end
|
75
73
|
|
76
74
|
it "accepts an array" do
|
77
75
|
expect {
|
78
|
-
Figaro.
|
76
|
+
Figaro.require_keys(["foo", "hello"])
|
79
77
|
}.not_to raise_error
|
80
78
|
end
|
81
79
|
end
|
@@ -83,7 +81,7 @@ describe Figaro do
|
|
83
81
|
context "when keys are missing" do
|
84
82
|
it "raises an error for the missing keys" do
|
85
83
|
expect {
|
86
|
-
Figaro.
|
84
|
+
Figaro.require_keys("foo", "goodbye", "baz")
|
87
85
|
}.to raise_error(Figaro::MissingKeys) { |error|
|
88
86
|
expect(error.message).not_to include("foo")
|
89
87
|
expect(error.message).to include("goodbye")
|
@@ -93,7 +91,7 @@ describe Figaro do
|
|
93
91
|
|
94
92
|
it "accepts an array" do
|
95
93
|
expect {
|
96
|
-
Figaro.
|
94
|
+
Figaro.require_keys(["foo", "goodbye", "baz"])
|
97
95
|
}.to raise_error(Figaro::MissingKeys)
|
98
96
|
end
|
99
97
|
end
|
data/spec/rails_spec.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
1
|
describe Figaro::Rails do
|
4
2
|
before do
|
5
3
|
run_simple(<<-CMD)
|
@@ -49,18 +47,4 @@ EOL
|
|
49
47
|
assert_partial_output("bar", all_stdout)
|
50
48
|
end
|
51
49
|
end
|
52
|
-
|
53
|
-
describe "rails generate figaro:install" do
|
54
|
-
it "generates application.yml" do
|
55
|
-
run_simple("rails generate figaro:install")
|
56
|
-
|
57
|
-
check_file_presence(["config/application.yml"], true)
|
58
|
-
end
|
59
|
-
|
60
|
-
it "ignores application.yml" do
|
61
|
-
run_simple("rails generate figaro:install")
|
62
|
-
|
63
|
-
check_file_content(".gitignore", %r(^/config/application\.yml$), true)
|
64
|
-
end
|
65
|
-
end
|
66
50
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,14 +1,13 @@
|
|
1
|
-
|
1
|
+
require "bundler"
|
2
|
+
Bundler.setup
|
3
|
+
|
4
|
+
if ENV["CODECLIMATE_REPO_TOKEN"]
|
2
5
|
require "codeclimate-test-reporter"
|
3
6
|
CodeClimate::TestReporter.start
|
4
7
|
end
|
5
8
|
|
6
9
|
require "figaro"
|
7
10
|
|
8
|
-
require "bundler"
|
9
11
|
Bundler.require(:test)
|
10
12
|
|
11
|
-
require
|
12
|
-
ROOT = Pathname.new(File.expand_path("../..", __FILE__))
|
13
|
-
|
14
|
-
Dir[ROOT.join("spec/support/**/*.rb")].each { |f| require f }
|
13
|
+
Dir[File.expand_path("../support/*.rb", __FILE__)].each { |f| require f }
|
metadata
CHANGED
@@ -1,35 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: figaro
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steve Richert
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-09-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: rails
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '3'
|
20
|
-
- - "<"
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version: '5'
|
23
|
-
type: :runtime
|
24
|
-
prerelease: false
|
25
|
-
version_requirements: !ruby/object:Gem::Requirement
|
26
|
-
requirements:
|
27
|
-
- - ">="
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: '3'
|
30
|
-
- - "<"
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
version: '5'
|
33
13
|
- !ruby/object:Gem::Dependency
|
34
14
|
name: thor
|
35
15
|
requirement: !ruby/object:Gem::Requirement
|
@@ -50,28 +30,28 @@ dependencies:
|
|
50
30
|
requirements:
|
51
31
|
- - "~>"
|
52
32
|
- !ruby/object:Gem::Version
|
53
|
-
version: '1.
|
33
|
+
version: '1.7'
|
54
34
|
type: :development
|
55
35
|
prerelease: false
|
56
36
|
version_requirements: !ruby/object:Gem::Requirement
|
57
37
|
requirements:
|
58
38
|
- - "~>"
|
59
39
|
- !ruby/object:Gem::Version
|
60
|
-
version: '1.
|
40
|
+
version: '1.7'
|
61
41
|
- !ruby/object:Gem::Dependency
|
62
42
|
name: rake
|
63
43
|
requirement: !ruby/object:Gem::Requirement
|
64
44
|
requirements:
|
65
45
|
- - "~>"
|
66
46
|
- !ruby/object:Gem::Version
|
67
|
-
version: '10.
|
47
|
+
version: '10.3'
|
68
48
|
type: :development
|
69
49
|
prerelease: false
|
70
50
|
version_requirements: !ruby/object:Gem::Requirement
|
71
51
|
requirements:
|
72
52
|
- - "~>"
|
73
53
|
- !ruby/object:Gem::Version
|
74
|
-
version: '10.
|
54
|
+
version: '10.3'
|
75
55
|
description: Simple, Heroku-friendly Rails app configuration using ENV and a single
|
76
56
|
YAML file
|
77
57
|
email: steve.richert@gmail.com
|
@@ -81,6 +61,7 @@ extensions: []
|
|
81
61
|
extra_rdoc_files: []
|
82
62
|
files:
|
83
63
|
- ".gitignore"
|
64
|
+
- ".rspec"
|
84
65
|
- ".travis.yml"
|
85
66
|
- CHANGELOG.md
|
86
67
|
- CONTRIBUTING.md
|
@@ -89,17 +70,19 @@ files:
|
|
89
70
|
- README.md
|
90
71
|
- Rakefile
|
91
72
|
- bin/figaro
|
92
|
-
- doc/title.png
|
93
73
|
- figaro.gemspec
|
94
74
|
- gemfiles/rails30.gemfile
|
95
75
|
- gemfiles/rails31.gemfile
|
96
76
|
- gemfiles/rails32.gemfile
|
97
77
|
- gemfiles/rails40.gemfile
|
98
78
|
- gemfiles/rails41.gemfile
|
79
|
+
- gemfiles/rails42.gemfile
|
99
80
|
- lib/figaro.rb
|
100
81
|
- lib/figaro/application.rb
|
101
82
|
- lib/figaro/cli.rb
|
102
83
|
- lib/figaro/cli/heroku_set.rb
|
84
|
+
- lib/figaro/cli/install.rb
|
85
|
+
- lib/figaro/cli/install/application.yml
|
103
86
|
- lib/figaro/cli/task.rb
|
104
87
|
- lib/figaro/env.rb
|
105
88
|
- lib/figaro/error.rb
|
@@ -107,10 +90,9 @@ files:
|
|
107
90
|
- lib/figaro/rails/application.rb
|
108
91
|
- lib/figaro/rails/railtie.rb
|
109
92
|
- lib/figaro/rails/tasks.rake
|
110
|
-
- lib/generators/figaro/install/install_generator.rb
|
111
|
-
- lib/generators/figaro/install/templates/application.yml
|
112
93
|
- spec/figaro/application_spec.rb
|
113
94
|
- spec/figaro/cli/heroku_set_spec.rb
|
95
|
+
- spec/figaro/cli/install_spec.rb
|
114
96
|
- spec/figaro/env_spec.rb
|
115
97
|
- spec/figaro/rails/application_spec.rb
|
116
98
|
- spec/figaro_spec.rb
|
@@ -120,7 +102,6 @@ files:
|
|
120
102
|
- spec/support/bin/heroku
|
121
103
|
- spec/support/command_helpers.rb
|
122
104
|
- spec/support/command_interceptor.rb
|
123
|
-
- spec/support/random.rb
|
124
105
|
- spec/support/reset.rb
|
125
106
|
homepage: https://github.com/laserlemon/figaro
|
126
107
|
licenses:
|
@@ -137,9 +118,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
137
118
|
version: '0'
|
138
119
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
139
120
|
requirements:
|
140
|
-
- - "
|
121
|
+
- - ">="
|
141
122
|
- !ruby/object:Gem::Version
|
142
|
-
version:
|
123
|
+
version: '0'
|
143
124
|
requirements: []
|
144
125
|
rubyforge_project:
|
145
126
|
rubygems_version: 2.2.2
|
@@ -149,6 +130,7 @@ summary: Simple Rails app configuration
|
|
149
130
|
test_files:
|
150
131
|
- spec/figaro/application_spec.rb
|
151
132
|
- spec/figaro/cli/heroku_set_spec.rb
|
133
|
+
- spec/figaro/cli/install_spec.rb
|
152
134
|
- spec/figaro/env_spec.rb
|
153
135
|
- spec/figaro/rails/application_spec.rb
|
154
136
|
- spec/figaro_spec.rb
|
@@ -158,5 +140,4 @@ test_files:
|
|
158
140
|
- spec/support/bin/heroku
|
159
141
|
- spec/support/command_helpers.rb
|
160
142
|
- spec/support/command_interceptor.rb
|
161
|
-
- spec/support/random.rb
|
162
143
|
- spec/support/reset.rb
|
data/doc/title.png
DELETED
Binary file
|
@@ -1,23 +0,0 @@
|
|
1
|
-
module Figaro
|
2
|
-
module Generators
|
3
|
-
class InstallGenerator < ::Rails::Generators::Base
|
4
|
-
source_root File.expand_path("../templates", __FILE__)
|
5
|
-
|
6
|
-
def create_configuration
|
7
|
-
copy_file("application.yml", "config/application.yml")
|
8
|
-
end
|
9
|
-
|
10
|
-
def ignore_configuration
|
11
|
-
if File.exists?(".gitignore")
|
12
|
-
append_to_file(".gitignore") do
|
13
|
-
<<-EOF.strip_heredoc
|
14
|
-
|
15
|
-
# Ignore application configuration
|
16
|
-
/config/application.yml
|
17
|
-
EOF
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
data/spec/support/random.rb
DELETED