songkick-transport 1.10.3 → 1.11.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -87,7 +87,7 @@ module Songkick
87
87
  end
88
88
  sanitized_params = sanitized_params.inject({}) do |result, param|
89
89
  key, value = param
90
- if value.length > TRUNCATED_PARAM_LENGTH
90
+ if value.respond_to?(:length) && value.length > TRUNCATED_PARAM_LENGTH
91
91
  result[key] = "#{value[0...TRUNCATED_PARAM_LENGTH]}[TRUNCATED]"
92
92
  else
93
93
  result[key] = value
@@ -57,7 +57,13 @@ module Songkick
57
57
  end
58
58
 
59
59
  def self.get_endpoint_name
60
- @endpoint_name || (parent_service && parent_service.get_endpoint_name)
60
+ @endpoint_name || (parent_service && parent_service.get_endpoint_name) ||
61
+ raise("no endpoint specified for #{self}, call endpoint 'foo' inside #{self}")
62
+ end
63
+
64
+ def self.get_endpoint
65
+ Service.get_endpoints[self.get_endpoint_name] ||
66
+ raise("can't find endpoint for '#{self.get_endpoint_name}', should have called Songkick::Transport::Service.set_endpoints")
61
67
  end
62
68
 
63
69
  def self.get_timeout
@@ -89,16 +95,10 @@ module Songkick
89
95
  end
90
96
 
91
97
  def self.new_transport
92
- unless name = get_endpoint_name
93
- raise "no endpoint specified for #{self}, call endpoint 'foo' inside #{self}"
94
- end
95
- unless endpoint = Service.get_endpoints[name]
96
- raise "can't find endpoint for '#{name}', should have called Songkick::Transport::Service.set_endpoints"
97
- end
98
98
  unless user_agent = get_user_agent
99
99
  raise "no user agent specified for #{self}, call user_agent 'foo' inside #{self} or on Songkick::Transport::Service"
100
100
  end
101
- get_stub_transport || get_transport_layer.new(endpoint, { :user_agent => user_agent, :timeout => get_timeout }.merge(get_transport_layer_options))
101
+ get_stub_transport || get_transport_layer.new(self.get_endpoint, { :user_agent => user_agent, :timeout => get_timeout }.merge(get_transport_layer_options))
102
102
  end
103
103
 
104
104
  def self.with_headers(headers)
@@ -11,6 +11,37 @@ describe Songkick::Transport::Service do
11
11
  allow(http).to receive(:with_headers).and_return(http)
12
12
  end
13
13
 
14
+ class TestService < Songkick::Transport::Service
15
+ endpoint :foo
16
+ end
17
+
18
+ class TestServiceWithoutEndpointName < Songkick::Transport::Service
19
+ end
20
+
21
+ class TestServiceWithoutEndpoint < Songkick::Transport::Service
22
+ endpoint :bar
23
+ end
24
+
25
+ describe '#get_endpoint' do
26
+ it 'returns the endpoint for the given endpoint name' do
27
+ expect(TestService.get_endpoint).to eq('nonsuch:1111')
28
+ end
29
+
30
+ it 'raises an error if the endpoint does not exist in the given config' do
31
+ expect { TestServiceWithoutEndpoint.get_endpoint }.to raise_error
32
+ end
33
+ end
34
+
35
+ describe '#get_endpoint_name' do
36
+ it 'returns the endpoint name' do
37
+ expect(TestService.get_endpoint_name).to eq('foo')
38
+ end
39
+
40
+ it 'raises an error if the endpoint is not given' do
41
+ expect { TestServiceWithoutEndpointName.get_endpoint_name }.to raise_error
42
+ end
43
+ end
44
+
14
45
  describe "given a Service class hierarchy" do
15
46
  class A < Songkick::Transport::Service
16
47
  endpoint :foo
metadata CHANGED
@@ -1,7 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: songkick-transport
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.10.3
4
+ version: 1.11.0
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Daniel Lucraft
@@ -11,149 +12,170 @@ authors:
11
12
  - Paul Lawson
12
13
  - Sabina Bejasa-Dimmock
13
14
  - Paul Springett
15
+ - Andy Mitchell
14
16
  autorequire:
15
17
  bindir: bin
16
18
  cert_chain: []
17
- date: 2016-02-22 00:00:00.000000000 Z
19
+ date: 2016-05-25 00:00:00.000000000 Z
18
20
  dependencies:
19
21
  - !ruby/object:Gem::Dependency
20
22
  name: multipart-post
21
23
  requirement: !ruby/object:Gem::Requirement
24
+ none: false
22
25
  requirements:
23
- - - '>='
26
+ - - ! '>='
24
27
  - !ruby/object:Gem::Version
25
28
  version: 1.1.0
26
29
  type: :runtime
27
30
  prerelease: false
28
31
  version_requirements: !ruby/object:Gem::Requirement
32
+ none: false
29
33
  requirements:
30
- - - '>='
34
+ - - ! '>='
31
35
  - !ruby/object:Gem::Version
