figaro 0.6.3 → 0.6.4
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.
- checksums.yaml +8 -8
- data/README.md +3 -3
- data/figaro.gemspec +3 -3
- data/lib/figaro.rb +1 -1
- data/lib/figaro/env.rb +4 -3
- data/spec/figaro/env_spec.rb +49 -7
- metadata +4 -5
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NjQzMmQ3NWI4M2ExYWE0OTc2MGY3NDY1YTQ0MDlmNDM5ZWEzOTI1Mw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZWRlNjM4ZjViMGExMGE1ODkyOWI1M2Y0YTAxNWVkNGYwMGViY2UxMw==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NThjYmVmYTZjM2YzNTNiZWI1MmI4ZTMxZTBlZWZhMTA3M2UwYjc2MWIxNjlj
|
10
|
+
Y2YxZjFlY2ZkM2ZjNzY3ZjQ4MTQyMTUzMDRhY2Q0OTE2MDY5NmQ2ODg1ZmM1
|
11
|
+
MWQ4NTc4NzFiMTkwMmEzMmQ4OWU2YjgzMzVjNTUzMDIwOWZiYmQ=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZTU0NDQ3YmMwYjY4NWFkMzgwMzJjZjNhZWE3MmQxZWIwNDExYWQyM2RmOTVm
|
14
|
+
ZDA0NmJkYjY5NWM5Y2QwZTRmOTU5NWI4ZjVmZTUwOTQ3ZjBmZTU1ZTA2OGIz
|
15
|
+
NzA2MWRkNWU4ZmZjMzMwOTc4NTVhYWQzMDBjZDYyMzA4MmQwZTU=
|
data/README.md
CHANGED
@@ -25,19 +25,19 @@ As an added bonus, this is exactly how apps on [Heroku](http://www.heroku.com/)
|
|
25
25
|
|
26
26
|
## Give me an example.
|
27
27
|
|
28
|
-
Okay. Add Figaro to your bundle:
|
28
|
+
Okay. Add Figaro to your Gemfile and run the `bundle` command to install it:
|
29
29
|
|
30
30
|
```ruby
|
31
31
|
gem "figaro"
|
32
32
|
```
|
33
33
|
|
34
|
-
Next up,
|
34
|
+
Next up, use the generator provided by Figaro:
|
35
35
|
|
36
36
|
```bash
|
37
37
|
rails generate figaro:install
|
38
38
|
```
|
39
39
|
|
40
|
-
This
|
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!
|
41
41
|
|
42
42
|
Your configuration will be available as key/value pairs in `ENV`. For example, here's `config/initializers/pusher.rb`:
|
43
43
|
|
data/figaro.gemspec
CHANGED
@@ -2,10 +2,10 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |gem|
|
4
4
|
gem.name = "figaro"
|
5
|
-
gem.version = "0.6.
|
5
|
+
gem.version = "0.6.4"
|
6
6
|
|
7
|
-
gem.
|
8
|
-
gem.email =
|
7
|
+
gem.author = "Steve Richert"
|
8
|
+
gem.email = "steve.richert@gmail.com"
|
9
9
|
gem.summary = "Simple Rails app configuration"
|
10
10
|
gem.description = "Simple, Heroku-friendly Rails app configuration using ENV and a single YAML file"
|
11
11
|
gem.homepage = "https://github.com/laserlemon/figaro"
|
data/lib/figaro.rb
CHANGED
data/lib/figaro/env.rb
CHANGED
@@ -5,11 +5,12 @@ module Figaro
|
|
5
5
|
end
|
6
6
|
|
7
7
|
def method_missing(method, *)
|
8
|
-
ENV.
|
8
|
+
pair = ENV.detect { |k, _| k.upcase == method.to_s.upcase }
|
9
|
+
pair ? pair[1] : super
|
9
10
|
end
|
10
11
|
|
11
|
-
def respond_to?(method)
|
12
|
-
ENV.
|
12
|
+
def respond_to?(method, *)
|
13
|
+
ENV.keys.any? { |k| k.upcase == method.to_s.upcase } || super
|
13
14
|
end
|
14
15
|
end
|
15
16
|
end
|
data/spec/figaro/env_spec.rb
CHANGED
@@ -1,23 +1,65 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe Figaro::Env do
|
4
|
+
subject(:env) { Figaro::Env.new }
|
5
|
+
|
4
6
|
before do
|
5
7
|
ENV["HELLO"] = "world"
|
8
|
+
ENV["foo"] = "bar"
|
6
9
|
end
|
7
10
|
|
8
11
|
after do
|
9
12
|
ENV.delete("HELLO")
|
13
|
+
ENV.delete("foo")
|
10
14
|
end
|
11
15
|
|
12
|
-
|
13
|
-
|
14
|
-
|
16
|
+
describe "#method_missing" do
|
17
|
+
it "makes ENV values accessible as lowercase methods" do
|
18
|
+
expect(env.hello).to eq("world")
|
19
|
+
expect(env.foo).to eq("bar")
|
20
|
+
end
|
21
|
+
|
22
|
+
it "makes ENV values accessible as uppercase methods" do
|
23
|
+
expect(env.HELLO).to eq("world")
|
24
|
+
expect(env.FOO).to eq("bar")
|
25
|
+
end
|
26
|
+
|
27
|
+
it "makes ENV values accessible as mixed-case methods" do
|
28
|
+
expect(env.Hello).to eq("world")
|
29
|
+
expect(env.fOO).to eq("bar")
|
30
|
+
end
|
15
31
|
|
16
|
-
|
17
|
-
|
32
|
+
it "raises an error if no ENV key matches" do
|
33
|
+
expect { env.goodbye }.to raise_error(NoMethodError)
|
34
|
+
end
|
18
35
|
end
|
19
36
|
|
20
|
-
|
21
|
-
|
37
|
+
describe "#respond_to?" do
|
38
|
+
context "when ENV has the key" do
|
39
|
+
it "is true for a lowercase method" do
|
40
|
+
expect(env.respond_to?(:hello)).to be_true
|
41
|
+
expect(env.respond_to?(:foo)).to be_true
|
42
|
+
end
|
43
|
+
|
44
|
+
it "is true for a uppercase method" do
|
45
|
+
expect(env.respond_to?(:HELLO)).to be_true
|
46
|
+
expect(env.respond_to?(:FOO)).to be_true
|
47
|
+
end
|
48
|
+
|
49
|
+
it "is true for a mixed-case key" do
|
50
|
+
expect(env.respond_to?(:Hello)).to be_true
|
51
|
+
expect(env.respond_to?(:fOO)).to be_true
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
context "when ENV doesn't have the key" do
|
56
|
+
it "is true if Hash responds to the method" do
|
57
|
+
expect(env.respond_to?(:baz)).to be_false
|
58
|
+
end
|
59
|
+
|
60
|
+
it "is false if Hash doesn't respond to the method" do
|
61
|
+
expect(env.respond_to?(:[])).to be_true
|
62
|
+
end
|
63
|
+
end
|
22
64
|
end
|
23
65
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: figaro
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steve Richert
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-05-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -46,8 +46,7 @@ dependencies:
|
|
46
46
|
version: '5'
|
47
47
|
description: Simple, Heroku-friendly Rails app configuration using ENV and a single
|
48
48
|
YAML file
|
49
|
-
email:
|
50
|
-
- steve.richert@gmail.com
|
49
|
+
email: steve.richert@gmail.com
|
51
50
|
executables: []
|
52
51
|
extensions: []
|
53
52
|
extra_rdoc_files: []
|
@@ -101,7 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
101
100
|
version: '0'
|
102
101
|
requirements: []
|
103
102
|
rubyforge_project:
|
104
|
-
rubygems_version: 2.0.
|
103
|
+
rubygems_version: 2.0.3
|
105
104
|
signing_key:
|
106
105
|
specification_version: 4
|
107
106
|
summary: Simple Rails app configuration
|