env_bang 0.2.6 → 0.2.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/env_bang/version.rb +1 -1
- data/lib/env_bang-rails.rb +1 -1
- data/lib/env_bang.rb +12 -0
- data/test/env_bang_test.rb +22 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b4a31d98f7b91fa5c4bbad7088e70e2acb7b8403
|
4
|
+
data.tar.gz: e4285280d46906f66d633a79ec99297ef7fdc132
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 825091731f2bcd8b74aa435a2612d099a936797840fb3a035097254c9897049984614aaf14619f53e1960425e7998ffe661aaed8e17f8f45d2140c8cdffe089f
|
7
|
+
data.tar.gz: bdb5e802b7e705a9d84b55a1bcdb11b6ffe58ee9b67494f9202a73935caa5aedeea254261af8de852d459bfc6115a28dbd5cbc700b8961ae9863aa7c0e8cc94f
|
data/lib/env_bang/version.rb
CHANGED
data/lib/env_bang-rails.rb
CHANGED
data/lib/env_bang.rb
CHANGED
@@ -7,6 +7,10 @@ class ENV_BANG
|
|
7
7
|
instance_eval(&block)
|
8
8
|
end
|
9
9
|
|
10
|
+
def clear_config
|
11
|
+
@vars = {}
|
12
|
+
end
|
13
|
+
|
10
14
|
def use(var, *args)
|
11
15
|
description = args.first.is_a?(String) && args.shift
|
12
16
|
options = args.last.is_a?(Hash) ? args.pop : {}
|
@@ -26,6 +30,14 @@ class ENV_BANG
|
|
26
30
|
@vars ||= {}
|
27
31
|
end
|
28
32
|
|
33
|
+
def keys
|
34
|
+
vars.keys
|
35
|
+
end
|
36
|
+
|
37
|
+
def values
|
38
|
+
keys.map { |k| self[k] }
|
39
|
+
end
|
40
|
+
|
29
41
|
def [](var)
|
30
42
|
raise KeyError.new("ENV_BANG is not configured to use var #{var}") unless vars.has_key?(var)
|
31
43
|
|
data/test/env_bang_test.rb
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
require_relative 'test_helper'
|
2
2
|
|
3
3
|
describe ENV_BANG do
|
4
|
+
before do
|
5
|
+
ENV!.clear_config
|
6
|
+
end
|
7
|
+
|
4
8
|
it "Raises exception if unconfigured ENV var requested" do
|
5
9
|
ENV['UNCONFIGURED'] = 'unconfigured'
|
6
10
|
proc { ENV!['UNCONFIGURED'] }.must_raise KeyError
|
@@ -112,6 +116,24 @@ describe ENV_BANG do
|
|
112
116
|
|
113
117
|
ENV!['FALSE'].class.must_equal String
|
114
118
|
end
|
119
|
+
|
120
|
+
it "provides configured keys" do
|
121
|
+
ENV['VAR1'] = 'something'
|
122
|
+
ENV['VAR2'] = 'something else'
|
123
|
+
ENV!.use 'VAR1'
|
124
|
+
ENV!.use 'VAR2'
|
125
|
+
|
126
|
+
ENV!.keys.must_equal %w[VAR1 VAR2]
|
127
|
+
end
|
128
|
+
|
129
|
+
it "provides configured values" do
|
130
|
+
ENV['VAR1'] = 'something'
|
131
|
+
ENV['VAR2'] = 'something else'
|
132
|
+
ENV!.use 'VAR1'
|
133
|
+
ENV!.use 'VAR2'
|
134
|
+
|
135
|
+
ENV!.values.must_equal %w[something something\ else]
|
136
|
+
end
|
115
137
|
end
|
116
138
|
|
117
139
|
describe "Formatting" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: env_bang
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonathan Camenisch
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-01-
|
11
|
+
date: 2014-01-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -80,7 +80,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
80
80
|
version: '0'
|
81
81
|
requirements: []
|
82
82
|
rubyforge_project:
|
83
|
-
rubygems_version: 2.
|
83
|
+
rubygems_version: 2.2.0
|
84
84
|
signing_key:
|
85
85
|
specification_version: 4
|
86
86
|
summary: Do a bang-up job managing your environment variables
|