sawyer 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +4 -0
- data/lib/sawyer.rb +1 -1
- data/lib/sawyer/resource.rb +3 -2
- data/sawyer.gemspec +1 -1
- data/test/agent_test.rb +7 -13
- data/test/helper.rb +2 -2
- data/test/relation_test.rb +1 -1
- data/test/resource_test.rb +14 -14
- metadata +11 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7366e3f2256e74947a4fa2774a611576e071df0c
|
4
|
+
data.tar.gz: 169092ebe870be47b615ae6256c4573c3c044f34
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0b454b751c638a4a33b81dd9f1cd5aae1e981af61f7be32133ef2defb0a750c224eee75164701e511c33e478563a9d66986a01e9344902f2c6e602cbec35ed47
|
7
|
+
data.tar.gz: a1c2cda9e4507367c1b90126cae91c2b6ed0a0e5d6eb130587ee7c1f301609118d37b9578c1722ead9a50e4058a02f568120aab71ca076554a75afd353276e4b
|
data/Gemfile
CHANGED
data/lib/sawyer.rb
CHANGED
data/lib/sawyer/resource.rb
CHANGED
@@ -3,8 +3,6 @@ module Sawyer
|
|
3
3
|
SPECIAL_METHODS = Set.new(%w(agent rels fields))
|
4
4
|
attr_reader :_agent, :_rels, :_fields
|
5
5
|
attr_reader :attrs
|
6
|
-
alias to_hash attrs
|
7
|
-
alias to_h attrs
|
8
6
|
include Enumerable
|
9
7
|
|
10
8
|
# Initializes a Resource with the given data.
|
@@ -142,6 +140,9 @@ module Sawyer
|
|
142
140
|
hash
|
143
141
|
end
|
144
142
|
|
143
|
+
alias to_hash to_attrs
|
144
|
+
alias to_h to_attrs
|
145
|
+
|
145
146
|
def marshal_dump
|
146
147
|
[@attrs, @_fields, @_rels]
|
147
148
|
end
|
data/sawyer.gemspec
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.licenses = ['MIT']
|
19
19
|
|
20
20
|
spec.add_dependency 'faraday', ['~> 0.8', '< 0.10']
|
21
|
-
spec.add_dependency 'addressable', ['
|
21
|
+
spec.add_dependency 'addressable', ['>= 2.3.5', '< 2.5']
|
22
22
|
|
23
23
|
spec.files = %w(Gemfile LICENSE.md README.md Rakefile)
|
24
24
|
spec.files << "#{lib}.gemspec"
|
data/test/agent_test.rb
CHANGED
@@ -68,7 +68,7 @@ module Sawyer
|
|
68
68
|
end
|
69
69
|
|
70
70
|
assert_kind_of Sawyer::Response, @agent.root
|
71
|
-
|
71
|
+
refute_equal @agent.root.time, @agent.start.time
|
72
72
|
end
|
73
73
|
|
74
74
|
def test_starts_a_session
|
@@ -169,18 +169,14 @@ module Sawyer
|
|
169
169
|
end
|
170
170
|
|
171
171
|
def test_handle_yaml_dump_and_load
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
YAML.load(YAML.dump(res))
|
176
|
-
end
|
172
|
+
require 'yaml'
|
173
|
+
res = Agent.new 'http://example.com', :a => 1
|
174
|
+
YAML.load(YAML.dump(res))
|
177
175
|
end
|
178
176
|
|
179
177
|
def test_handle_marshal_dump_and_load
|
180
|
-
|
181
|
-
|
182
|
-
Marshal.load(Marshal.dump(res))
|
183
|
-
end
|
178
|
+
res = Agent.new 'http://example.com', :a => 1
|
179
|
+
Marshal.load(Marshal.dump(res))
|
184
180
|
end
|
185
181
|
|
186
182
|
def test_blank_response_doesnt_raise
|
@@ -193,9 +189,7 @@ module Sawyer
|
|
193
189
|
conn.adapter :test, @stubs
|
194
190
|
end
|
195
191
|
|
196
|
-
|
197
|
-
assert_equal 200, agent.root.status
|
198
|
-
end
|
192
|
+
assert_equal 200, agent.root.status
|
199
193
|
end
|
200
194
|
end
|
201
195
|
end
|
data/test/helper.rb
CHANGED
data/test/relation_test.rb
CHANGED
data/test/resource_test.rb
CHANGED
@@ -99,9 +99,7 @@ module Sawyer
|
|
99
99
|
assert !res.respond_to?(:b)
|
100
100
|
assert !res.respond_to?(:b=)
|
101
101
|
assert_nil res.b
|
102
|
-
|
103
|
-
res.b
|
104
|
-
end
|
102
|
+
res.b
|
105
103
|
end
|
106
104
|
|
107
105
|
def test_dynamic_attribute_methods_from_setter
|
@@ -128,6 +126,12 @@ module Sawyer
|
|
128
126
|
assert_equal hash, res.to_h
|
129
127
|
end
|
130
128
|
|
129
|
+
def test_to_h_with_nesting
|
130
|
+
res = Resource.new @agent, :a => {:b => 1}
|
131
|
+
hash = {:a => {:b => 1}}
|
132
|
+
assert_equal hash, res.to_h
|
133
|
+
end
|
134
|
+
|
131
135
|
def test_to_attrs_for_sawyer_resource_arrays
|
132
136
|
res = Resource.new @agent, :a => 1, :b => [Resource.new(@agent, :a => 2)]
|
133
137
|
hash = {:a => 1, :b => [{:a => 2}]}
|
@@ -163,24 +167,20 @@ module Sawyer
|
|
163
167
|
end
|
164
168
|
|
165
169
|
def test_handle_yaml_dump
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
YAML.dump(res)
|
170
|
-
end
|
170
|
+
require 'yaml'
|
171
|
+
res = Resource.new @agent, :a => 1
|
172
|
+
YAML.dump(res)
|
171
173
|
end
|
172
174
|
|
173
175
|
def test_handle_marshal_dump
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
assert_equal 1, resource.a
|
178
|
-
end
|
176
|
+
dump = Marshal.dump(Resource.new(@agent, :a => 1))
|
177
|
+
resource = Marshal.load(dump)
|
178
|
+
assert_equal 1, resource.a
|
179
179
|
end
|
180
180
|
|
181
181
|
def test_inspect
|
182
182
|
resource = Resource.new @agent, :a => 1
|
183
|
-
assert_equal "{:a=>1}
|
183
|
+
assert_equal "{:a=>1}", resource.inspect
|
184
184
|
end
|
185
185
|
|
186
186
|
def test_each
|
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.
|
4
|
+
version: 0.7.0
|
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:
|
12
|
+
date: 2016-02-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: faraday
|
@@ -35,16 +35,22 @@ dependencies:
|
|
35
35
|
name: addressable
|
36
36
|
requirement: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 2.3.5
|
41
|
+
- - "<"
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '2.5'
|
41
44
|
type: :runtime
|
42
45
|
prerelease: false
|
43
46
|
version_requirements: !ruby/object:Gem::Requirement
|
44
47
|
requirements:
|
45
|
-
- - "
|
48
|
+
- - ">="
|
46
49
|
- !ruby/object:Gem::Version
|
47
50
|
version: 2.3.5
|
51
|
+
- - "<"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '2.5'
|
48
54
|
description:
|
49
55
|
email: technoweenie@gmail.com
|
50
56
|
executables: []
|
@@ -94,7 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
94
100
|
version: 1.3.5
|
95
101
|
requirements: []
|
96
102
|
rubyforge_project:
|
97
|
-
rubygems_version: 2.
|
103
|
+
rubygems_version: 2.4.5.1
|
98
104
|
signing_key:
|
99
105
|
specification_version: 2
|
100
106
|
summary: Secret User Agent of HTTP
|