env_bang 0.2.8 → 0.2.8.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -2
- data/lib/env_bang/version.rb +1 -1
- data/lib/env_bang.rb +7 -6
- data/test/env_bang_test.rb +2 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ec44b0eec6674b6a0cdf6f16989121a5bda0d79b
|
4
|
+
data.tar.gz: 58a68baf89c28c817f8b543cb5ec485aa83bef6f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a92587c42bda2d877ecb4fe61b7358579ec7869c01afd064c722dc87e46f278b6a4ad94cec923180d0a98e2ef13ba7383eb583a26738a54e8744d4bea8e20764
|
7
|
+
data.tar.gz: 7fd541f39092230c9a3e84775b0be6aac4a4c9fd345efb4ff5659535732fa7450c2f67bc6db707a640c1c32b5cfb0f02fdb6c54d9930a3cb8645e3d2dd698f2e
|
data/README.md
CHANGED
@@ -27,7 +27,7 @@ gem 'env_bang'
|
|
27
27
|
Or for Rails apps, use `env_bang-rails` instead for more convenience:
|
28
28
|
|
29
29
|
```ruby
|
30
|
-
gem 'env_bang-rails
|
30
|
+
gem 'env_bang-rails'
|
31
31
|
```
|
32
32
|
|
33
33
|
And then execute:
|
@@ -133,8 +133,9 @@ set
|
|
133
133
|
|
134
134
|
```ruby
|
135
135
|
ENV!.config do
|
136
|
-
|
136
|
+
default_class String
|
137
137
|
end
|
138
|
+
```
|
138
139
|
|
139
140
|
#### Custom type conversion
|
140
141
|
|
data/lib/env_bang/version.rb
CHANGED
data/lib/env_bang.rb
CHANGED
@@ -9,6 +9,7 @@ class ENV_BANG
|
|
9
9
|
|
10
10
|
def clear_config
|
11
11
|
@vars = {}
|
12
|
+
default_class nil
|
12
13
|
end
|
13
14
|
|
14
15
|
def use(var, *args)
|
@@ -54,12 +55,12 @@ class ENV_BANG
|
|
54
55
|
Classes.send :define_singleton_method, klass.to_s, &block
|
55
56
|
end
|
56
57
|
|
57
|
-
def default_class
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
58
|
+
def default_class(*args)
|
59
|
+
if args.any?
|
60
|
+
Classes.default_class = args.first
|
61
|
+
else
|
62
|
+
Classes.default_class
|
63
|
+
end
|
63
64
|
end
|
64
65
|
end
|
65
66
|
|
data/test/env_bang_test.rb
CHANGED
@@ -118,7 +118,8 @@ describe ENV_BANG do
|
|
118
118
|
end
|
119
119
|
|
120
120
|
it "allows default class to be overridden" do
|
121
|
-
ENV!.
|
121
|
+
ENV!.default_class.must_equal :StringUnlessFalsey
|
122
|
+
ENV!.config { default_class String }
|
122
123
|
ENV['FALSE'] = falsey_values.sample
|
123
124
|
ENV!.use 'FALSE', class: String
|
124
125
|
|