32
36
  version: 1.1.0
33
37
  - !ruby/object:Gem::Dependency
34
38
  name: yajl-ruby
35
39
  requirement: !ruby/object:Gem::Requirement
40
+ none: false
36
41
  requirements:
37
- - - '>='
42
+ - - ! '>='
38
43
  - !ruby/object:Gem::Version
39
44
  version: 1.1.0
40
45
  type: :runtime
41
46
  prerelease: false
42
47
  version_requirements: !ruby/object:Gem::Requirement
48
+ none: false
43
49
  requirements:
44
- - - '>='
50
+ - - ! '>='
45
51
  - !ruby/object:Gem::Version
46
52
  version: 1.1.0
47
53
  - !ruby/object:Gem::Dependency
48
54
  name: activesupport
49
55
  requirement: !ruby/object:Gem::Requirement
56
+ none: false
50
57
  requirements:
51
- - - '>='
58
+ - - ! '>='
52
59
  - !ruby/object:Gem::Version
53
60
  version: 3.0.0
54
61
  type: :development
55
62
  prerelease: false
56
63
  version_requirements: !ruby/object:Gem::Requirement
64
+ none: false
57
65
  requirements:
58
- - - '>='
66
+ - - ! '>='
59
67
  - !ruby/object:Gem::Version
60
68
  version: 3.0.0
61
69
  - !ruby/object:Gem::Dependency
62
70
  name: curb
63
71
  requirement: !ruby/object:Gem::Requirement
72
+ none: false
64
73
  requirements:
65
- - - '>='
74
+ - - ! '>='
66
75
  - !ruby/object:Gem::Version
67
76
  version: 0.3.0
68
77
  type: :development
69
78
  prerelease: false
70
79
  version_requirements: !ruby/object:Gem::Requirement
80
+ none: false
71
81
  requirements:
72
- - - '>='
82
+ - - ! '>='
73
83
  - !ruby/object:Gem::Version
74
84
  version: 0.3.0
75
85
  - !ruby/object:Gem::Dependency
76
86
  name: httparty
77
87
  requirement: !ruby/object:Gem::Requirement
88
+ none: false
78
89
  requirements:
79
- - - '>='
90
+ - - ! '>='
80
91
  - !ruby/object:Gem::Version
81
92
  version: 0.8.0
82
93
  type: :development
83
94
  prerelease: false
84
95
  version_requirements: !ruby/object:Gem::Requirement
96
+ none: false
85
97
  requirements:
86
- - - '>='
98
+ - - ! '>='
87
99
  - !ruby/object:Gem::Version
88
100
  version: 0.8.0
89
101
  - !ruby/object:Gem::Dependency
90
102
  name: rack-test
91
103
  requirement: !ruby/object:Gem::Requirement
104
+ none: false
92
105
  requirements:
93
- - - '>='
106
+ - - ! '>='
94
107
  - !ruby/object:Gem::Version
95
108
  version: 0.4.0
96
109
  type: :development
97
110
  prerelease: false
98
111
  version_requirements: !ruby/object:Gem::Requirement
112
+ none: false
99
113
  requirements:
100
- - - '>='
114
+ - - ! '>='
101
115
  - !ruby/object:Gem::Version
102
116
  version: 0.4.0
103
117
  - !ruby/object:Gem::Dependency
104
118
  name: rake
105
119
  requirement: !ruby/object:Gem::Requirement
120
+ none: false
106
121
  requirements:
107
- - - '>='
122
+ - - ! '>='
108
123
  - !ruby/object:Gem::Version
109
124
  version: '0'
110
125
  type: :development
111
126
  prerelease: false
112
127
  version_requirements: !ruby/object:Gem::Requirement
128
+ none: false
113
129
  requirements:
114
- - - '>='
130
+ - - ! '>='
115
131
  - !ruby/object:Gem::Version
116
132
  version: '0'
117
133
  - !ruby/object:Gem::Dependency
118
134
  name: rspec
119
135
  requirement: !ruby/object:Gem::Requirement
136
+ none: false
120
137
  requirements:
121
- - - '>='
138
+ - - ! '>='
122
139
  - !ruby/object:Gem::Version
123
140
  version: '0'
124
141
  type: :development
125
142
  prerelease: false
126
143
  version_requirements: !ruby/object:Gem::Requirement
144
+ none: false
127
145
  requirements:
128
- - - '>='
146
+ - - ! '>='
129
147
  - !ruby/object:Gem::Version
130
148
  version: '0'
131
149
  - !ruby/object:Gem::Dependency
132
150
  name: sinatra
133
151
  requirement: !ruby/object:Gem::Requirement
152
+ none: false
134
153
  requirements:
135
- - - '>='
154
+ - - ! '>='
136
155
  - !ruby/object:Gem::Version
137
156
  version: '0'
138
157
  type: :development
139
158
  prerelease: false
140
159
  version_requirements: !ruby/object:Gem::Requirement
160
+ none: false
141
161
  requirements:
142
- - - '>='
162
+ - - ! '>='
143
163
  - !ruby/object:Gem::Version
