env_bang 0.2.2 → 0.2.3

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: f4f947f6254ba2525e9adbc54f9232f3ad474d87
4
- data.tar.gz: 1d841d62033d1de759c785df8ff4777e70021fcc
3
+ metadata.gz: 287b06064bf43d1929be703bf94162da9410405e
4
+ data.tar.gz: af7afbcc9e86a6b49a8f707d30f36f72a69f0c51
5
5
  SHA512:
6
- metadata.gz: 00714c51d0c558d9dc4b6fe9f34bd1e2e50ea99ce02123e841ac5c616b7c1250ef8d856e141ace7f92b8dab817b2c3bd84cfaa1f39c2637730f27ee1bc859311
7
- data.tar.gz: c65bdc677a552e3dcd82ffdf915922a076b9067348ce81bd28fa15469524bad00ad37213c310ed95063c7a4c27b55da6091df4de99c58aeaa7136ffa6a3c619e
6
+ metadata.gz: 34468725fcb5025f66a3f07465c23c1a2339954f1437354867c9c6d4593715a053d79bccad4d38fa13a113cbee0988d33259931504c3911cd7b8c93b901dc13d
7
+ data.tar.gz: f3d75bd63a8a9bae881e44f11bfc7d718e90a508dbb398eec0a79801a4a79ff3abaa3d551e8b1701e1e08f2139587d650ba39a9fd3692cb91262a7299f4cddbf
@@ -1,3 +1,3 @@
1
1
  class ENV_BANG
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.3"
3
3
  end
data/lib/env_bang.rb CHANGED
@@ -14,9 +14,7 @@ class ENV_BANG
14
14
  ENV[var] = options.fetch(:default) { formatted_error(var, description) }.to_s
15
15
  end
16
16
 
17
- # Store the variable, converted to requested class
18
- klass = :"#{options.fetch(:class, :StringUnlessFalsey)}"
19
- vars[var] = Classes.cast ENV[var], klass, options
17
+ vars[var] = options
20
18
  end
21
19
 
22
20
  def formatted_error(var, description)
@@ -33,7 +31,7 @@ class ENV_BANG
33
31
  def [](var)
34
32
  raise KeyError.new("ENV_BANG is not configured to use var #{var}") unless vars.has_key?(var)
35
33
 
36
- vars[var]
34
+ Classes.cast ENV[var], vars[var]
37
35
  end
38
36
 
39
37
  def method_missing(method, *args, &block)
@@ -43,8 +41,8 @@ class ENV_BANG
43
41
 
44
42
  module Classes
45
43
  class << self
46
- def cast(value, klass, options = {})
47
- public_send(:"#{klass}", value, options)
44
+ def cast(value, options = {})
45
+ public_send(:"#{options.fetch(:class, :StringUnlessFalsey)}", value, options)
48
46
  end
49
47
 
50
48
  def boolean(value, options)
@@ -52,8 +50,9 @@ class ENV_BANG
52
50
  end
53
51
 
54
52
  def Array(value, options)
55
- klass = options.fetch(:of, :StringUnlessFalsey)
56
- value.split(',').map { |value| cast(value.strip, klass) }
53
+ options.delete(:class)
54
+ options[:class] = options[:of] if options[:of]
55
+ value.split(',').map { |value| cast(value.strip, options) }
57
56
  end
58
57
 
59
58
  def Symbol(value, options)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: env_bang
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Camenisch