zephyr 1.0.5 → 1.0.6
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.
- data/README.md +1 -0
- data/VERSION +1 -1
- data/lib/zephyr.rb +24 -18
- data/zephyr.gemspec +2 -2
- metadata +4 -4
data/README.md
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.6
|
data/lib/zephyr.rb
CHANGED
@@ -45,7 +45,7 @@ class Zephyr
|
|
45
45
|
def default_headers
|
46
46
|
{
|
47
47
|
'Accept' => 'application/json;q=0.7, */*;q=0.5',
|
48
|
-
'User-Agent' => '
|
48
|
+
'User-Agent' => 'zephyr',
|
49
49
|
}
|
50
50
|
end
|
51
51
|
|
@@ -87,15 +87,7 @@ class Zephyr
|
|
87
87
|
# application/json) and adds it under the :json key in the returned hash.
|
88
88
|
def get_json(expected_statuses, timeout, path_components, headers={}, yajl_opts={})
|
89
89
|
response = get(expected_statuses, timeout, path_components, headers)
|
90
|
-
|
91
|
-
content_type = response[:headers]['content-type']
|
92
|
-
content_type = content_type.first if content_type.respond_to?(:first)
|
93
|
-
|
94
|
-
if content_type.to_s.strip.match /^application\/json/
|
95
|
-
response[:json] = Yajl::Parser.parse(response[:body], yajl_opts)
|
96
|
-
end
|
97
|
-
|
98
|
-
response
|
90
|
+
create_json_response(response, yajl_opts)
|
99
91
|
end
|
100
92
|
|
101
93
|
# Performs a PUT request to the specified resource.
|
@@ -119,7 +111,8 @@ class Zephyr
|
|
119
111
|
# The same thing as #put, but encodes the entity as JSON and specifies
|
120
112
|
# "application/json" as the request entity content type.
|
121
113
|
def put_json(expected_statuses, timeout, path_components, entity, headers={})
|
122
|
-
put(expected_statuses, timeout, path_components, Yajl::Encoder.encode(entity), headers.merge("Content-Type" => "application/json"))
|
114
|
+
response = put(expected_statuses, timeout, path_components, Yajl::Encoder.encode(entity), headers.merge("Content-Type" => "application/json"))
|
115
|
+
create_json_response(response)
|
123
116
|
end
|
124
117
|
|
125
118
|
# Performs a POST request to the specified resource.
|
@@ -143,13 +136,14 @@ class Zephyr
|
|
143
136
|
# The same thing as #post, but encodes the entity as JSON and specifies
|
144
137
|
# "application/json" as the request entity content type.
|
145
138
|
def post_json(expected_statuses, timeout, path_components, entity, headers={})
|
146
|
-
post(
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
139
|
+
response = post(
|
140
|
+
expected_statuses,
|
141
|
+
timeout,
|
142
|
+
path_components,
|
143
|
+
Yajl::Encoder.encode(entity),
|
144
|
+
headers.merge("Content-Type" => "application/json")
|
145
|
+
)
|
146
|
+
create_json_response(response)
|
153
147
|
end
|
154
148
|
|
155
149
|
# Performs a DELETE request to the specified resource.
|
@@ -308,6 +302,18 @@ class Zephyr
|
|
308
302
|
end
|
309
303
|
end
|
310
304
|
end
|
305
|
+
|
306
|
+
def create_json_response(response, yajl_opts = {})
|
307
|
+
return response if response.nil? || !response.key?(:headers) || !response[:headers].key?('content-type')
|
308
|
+
content_type = response[:headers]['content-type']
|
309
|
+
content_type = content_type.first if content_type.respond_to?(:first)
|
310
|
+
|
311
|
+
if content_type.to_s.strip.match /^application\/json/
|
312
|
+
response[:json] = Yajl::Parser.parse(response[:body], yajl_opts)
|
313
|
+
end
|
314
|
+
response
|
315
|
+
end
|
316
|
+
|
311
317
|
end
|
312
318
|
|
313
319
|
# Represents headers from an HTTP request or response.
|
data/zephyr.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{zephyr}
|
8
|
-
s.version = "1.0.
|
8
|
+
s.version = "1.0.6"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Matt Knopp"]
|
12
|
-
s.date = %q{2011-
|
12
|
+
s.date = %q{2011-11-01}
|
13
13
|
s.description = %q{Simple HTTP client using Typheous, derived from the Riak client}
|
14
14
|
s.email = %q{matt.knopp@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zephyr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 6
|
10
|
+
version: 1.0.6
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Matt Knopp
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-11-01 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|