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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bfdb5e43a5f35d5cea9f39f538f83504d4f77869
4
- data.tar.gz: f11fd02adf4720dcec9a4f6161aa618bc259f877
3
+ metadata.gz: b4a31d98f7b91fa5c4bbad7088e70e2acb7b8403
4
+ data.tar.gz: e4285280d46906f66d633a79ec99297ef7fdc132
5
5
  SHA512:
6
- metadata.gz: 161419e599bed888d9f6177a3113685379d32710712c6d20a6953e16389d1ef8aaa291d9474a337b187c9e9b640a837cb0802e08827a1912365a802f547a6161
7
- data.tar.gz: b90d49748dba09ae7633796290f31a2931dcb7478f58b95854eddfd0e0eeaf7a2b4225bd07678cac4792adeff1e97e79deb6f93c92e4c20a83c1361bd9fab6da
6
+ metadata.gz: 825091731f2bcd8b74aa435a2612d099a936797840fb3a035097254c9897049984614aaf14619f53e1960425e7998ffe661aaed8e17f8f45d2140c8cdffe089f
7
+ data.tar.gz: bdb5e802b7e705a9d84b55a1bcdb11b6ffe58ee9b67494f9202a73935caa5aedeea254261af8de852d459bfc6115a28dbd5cbc700b8961ae9863aa7c0e8cc94f
@@ -1,3 +1,3 @@
1
1
  class ENV_BANG
2
- VERSION = "0.2.6"
2
+ VERSION = "0.2.7"
3
3
  end
@@ -3,7 +3,7 @@ require 'env_bang'
3
3
  class ENV_BANG
4
4
  class Railtie < Rails::Railtie
5
5
  def env_rb_file
6
- File.join(Rails.root, 'config/env.rb')
6
+ File.join(Rails.root.to_s, 'config/env.rb')
7
7
  end
8
8
 
9
9
  config.before_configuration do
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
 
@@ -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.6
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-17 00:00:00.000000000 Z
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.1.10
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