api_resource 0.6.8 → 0.6.9
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +2 -2
- data/Gemfile.lock +6 -6
- data/lib/api_resource/connection.rb +23 -6
- data/lib/api_resource/typecast.rb +1 -0
- data/lib/api_resource/version.rb +1 -1
- metadata +3 -4
data/.travis.yml
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
api_resource (0.6.
|
4
|
+
api_resource (0.6.8)
|
5
5
|
colorize
|
6
6
|
differ
|
7
7
|
json
|
@@ -77,10 +77,10 @@ GEM
|
|
77
77
|
activesupport
|
78
78
|
colorize
|
79
79
|
i18n
|
80
|
-
hike (1.2.
|
80
|
+
hike (1.2.3)
|
81
81
|
i18n (0.6.1)
|
82
82
|
journey (1.0.4)
|
83
|
-
json (1.
|
83
|
+
json (1.8.0)
|
84
84
|
listen (0.7.1)
|
85
85
|
log4r (1.1.10)
|
86
86
|
lumberjack (1.0.2)
|
@@ -90,7 +90,7 @@ GEM
|
|
90
90
|
treetop (~> 1.4.8)
|
91
91
|
metaclass (0.0.1)
|
92
92
|
method_source (0.8.1)
|
93
|
-
mime-types (1.
|
93
|
+
mime-types (1.25)
|
94
94
|
mocha (0.12.7)
|
95
95
|
metaclass (~> 0.0.1)
|
96
96
|
multi_json (1.5.0)
|
@@ -151,8 +151,8 @@ GEM
|
|
151
151
|
tilt (~> 1.1, != 1.3.0)
|
152
152
|
sqlite3 (1.3.6)
|
153
153
|
thor (0.16.0)
|
154
|
-
tilt (1.
|
155
|
-
treetop (1.4.
|
154
|
+
tilt (1.4.1)
|
155
|
+
treetop (1.4.15)
|
156
156
|
polyglot
|
157
157
|
polyglot (>= 0.3.1)
|
158
158
|
tzinfo (0.3.37)
|
@@ -50,8 +50,13 @@ module ApiResource
|
|
50
50
|
def timeout=(timeout)
|
51
51
|
@timeout = timeout
|
52
52
|
end
|
53
|
-
|
54
|
-
|
53
|
+
|
54
|
+
# make a put request
|
55
|
+
# @return [String] response.body raises an
|
56
|
+
# ApiResource::ConnectionError if we
|
57
|
+
# have a timeout, general exception, or
|
58
|
+
# if result.code is not within 200..399
|
59
|
+
def get(path, headers = self.headers)
|
55
60
|
# our site and headers for this request
|
56
61
|
site = self.site.merge(path)
|
57
62
|
headers = build_request_headers(headers, :get, site)
|
@@ -71,6 +76,10 @@ module ApiResource
|
|
71
76
|
end
|
72
77
|
|
73
78
|
# make a put request
|
79
|
+
# @return [String] response.body raises an
|
80
|
+
# ApiResource::ConnectionError if we
|
81
|
+
# have a timeout, general exception, or
|
82
|
+
# if result.code is not within 200..399
|
74
83
|
def put(path, body = {}, headers = self.headers)
|
75
84
|
format.decode(
|
76
85
|
request(
|
@@ -82,8 +91,12 @@ module ApiResource
|
|
82
91
|
)
|
83
92
|
end
|
84
93
|
|
85
|
-
|
86
|
-
|
94
|
+
# make a post request
|
95
|
+
# @return [String] response.body raises an
|
96
|
+
# ApiResource::ConnectionError if we
|
97
|
+
# have a timeout, general exception, or
|
98
|
+
# if result.code is not within 200..399
|
99
|
+
def post(path, body = {}, headers = self.headers)
|
87
100
|
format.decode(
|
88
101
|
request(
|
89
102
|
:post,
|
@@ -113,7 +126,11 @@ module ApiResource
|
|
113
126
|
end
|
114
127
|
|
115
128
|
private
|
116
|
-
# Makes a request to the remote service
|
129
|
+
# Makes a request to the remote service
|
130
|
+
# @return [String] response.body raises an
|
131
|
+
# ApiResource::ConnectionError if we
|
132
|
+
# have a timeout, general exception, or
|
133
|
+
# if result.code is not within 200..399
|
117
134
|
def request(method, path, *arguments)
|
118
135
|
handle_response(path) do
|
119
136
|
ActiveSupport::Notifications.instrument("request.api_resource") do |payload|
|
@@ -149,7 +166,7 @@ module ApiResource
|
|
149
166
|
case code.to_i
|
150
167
|
when 301,302
|
151
168
|
raise ApiResource::Redirection.new(response)
|
152
|
-
when 200..
|
169
|
+
when 200..399
|
153
170
|
response.body
|
154
171
|
when 400
|
155
172
|
raise ApiResource::BadRequest.new(response)
|
data/lib/api_resource/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: api_resource
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.9
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2013-
|
14
|
+
date: 2013-09-18 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: rake
|
@@ -480,7 +480,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
480
480
|
version: '0'
|
481
481
|
requirements: []
|
482
482
|
rubyforge_project:
|
483
|
-
rubygems_version: 1.8.
|
483
|
+
rubygems_version: 1.8.25
|
484
484
|
signing_key:
|
485
485
|
specification_version: 3
|
486
486
|
summary: ActiveRecord for restful APIs
|
@@ -523,4 +523,3 @@ test_files:
|
|
523
523
|
- spec/support/requests/test_resource_requests.rb
|
524
524
|
- spec/support/test_resource.rb
|
525
525
|
- spec/tmp/DIR
|
526
|
-
has_rdoc:
|