zephyr 1.1.2 → 1.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/VERSION +1 -1
  2. data/lib/zephyr.rb +15 -20
  3. data/zephyr.gemspec +2 -2
  4. metadata +38 -16
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.2
1
+ 1.1.3
data/lib/zephyr.rb CHANGED
@@ -57,6 +57,8 @@ class Zephyr
57
57
  end
58
58
 
59
59
  class << self
60
+ @debug_mode = false
61
+
60
62
  def logger
61
63
  @@logger
62
64
  end
@@ -64,6 +66,14 @@ class Zephyr
64
66
  def logger=(logger)
65
67
  @@logger = logger
66
68
  end
69
+
70
+ def debug_mode
71
+ @debug_mode
72
+ end
73
+
74
+ def debug_mode=(mode)
75
+ @debug_mode = mode
76
+ end
67
77
  end
68
78
 
69
79
  @@logger = Logger.new(STDOUT)
@@ -194,7 +204,6 @@ class Zephyr
194
204
  def uri(given_parts = [])
195
205
  @root_uri.dup.tap do |uri|
196
206
  parts = given_parts.dup.unshift(uri.path) # URI#merge is broken.
197
- uri.query = build_query_string(parts.pop) if parts.last.is_a? Hash
198
207
  uri.path = ('/%s' % parts.join('/')).gsub(/\/+/, '/')
199
208
  end
200
209
  end
@@ -209,21 +218,6 @@ class Zephyr
209
218
  Typheous::Hydra.hydra.cleanup
210
219
  end
211
220
 
212
- # Assembles a query string from a Hash, escaping values and keys. If a
213
- # value is an Array, the query parameter simply appears twice.
214
- #
215
- # Stolen from Rack (with minor changes for sorting).
216
- #
217
- def build_query_string(params)
218
- params.map do |k, v|
219
- if v.kind_of? Array
220
- build_query_string(v.map { |x| [k, x] })
221
- else
222
- "#{percent_encode(k)}=#{percent_encode(v)}"
223
- end
224
- end.sort.join '&'
225
- end
226
-
227
221
  def percent_encode(value)
228
222
  typhoeus_easy.send(:easy_escape, value.to_s, value.to_s.bytesize)
229
223
  end
@@ -266,17 +260,18 @@ class Zephyr
266
260
  params[:headers] = headers
267
261
  params[:timeout] = timeout
268
262
  params[:follow_location] = false
269
-
270
- # seriously, why is this on by default
263
+ params[:params] = path_components.pop if path_components.last.is_a?(Hash)
264
+
265
+ # seriously, why is this on by default
271
266
  Typhoeus::Hydra.hydra.disable_memoization
272
267
 
273
268
  # if you want debugging
274
- # params[:verbose] = true
269
+ params[:verbose] = Zephyr.debug_mode
275
270
 
276
271
  # have a vague feeling this isn't going to work as expected
277
272
  if method == :post || method == :put
278
273
  data = data.read if data.respond_to?(:read)
279
- params[:body] = data
274
+ params[:body] = data if data != ''
280
275
  end
281
276
 
282
277
  # request has class methods for :delete, :get, :head, :put, and :post
data/zephyr.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "zephyr"
8
- s.version = "1.1.2"
8
+ s.version = "1.1.3"
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 = "2012-03-16"
12
+ s.date = "2012-07-05"
13
13
  s.description = "Simple HTTP client using Typheous, derived from the Riak client"
14
14
  s.email = "matt.knopp@gmail.com"
15
15
  s.extra_rdoc_files = [
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zephyr
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.1.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-03-16 00:00:00.000000000 Z
12
+ date: 2012-07-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: typhoeus
16
- requirement: &70159647046820 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,15 @@ dependencies:
21
21
  version: 0.2.4
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70159647046820
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 0.2.4
25
30
  - !ruby/object:Gem::Dependency
26
31
  name: yajl-ruby
27
- requirement: &70159647045860 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
28
33
  none: false
29
34
  requirements:
30
35
  - - ! '>='
@@ -32,10 +37,15 @@ dependencies:
32
37
  version: '0'
33
38
  type: :runtime
34
39
  prerelease: false
35
- version_requirements: *70159647045860
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
36
46
  - !ruby/object:Gem::Dependency
37
47
  name: bundler
38
- requirement: &70159646995840 !ruby/object:Gem::Requirement
48
+ requirement: !ruby/object:Gem::Requirement
39
49
  none: false
40
50
  requirements:
41
51
  - - ~>
@@ -43,10 +53,15 @@ dependencies:
43
53
  version: 1.0.0
44
54
  type: :development
45
55
  prerelease: false
46
- version_requirements: *70159646995840
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 1.0.0
47
62
  - !ruby/object:Gem::Dependency
48
63
  name: jeweler
49
- requirement: &70159646993360 !ruby/object:Gem::Requirement
64
+ requirement: !ruby/object:Gem::Requirement
50
65
  none: false
51
66
  requirements:
52
67
  - - ~>
@@ -54,10 +69,15 @@ dependencies:
54
69
  version: 1.6.4
55
70
  type: :development
56
71
  prerelease: false
57
- version_requirements: *70159646993360
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: 1.6.4
58
78
  - !ruby/object:Gem::Dependency
59
79
  name: shoulda
60
- requirement: &70159646992740 !ruby/object:Gem::Requirement
80
+ requirement: !ruby/object:Gem::Requirement
61
81
  none: false
62
82
  requirements:
63
83
  - - ~>
@@ -65,7 +85,12 @@ dependencies:
65
85
  version: 2.11.3
66
86
  type: :development
67
87
  prerelease: false
68
- version_requirements: *70159646992740
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: 2.11.3
69
94
  description: Simple HTTP client using Typheous, derived from the Riak client
70
95
  email: matt.knopp@gmail.com
71
96
  executables: []
@@ -99,9 +124,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
99
124
  - - ! '>='
100
125
  - !ruby/object:Gem::Version
101
126
  version: '0'
102
- segments:
103
- - 0
104
- hash: 2863491660694697364
105
127
  required_rubygems_version: !ruby/object:Gem::Requirement
106
128
  none: false
107
129
  requirements:
@@ -110,7 +132,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
110
132
  version: '0'
111
133
  requirements: []
112
134
  rubyforge_project:
113
- rubygems_version: 1.8.11
135
+ rubygems_version: 1.8.23
114
136
  signing_key:
115
137
  specification_version: 3
116
138
  summary: Simple HTTP client using Typheous, derived from the Riak client