hashstruct 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/lib/hashstruct.rb +6 -3
- metadata +9 -11
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 2b3409cfc4f6bbdc9e8c6419da0886c96ee9e18b2ac7a1664d7cfdfff505e883
|
4
|
+
data.tar.gz: 9ec4f2a13067016073949b2e32da7db3dae3149853133c0141d88ece942dbb00
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9ab5c46ed27d3b0a642fb24e5e895ba8b7d2859e5adbe431622729f5bc5fccea57ee052a1bd6dfb627a8a75ddea5e365d809b46d55309892b47e6f52bf4c9ee0
|
7
|
+
data.tar.gz: f2cbba2f9c8ea8ca9eed54b1925863151ac9b3b9c54d1440dd57544554ac2ee4ef4ca91279d091821c196e2d9136dd2821c186f66e5d32241a446a54b1133c23
|
data/lib/hashstruct.rb
CHANGED
@@ -3,7 +3,7 @@ require 'uri'
|
|
3
3
|
|
4
4
|
class HashStruct < Hash
|
5
5
|
|
6
|
-
VERSION = '1.0.
|
6
|
+
VERSION = '1.0.1'
|
7
7
|
|
8
8
|
def initialize(args={})
|
9
9
|
super()
|
@@ -60,6 +60,9 @@ class HashStruct < Hash
|
|
60
60
|
# percent
|
61
61
|
when %r{^-?[\d,]+(\.\d+)?%$}
|
62
62
|
obj.to_f / 100
|
63
|
+
# rational
|
64
|
+
when %r{^(\d+)/(\d+)$}
|
65
|
+
Rational($1.to_i, $2.to_i)
|
63
66
|
# date
|
64
67
|
when %r{^\d{4}-\d{2}-\d{2}}, # 2010-06-06
|
65
68
|
%r{^\d{1,2}/\d{1,2}/\d{4}}, # 06/06/2010
|
@@ -67,10 +70,10 @@ class HashStruct < Hash
|
|
67
70
|
%r{^(Sun|Mon|Tue|Wed|Thu|Fri|Sat|Sun),?\s*\d*\s*\b(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\b} # Sun, 06 Jun 2010 23:02:25 GMT
|
68
71
|
DateTime.parse(obj)
|
69
72
|
# boolean true
|
70
|
-
when 'true'
|
73
|
+
when 'true', 'yes', 'on'
|
71
74
|
true
|
72
75
|
# boolean false
|
73
|
-
when 'false'
|
76
|
+
when 'false', 'no', 'off'
|
74
77
|
false
|
75
78
|
else
|
76
79
|
obj
|
metadata
CHANGED
@@ -1,17 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hashstruct
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
5
|
-
prerelease:
|
4
|
+
version: 1.0.1
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- John Labovitz
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2017-12-15 00:00:00.000000000 Z
|
13
12
|
dependencies: []
|
14
|
-
description:
|
13
|
+
description: "\n HashStruct provides an object based on Hash, but acts like Struct
|
15
14
|
(or OpenStruct), providing helpful\n accessors for each key from the get-go.
|
16
15
|
It also magically parses string values when it can (eg, dates,\n URIs, numbers,
|
17
16
|
and does so recursively.\n "
|
@@ -20,30 +19,29 @@ executables: []
|
|
20
19
|
extensions: []
|
21
20
|
extra_rdoc_files: []
|
22
21
|
files:
|
23
|
-
- lib/hashstruct.rb
|
24
22
|
- README.mdown
|
23
|
+
- lib/hashstruct.rb
|
25
24
|
homepage: http://github.com/jslabovitz/hashstruct
|
26
25
|
licenses: []
|
26
|
+
metadata: {}
|
27
27
|
post_install_message:
|
28
28
|
rdoc_options: []
|
29
29
|
require_paths:
|
30
30
|
- lib
|
31
31
|
required_ruby_version: !ruby/object:Gem::Requirement
|
32
|
-
none: false
|
33
32
|
requirements:
|
34
|
-
- -
|
33
|
+
- - ">="
|
35
34
|
- !ruby/object:Gem::Version
|
36
35
|
version: '0'
|
37
36
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
38
|
-
none: false
|
39
37
|
requirements:
|
40
|
-
- -
|
38
|
+
- - ">="
|
41
39
|
- !ruby/object:Gem::Version
|
42
40
|
version: '0'
|
43
41
|
requirements: []
|
44
42
|
rubyforge_project:
|
45
|
-
rubygems_version:
|
43
|
+
rubygems_version: 2.7.3
|
46
44
|
signing_key:
|
47
|
-
specification_version:
|
45
|
+
specification_version: 4
|
48
46
|
summary: Overly helpful magic hash structure.
|
49
47
|
test_files: []
|