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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5d7b54a1fff4008a1f9b1ce3b71e10b21f513cf0
4
- data.tar.gz: 15f7461f65c71a52f259887192c881d7cacb63c8
3
+ metadata.gz: 7b8d6739744f9370d824be0539484471d4bf1e86
4
+ data.tar.gz: cfd655d0df2b5d13392a8e552440bcc70a219b54
5
5
  SHA512:
6
- metadata.gz: cb2cbf128ccb8abb1ea3a09f4dff794eacde58efa511ab0a1cee9e87e092432244b43bacebb738e26e8909a98804b010ca175679bd4a7260e8c09fcca2c1d925
7
- data.tar.gz: fb09d67d7c006cf2a14285a228ddeb85758d77e5a6ab1553c27980fd4ec46bab382b64eff069c03a967a4cee0afd8cae12a6752a30ebf19c491cc876cec9516c
6
+ metadata.gz: 4b47d791dd1cebfc7afcce9912b7e47eae29d0410e4afd2ea4ce1e676e52a1ae5072f2eae4f4721f66588d09422b74d9c18eeb025332ceb8dd2a4d0c9c38a776
7
+ data.tar.gz: 1091cf3a6072a334e806febaea04fa66d520c54a754b9e230cfb233b69c7cd1b6da682f6703a19eaff9b95f49a364d9093558651ea2ac0a57e3ae1548e3a3045
@@ -1,5 +1,5 @@
1
1
  module Sawyer
2
- VERSION = "0.5.1"
2
+ VERSION = "0.5.2"
3
3
 
4
4
  class Error < StandardError; end
5
5
  end
@@ -100,7 +100,11 @@ module Sawyer
100
100
 
101
101
  def decode_hash_value(key, value)
102
102
  if time_field?(key, value)
103
- Time.parse(value)
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
@@ -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 = {:a => 1, :b => true, :c => 'c', :created_at => time, :published_at => nil}
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.1
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-09-25 00:00:00.000000000 Z
12
+ date: 2013-12-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: faraday