sawyer 0.5.1 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sawyer.rb +1 -1
- data/lib/sawyer/serializer.rb +6 -2
- data/test/agent_test.rb +14 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7b8d6739744f9370d824be0539484471d4bf1e86
|
4
|
+
data.tar.gz: cfd655d0df2b5d13392a8e552440bcc70a219b54
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4b47d791dd1cebfc7afcce9912b7e47eae29d0410e4afd2ea4ce1e676e52a1ae5072f2eae4f4721f66588d09422b74d9c18eeb025332ceb8dd2a4d0c9c38a776
|
7
|
+
data.tar.gz: 1091cf3a6072a334e806febaea04fa66d520c54a754b9e230cfb233b69c7cd1b6da682f6703a19eaff9b95f49a364d9093558651ea2ac0a57e3ae1548e3a3045
|
data/lib/sawyer.rb
CHANGED
data/lib/sawyer/serializer.rb
CHANGED
@@ -100,7 +100,11 @@ module Sawyer
|
|
100
100
|
|
101
101
|
def decode_hash_value(key, value)
|
102
102
|
if time_field?(key, value)
|
103
|
-
|
103
|
+
begin
|
104
|
+
Time.parse(value)
|
105
|
+
rescue ArgumentError
|
106
|
+
value
|
107
|
+
end
|
104
108
|
elsif value.is_a?(Hash)
|
105
109
|
decode_hash(value)
|
106
110
|
elsif value.is_a?(Array)
|
@@ -111,7 +115,7 @@ module Sawyer
|
|
111
115
|
end
|
112
116
|
|
113
117
|
def time_field?(key, value)
|
114
|
-
value && key =~ /_(at|on)
|
118
|
+
value && (key =~ /_(at|on)\z/ || key =~ /(\A|_)date\z/)
|
115
119
|
end
|
116
120
|
end
|
117
121
|
end
|
data/test/agent_test.rb
CHANGED
@@ -119,7 +119,16 @@ module Sawyer
|
|
119
119
|
|
120
120
|
def test_encodes_and_decodes_times
|
121
121
|
time = Time.at(Time.now.to_i)
|
122
|
-
data = {
|
122
|
+
data = {
|
123
|
+
:a => 1,
|
124
|
+
:b => true,
|
125
|
+
:c => 'c',
|
126
|
+
:created_at => time,
|
127
|
+
:published_at => nil,
|
128
|
+
:updated_at => "An invalid date",
|
129
|
+
:pub_date => time,
|
130
|
+
:validate => true
|
131
|
+
}
|
123
132
|
data = [data.merge(:foo => [data])]
|
124
133
|
encoded = Sawyer::Agent.encode(data)
|
125
134
|
decoded = Sawyer::Agent.decode(encoded)
|
@@ -131,8 +140,11 @@ module Sawyer
|
|
131
140
|
assert_equal 1, decoded[:a]
|
132
141
|
assert_equal true, decoded[:b]
|
133
142
|
assert_equal 'c', decoded[:c]
|
134
|
-
assert_equal time, decoded[:created_at]
|
143
|
+
assert_equal time, decoded[:created_at], "Did not parse created_at as Time"
|
135
144
|
assert_nil decoded[:published_at]
|
145
|
+
assert_equal "An invalid date", decoded[:updated_at]
|
146
|
+
assert_equal time, decoded[:pub_date], "Did not parse pub_date as Time"
|
147
|
+
assert_equal true, decoded[:validate]
|
136
148
|
decoded = decoded[:foo]
|
137
149
|
end
|
138
150
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sawyer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rick Olson
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-12-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: faraday
|