hashstructor 1.0.2 → 1.0.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: 675a97fc95885219b7cdaa51ddd36f67a231c5d3
4
- data.tar.gz: ca05c6be506989b23d5afb11fe912bbdd7c6914b
3
+ metadata.gz: 620346f223f8ef18b1f9442286fb77640d486a58
4
+ data.tar.gz: 12a8b05f4dead8cf6c4a4b9a286975e08dcd368b
5
5
  SHA512:
6
- metadata.gz: 9cda2a0d1e8f58565bab6a92fe0c6f488777667b04ba5af61e543af68b45a95d328ff5da609c3e60185bef37f58685cbdb11fa0930ad890af8c6439d9195eeb5
7
- data.tar.gz: 0ae36d6db64cb120b4158b5c97d8f68123f8a2329df7ca9b61f644a0641a9169e4677be7a7b00112809bb5fdfb6b894d1b3dba9b2fb4dc45ea5a0416d06a9c0d
6
+ metadata.gz: e2f79fcb466071cd46d3ae82dca1f27035fd14403f7c5488148429bc858bb10fa1621feb0a45d5a2807ee2dae3b89db993d33671455fdefdadb841746b197509
7
+ data.tar.gz: ae4186ea0b7b24f5a3f180e5c5c3ffdd220f1692dac456724e7f03e6444045cbec2020ebef649d8f9e49bebef68a20deaaf883872e5d210b1abef8b99851b19f
@@ -22,6 +22,22 @@ module Hashstructor
22
22
  # @return [Symbol] the type of the member; see {VALID_MEMBER_TYPES}.
23
23
  attr_reader :member_type
24
24
 
25
+ # The procedure used in {VALID_VALUE_TYPES} for both `TrueClass` and
26
+ # `FalseClass`.
27
+ BOOL_PROC = Proc.new do |v|
28
+ v = v.downcase
29
+
30
+ case v.downcase
31
+ when "true", "t", "on", "yes"
32
+ true
33
+ when "false", "f", "off", "no"
34
+ false
35
+ else
36
+ raise HashstructorError, "unknown value when parsing boolean: #{v}"
37
+ end
38
+ end
39
+
40
+
25
41
  # A hash of Class => Proc converters for value types. Any value type
26
42
  # in this list, as well as any class that includes or prepends
27
43
  # `Hashstructor`, is valid for {#value_type}. This is _intentionally_
@@ -40,12 +56,8 @@ module Hashstructor
40
56
  Float => Proc.new do |v|
41
57
  Float(v.to_s)
42
58
  end,
43
- TrueClass => Proc.new do |v|
44
- !!v
45
- end,
46
- FalseClass => Proc.new do |v|
47
- !!v
48
- end,
59
+ TrueClass => BOOL_PROC,
60
+ FalseClass => BOOL_PROC,
49
61
  }
50
62
  # Determines the class that Hashstructor should attempt to coerce a
51
63
  # given value into. For example, `Fixnum` will attempt to coerce a
@@ -1,4 +1,4 @@
1
1
  module Hashstructor
2
2
  # The gem version. As one does.
3
- VERSION = "1.0.2"
3
+ VERSION = "1.0.3"
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hashstructor
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ed Ropple