144
164
  version: '0'
145
165
  - !ruby/object:Gem::Dependency
146
166
  name: thin
147
167
  requirement: !ruby/object:Gem::Requirement
168
+ none: false
148
169
  requirements:
149
- - - '>='
170
+ - - ! '>='
150
171
  - !ruby/object:Gem::Version
151
172
  version: '0'
152
173
  type: :development
153
174
  prerelease: false
154
175
  version_requirements: !ruby/object:Gem::Requirement
176
+ none: false
155
177
  requirements:
156
- - - '>='
178
+ - - ! '>='
157
179
  - !ruby/object:Gem::Version
158
180
  version: '0'
159
181
  description: HTTP client abstraction for service clients
@@ -164,39 +186,38 @@ extra_rdoc_files:
164
186
  - README.rdoc
165
187
  files:
166
188
  - README.rdoc
167
- - examples/tcp_server.rb
168
189
  - examples/example.rb
169
- - examples/thread_safety.rb
170
190
  - examples/loop.rb
171
191
  - examples/server.rb
172
- - lib/songkick/transport/reporting.rb
173
- - lib/songkick/transport/rack_test.rb
174
- - lib/songkick/transport/headers.rb
175
- - lib/songkick/transport/response.rb
192
+ - examples/tcp_server.rb
193
+ - examples/thread_safety.rb
194
+ - lib/songkick/transport/authentication.rb
195
+ - lib/songkick/transport/base.rb
176
196
  - lib/songkick/transport/curb.rb
197
+ - lib/songkick/transport/headers.rb
177
198
  - lib/songkick/transport/http_error.rb
178
199
  - lib/songkick/transport/httparty.rb
179
- - lib/songkick/transport/service.rb
200
+ - lib/songkick/transport/rack_test.rb
201
+ - lib/songkick/transport/reporting.rb
180
202
  - lib/songkick/transport/request.rb
181
- - lib/songkick/transport/authentication.rb
203
+ - lib/songkick/transport/response.rb
182
204
  - lib/songkick/transport/serialization.rb
205
+ - lib/songkick/transport/service.rb
183
206
  - lib/songkick/transport/upstream_error.rb
184
- - lib/songkick/transport/base.rb
185
207
  - lib/songkick/transport.rb
186
- - spec/spec_helper.rb
187
- - spec/songkick/transport_spec.rb
188
- - spec/songkick/transport/curb_spec.rb
189
- - spec/songkick/transport/service_spec.rb
190
- - spec/songkick/transport/request_spec.rb
191
208
  - spec/songkick/transport/authentication_spec.rb
192
- - spec/songkick/transport/httparty_spec.rb
193
209
  - spec/songkick/transport/base_spec.rb
210
+ - spec/songkick/transport/curb_spec.rb
211
+ - spec/songkick/transport/httparty_spec.rb
212
+ - spec/songkick/transport/request_spec.rb
194
213
  - spec/songkick/transport/response_spec.rb
214
+ - spec/songkick/transport/service_spec.rb
215
+ - spec/songkick/transport_spec.rb
216
+ - spec/spec_helper.rb
195
217
  - lib/songkick/transport/html_report.html.erb
196
218
  homepage: http://github.com/songkick/transport
197
219
  licenses:
198
220
  - MIT
199
- metadata: {}
200
221
  post_install_message:
201
222
  rdoc_options:
202
223
  - --main
@@ -204,19 +225,21 @@ rdoc_options:
204
225
  require_paths:
205
226
  - lib
206
227
  required_ruby_version: !ruby/object:Gem::Requirement
228
+ none: false
207
229
  requirements:
208
- - - '>='
230
+ - - ! '>='
209
231
  - !ruby/object:Gem::Version
210
232
  version: 1.8.7
211
233
  required_rubygems_version: !ruby/object:Gem::Requirement
234
+ none: false
212
235
  requirements:
213
- - - '>='
236
+ - - ! '>='
214
237
  - !ruby/object:Gem::Version
215
238
  version: '0'
216
239
  requirements: []
217
240
  rubyforge_project:
218
- rubygems_version: 2.1.11
241
+ rubygems_version: 1.8.23
219
242
  signing_key:
220
- specification_version: 4
243
+ specification_version: 3
221
244
  summary: HTTP client abstraction for service clients
222
245
  test_files: []
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: f78ef6ef6b0a53938d0f7c9764d2b8731f6e598c
4
- data.tar.gz: 85040828b85d89e8a3899281fb8cfde2fcc5fd3f
5
- SHA512:
6
- metadata.gz: fcf4ca0a093d8f8762b4758fdee5a97a2ed052781367e41eb5c62aa443adc8bab3aedaaa69f0437e36d7447c866dee1ebff89b1e22031a7cb5ac2303eec69576
7
- data.tar.gz: 017de61ca05657be0c344a3365039d23982324ea8d3137e01d012ed2f0b72d6c53082ad6927de7687969d15f9714d74e2e7cf55d11f97532b8e8e3967e45ff51