songkick-transport 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -16,7 +16,7 @@ module Songkick
16
16
  def build_query_string(params, fully_encode = true, sanitize = false)
17
17
  return params if String === params
18
18
  pairs = []
19
- each_qs_param('', params) do |key, value|
19
+ each_qs_param('', params, fully_encode) do |key, value|
20
20
  value = SANITIZED_VALUE if sanitize and sanitize?(key)
21
21
  pairs << [key, value]
22
22
  end
@@ -30,19 +30,21 @@ module Songkick
30
30
  end
31
31
  end
32
32
 
33
- def each_qs_param(prefix, value, &block)
33
+ def each_qs_param(prefix, value, fully_encode = true, &block)
34
34
  case value
35
35
  when Array
36
- value.each { |e| each_qs_param(prefix + "[]", e, &block) }
36
+ value.each { |e| each_qs_param(prefix + "[]", e, fully_encode, &block) }
37
37
  when Hash
38
38
  value.each do |k,v|
39
- key = (prefix == '') ? CGI.escape(k.to_s) : prefix + "[#{CGI.escape k.to_s}]"
40
- each_qs_param(key, v, &block)
39
+ encoded = fully_encode ? CGI.escape(k.to_s) : k.to_s
40
+ key = (prefix == '') ? encoded : prefix + "[#{encoded}]"
41
+ each_qs_param(key, v, fully_encode, &block)
41
42
  end
42
43
  when Transport::IO
43
44
  block.call(prefix, value)
44
45
  else
45
- block.call(prefix, CGI.escape(value.to_s))
46
+ encoded = fully_encode ? CGI.escape(value.to_s) : value.to_s
47
+ block.call(prefix, encoded)
46
48
  end
47
49
  end
48
50
 
@@ -119,7 +119,7 @@ describe Songkick::Transport do
119
119
  let(:upload) { Songkick::Transport::IO.new(file, "image/jpeg", "songkick.png") }
120
120
 
121
121
  let :params do
122
- {:concert => {:file => upload, :foo => :bar}}
122
+ {:concert => {:file => upload, :foo => "me@thing.com"}}
123
123
  end
124
124
 
125
125
  let :expected_response do
@@ -127,7 +127,7 @@ describe Songkick::Transport do
127
127
  "filename" => "songkick.png",
128
128
  "method" => @http_method,
129
129
  "size" => 6694,
130
- "foo" => "bar"
130
+ "foo" => "me@thing.com"
131
131
  }
132
132
  end
133
133
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: songkick-transport
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-19 00:00:00.000000000 Z
12
+ date: 2013-04-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: multipart-post
@@ -151,7 +151,6 @@ files:
151
151
  - examples/loop.rb
152
152
  - examples/thread_safety.rb
153
153
  - examples/server.rb
154
- - examples/foo.rb
155
154
  - examples/example.rb
156
155
  - lib/songkick/transport/request.rb
157
156
  - lib/songkick/transport/rack_test.rb
@@ -200,3 +199,4 @@ signing_key:
200
199
  specification_version: 3
201
200
  summary: HTTP client abstraction for service clients
202
201
  test_files: []
202
+ has_rdoc:
data/examples/foo.rb DELETED
@@ -1,9 +0,0 @@
1
- require './lib/songkick/transport'
2
-
3
- t = Songkick::Transport::Curb.new 'localhost:4567'
4
- r = Songkick::Transport.report
5
-
6
- r.execute { t.get '/' }
7
-
8
- p r.first.duration
9
-