leipzig 0.0.4 → 0.0.5

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 CHANGED
@@ -56,15 +56,22 @@ Leipzig::District.new(key).find_streets
56
56
 
57
57
  ## Running the tests
58
58
 
59
+ One can choose to run either the fake specs or the real world specs, whereas the latter ones actually calling the
60
+ API:
61
+
59
62
  ```bash
60
63
  $ bundle
61
- $ API_KEY='my-key' rake
64
+
65
+ $ # Mocked API (default)
66
+ $ rake spec
67
+
68
+ $ # Real world API
69
+ $ API_KEY='my-key' API_TYPE='real' rake spec
62
70
  ```
63
71
 
64
72
  ## Todo
65
73
 
66
74
  * Refactoring
67
- * Maybe model layer instead of OpenStruct?
68
75
 
69
76
  ## License
70
77
 
data/Rakefile CHANGED
@@ -5,6 +5,7 @@ Bundler::GemHelper.install_tasks
5
5
 
6
6
  desc 'Run unit specs'
7
7
  RSpec::Core::RakeTask.new('spec') do |t|
8
+ ENV['API_TYPE'] ||= 'mock'
8
9
  t.pattern = 'spec/{*_spec.rb,leipzig/**/*_spec.rb}'
9
10
  end
10
11
 
data/leipzig.gemspec CHANGED
@@ -6,17 +6,17 @@ Gem::Specification.new do |gem|
6
6
  gem.email = ["info@mario-behrendt.de"]
7
7
  gem.description = %q{Tiny client for API Leipzig}
8
8
  gem.summary = %q{Tiny client for API Leipzig}
9
- gem.homepage = ""
9
+ gem.homepage = "http://github.com/mbehrendt/leipzig.rb"
10
10
 
11
11
  gem.files = `git ls-files`.split($\)
12
- gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
12
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
13
  gem.name = "leipzig"
15
14
  gem.require_paths = ["lib"]
16
15
  gem.version = Leipzig::VERSION
17
16
 
18
- gem.add_dependency 'rest-client'
17
+ gem.add_dependency 'rest-client', '>= 1.6.7'
19
18
 
20
- gem.add_development_dependency 'rspec'
21
- gem.add_development_dependency 'rake'
19
+ gem.add_development_dependency 'rspec', '~> 2.12.0'
20
+ gem.add_development_dependency 'rake', '~> 10.0.3'
21
+ gem.add_development_dependency 'webmock', '~> 1.9.0'
22
22
  end
@@ -34,11 +34,9 @@ module Leipzig
34
34
  # @return [Array] Result set of `request` method
35
35
  def find(type, conditions = {})
36
36
  raise "Type #{type} is invalid" unless types.include?(type.to_sym)
37
- uri = "#{API_URL}/#{resource}/#{type}"
38
37
 
39
- if has_search_param?(conditions)
40
- uri += '/search'
41
- end
38
+ uri = "#{API_URL}/#{resource}/#{type}"
39
+ uri += '/search' if includes_search_param?(conditions)
42
40
 
43
41
  request(uri, conditions)
44
42
  end
@@ -47,7 +45,7 @@ module Leipzig
47
45
  #
48
46
  # @param [Hash] Conditions to check
49
47
  # @return [Boolean] True if search param was found
50
- def has_search_param?(conditions)
48
+ def includes_search_param?(conditions)
51
49
  conditions.keys.select { |key| !KEYWORDS.include?(key) }.any?
52
50
  end
53
51
 
@@ -76,7 +74,7 @@ module Leipzig
76
74
  def request(uri, conditions)
77
75
  result = JSON.parse RestClient.get(uri, :params => @conditions.merge(conditions))
78
76
 
79
- if result.has_key? "error"
77
+ if result.has_key? 'error'
80
78
  raise "API returned error for uri '#{uri}': #{result['error']}"
81
79
  end
82
80
 
@@ -1,3 +1,3 @@
1
1
  module Leipzig
2
- VERSION = '0.0.4'
2
+ VERSION = '0.0.5'
3
3
  end
Binary file
@@ -0,0 +1,69 @@
1
+ require 'leipzig/mediahandbook'
2
+ require 'leipzig/calendar'
3
+ require 'leipzig/district'
4
+ require 'webmock/rspec'
5
+ require_relative 'spec_helper'
6
+ require_relative 'response_builder'
7
+
8
+ describe 'Client' do
9
+ before do
10
+ if realworld_spec?
11
+ WebMock.allow_net_connect!
12
+ else
13
+ stub_request(:get, /#{Leipzig::Client::API_URL}*/).to_return do |request|
14
+ { :body => ResponseBuilder.new.response(request.uri.query_values) }
15
+ end
16
+ end
17
+
18
+ key = ENV['API_KEY'] ? ENV['API_KEY'] : 'mock'
19
+
20
+ @clients = Array.new
21
+ @clients << Leipzig::Mediahandbook.new(key)
22
+ @clients << Leipzig::Calendar.new(key)
23
+ @clients << Leipzig::District.new(key)
24
+ end
25
+
26
+ it 'makes API key accessible' do
27
+ @clients.each { |client| client.should respond_to(:api_key) }
28
+ end
29
+
30
+ it 'responds to all types with according find method' do
31
+ @clients.each do |client|
32
+ client.class::TYPES.each do |type|
33
+ client.should respond_to("find_#{type}")
34
+ end
35
+ end
36
+ end
37
+
38
+ it 'returns Array of OpenStructs for find_* methods' do
39
+ @clients.each do |client|
40
+ type = client.class::TYPES.first
41
+ data = client.send("find_#{type}".to_sym)
42
+
43
+ data.should be_instance_of(Array)
44
+ data.size.should eq(10) # Default limit
45
+ data.each { |entry| entry.should be_instance_of(OpenStruct) }
46
+ end
47
+ end
48
+
49
+ it 'takes search and limit parameters into account' do
50
+ zip = '04317'
51
+ limit = 2
52
+
53
+ data = @clients.first.find_companies(:limit => limit, :postcode => zip)
54
+ data.size.should eq(limit)
55
+ data.each { |company| company.postcode.should eq(zip) }
56
+ end
57
+
58
+ it 'raises exception if invalid key is used' do
59
+ if realworld_spec?
60
+ lambda { Leipzig::Mediahandbook.new('wrong').find_companies }.should raise_error
61
+ end
62
+ end
63
+
64
+ it 'raises exception if undefined method is called' do
65
+ @clients.each do |client|
66
+ lambda { client.find_something }.should raise_error
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,414 @@
1
+ {
2
+ "data": [
3
+ {
4
+ "city": "Leipzig",
5
+ "created_at": "2011-02-23T03:06:15+01:00",
6
+ "email_primary": "info@univerlag-leipzig.de",
7
+ "email_secondary": null,
8
+ "fax_primary": null,
9
+ "fax_secondary": null,
10
+ "housenumber": 41,
11
+ "housenumber_additional": null,
12
+ "id": 1,
13
+ "main_activity": null,
14
+ "main_branch_id": 17,
15
+ "mkw_branch_id": null,
16
+ "mobile_primary": null,
17
+ "mobile_secondary": null,
18
+ "name": "Leipziger Universitätsverlag GmbH und Akademische Verlagsanstalt AVA",
19
+ "old_id": 3,
20
+ "past_customers": null,
21
+ "phone_primary": "+49 341 9900440",
22
+ "phone_secondary": null,
23
+ "postcode": "04317",
24
+ "products": null,
25
+ "resources": null,
26
+ "street": "Oststraße",
27
+ "sub_market_id": 3,
28
+ "updated_at": "2011-03-14T17:47:47+01:00",
29
+ "url_primary": "http://www.univerlag-leipzig.de",
30
+ "url_secondary": "http://www.univerlag-leipzig.de",
31
+ "sub_branches": [
32
+ 23
33
+ ],
34
+ "people": [
35
+ 1,
36
+ 2
37
+ ]
38
+ },
39
+ {
40
+ "city": "Leipzig",
41
+ "created_at": "2011-02-23T03:06:17+01:00",
42
+ "email_primary": "hallo@frauenkultur-leipzig.de",
43
+ "email_secondary": null,
44
+ "fax_primary": null,
45
+ "fax_secondary": null,
46
+ "housenumber": 51,
47
+ "housenumber_additional": null,
48
+ "id": 4,
49
+ "main_activity": null,
50
+ "main_branch_id": 55,
51
+ "mkw_branch_id": null,
52
+ "mobile_primary": null,
53
+ "mobile_secondary": null,
54
+ "name": "Frauenkultur e.V. Leipzig",
55
+ "old_id": 10,
56
+ "past_customers": null,
57
+ "phone_primary": "+49 341 2130030",
58
+ "phone_secondary": null,
59
+ "postcode": "04317",
60
+ "products": null,
61
+ "resources": null,
62
+ "street": "Windscheidstraße",
63
+ "sub_market_id": 8,
64
+ "updated_at": "2011-02-23T03:06:17+01:00",
65
+ "url_primary": "http://www.frauenkultur-leipzig.de",
66
+ "url_secondary": "http://www.frauenkultur-leipzig.de",
67
+ "sub_branches": [
68
+ 56,
69
+ 57
70
+ ],
71
+ "people": [
72
+ 7,
73
+ 8
74
+ ]
75
+ },
76
+ {
77
+ "city": "Leipzig",
78
+ "created_at": "2011-02-23T03:06:18+01:00",
79
+ "email_primary": "stadtbib@leipzig.de",
80
+ "email_secondary": null,
81
+ "fax_primary": null,
82
+ "fax_secondary": null,
83
+ "housenumber": 44,
84
+ "housenumber_additional": null,
85
+ "id": 6,
86
+ "main_activity": null,
87
+ "main_branch_id": 58,
88
+ "mkw_branch_id": null,
89
+ "mobile_primary": null,
90
+ "mobile_secondary": null,
91
+ "name": "Leipziger Städtische Bibliotheken",
92
+ "old_id": 13,
93
+ "past_customers": null,
94
+ "phone_primary": "+49 341 1235343",
95
+ "phone_secondary": null,
96
+ "postcode": "04229",
97
+ "products": null,
98
+ "resources": null,
99
+ "street": "Nonnenstraße",
100
+ "sub_market_id": 3,
101
+ "updated_at": "2011-02-23T03:06:18+01:00",
102
+ "url_primary": "http://www.leipzig.de/stadtbib",
103
+ "url_secondary": "http://www.leipzig.de/stadtbib",
104
+ "people": [
105
+ 11,
106
+ 12
107
+ ]
108
+ },
109
+ {
110
+ "city": "Leipzig",
111
+ "created_at": "2011-02-23T03:06:23+01:00",
112
+ "email_primary": "direktion@ub.uni-leipzig.de",
113
+ "email_secondary": null,
114
+ "fax_primary": null,
115
+ "fax_secondary": null,
116
+ "housenumber": 6,
117
+ "housenumber_additional": null,
118
+ "id": 13,
119
+ "main_activity": null,
120
+ "main_branch_id": 58,
121
+ "mkw_branch_id": null,
122
+ "mobile_primary": null,
123
+ "mobile_secondary": null,
124
+ "name": "Universität Leipzig Universitätsbibliothek",
125
+ "old_id": 30,
126
+ "past_customers": null,
127
+ "phone_primary": "+49 341 9730500",
128
+ "phone_secondary": " 49 341 9730502",
129
+ "postcode": "04107",
130
+ "products": null,
131
+ "resources": null,
132
+ "street": "Beethovenstraße",
133
+ "sub_market_id": 3,
134
+ "updated_at": "2011-02-23T03:06:23+01:00",
135
+ "url_primary": "http://www.ub.uni-leipzig.de",
136
+ "url_secondary": "http://www.ub.uni-leipzig.de",
137
+ "people": [
138
+ 25,
139
+ 26,
140
+ 27
141
+ ]
142
+ },
143
+ {
144
+ "city": "Leipzig",
145
+ "created_at": "2011-02-23T03:06:24+01:00",
146
+ "email_primary": "leipzig@schmidt-roemhild.de",
147
+ "email_secondary": null,
148
+ "fax_primary": null,
149
+ "fax_secondary": null,
150
+ "housenumber": 2,
151
+ "housenumber_additional": null,
152
+ "id": 17,
153
+ "main_activity": null,
154
+ "main_branch_id": 20,
155
+ "mkw_branch_id": null,
156
+ "mobile_primary": null,
157
+ "mobile_secondary": null,
158
+ "name": "Schmidt-Römhild Verlagsgesellschaft mbH Leipzig",
159
+ "old_id": 39,
160
+ "past_customers": null,
161
+ "phone_primary": "+49 341 904850",
162
+ "phone_secondary": null,
163
+ "postcode": "04129",
164
+ "products": null,
165
+ "resources": null,
166
+ "street": "Coppistraße",
167
+ "sub_market_id": 3,
168
+ "updated_at": "2011-02-23T03:06:24+01:00",
169
+ "url_primary": "http://www.schmidt-roemhild.de",
170
+ "url_secondary": "http://www.schmidt-roemhild.de",
171
+ "sub_branches": [
172
+ 23,
173
+ 24
174
+ ],
175
+ "people": [
176
+ 33,
177
+ 34
178
+ ]
179
+ },
180
+ {
181
+ "city": "Leipzig",
182
+ "created_at": "2011-02-23T03:06:24+01:00",
183
+ "email_primary": "rektor@htwk-leipzig.de",
184
+ "email_secondary": null,
185
+ "fax_primary": null,
186
+ "fax_secondary": null,
187
+ "housenumber": 132,
188
+ "housenumber_additional": null,
189
+ "id": 18,
190
+ "main_activity": null,
191
+ "main_branch_id": 59,
192
+ "mkw_branch_id": null,
193
+ "mobile_primary": null,
194
+ "mobile_secondary": null,
195
+ "name": "HTWK Hochschule für Technik Wirtschaft und Kultur Leipzig",
196
+ "old_id": 40,
197
+ "past_customers": null,
198
+ "phone_primary": "+49 341 30766305",
199
+ "phone_secondary": null,
200
+ "postcode": "04277",
201
+ "products": null,
202
+ "resources": null,
203
+ "street": "Karl-Liebknecht-Straße",
204
+ "sub_market_id": null,
205
+ "updated_at": "2011-02-23T03:06:24+01:00",
206
+ "url_primary": "http://www.htwk-leipzig.de",
207
+ "url_secondary": "http://www.htwk-leipzig.de",
208
+ "people": [
209
+ 35,
210
+ 36
211
+ ]
212
+ },
213
+ {
214
+ "city": null,
215
+ "created_at": "2011-02-23T03:06:24+01:00",
216
+ "email_primary": null,
217
+ "email_secondary": null,
218
+ "fax_primary": null,
219
+ "fax_secondary": null,
220
+ "housenumber": null,
221
+ "housenumber_additional": null,
222
+ "id": 20,
223
+ "main_activity": null,
224
+ "main_branch_id": null,
225
+ "mkw_branch_id": null,
226
+ "mobile_primary": null,
227
+ "mobile_secondary": null,
228
+ "name": "Leipziger Verlags- und Druckereigesellschaft mbH ",
229
+ "old_id": 42,
230
+ "past_customers": null,
231
+ "phone_primary": null,
232
+ "phone_secondary": null,
233
+ "postcode": null,
234
+ "products": null,
235
+ "resources": null,
236
+ "street": null,
237
+ "sub_market_id": 4,
238
+ "updated_at": "2011-02-23T03:06:24+01:00",
239
+ "url_primary": null,
240
+ "url_secondary": null
241
+ },
242
+ {
243
+ "city": null,
244
+ "created_at": "2011-02-23T03:06:24+01:00",
245
+ "email_primary": null,
246
+ "email_secondary": null,
247
+ "fax_primary": null,
248
+ "fax_secondary": null,
249
+ "housenumber": null,
250
+ "housenumber_additional": null,
251
+ "id": 22,
252
+ "main_activity": null,
253
+ "main_branch_id": null,
254
+ "mkw_branch_id": null,
255
+ "mobile_primary": null,
256
+ "mobile_secondary": null,
257
+ "name": "Radio Leipzig BCS Broadcast Sachsen GmbH ",
258
+ "old_id": 44,
259
+ "past_customers": null,
260
+ "phone_primary": null,
261
+ "phone_secondary": null,
262
+ "postcode": null,
263
+ "products": null,
264
+ "resources": null,
265
+ "street": null,
266
+ "sub_market_id": 9,
267
+ "updated_at": "2011-02-23T03:06:24+01:00",
268
+ "url_primary": null,
269
+ "url_secondary": null
270
+ },
271
+ {
272
+ "city": "Zwenkau",
273
+ "created_at": "2011-02-23T03:06:24+01:00",
274
+ "email_primary": "info@oan.de",
275
+ "email_secondary": null,
276
+ "fax_primary": null,
277
+ "fax_secondary": null,
278
+ "housenumber": 26,
279
+ "housenumber_additional": " -30",
280
+ "id": 26,
281
+ "main_activity": null,
282
+ "main_branch_id": 19,
283
+ "mkw_branch_id": null,
284
+ "mobile_primary": null,
285
+ "mobile_secondary": null,
286
+ "name": "Offizin Andersen Nexö Leipzig GmbH",
287
+ "old_id": 53,
288
+ "past_customers": null,
289
+ "phone_primary": "+49 34203 37800",
290
+ "phone_secondary": null,
291
+ "postcode": "04442",
292
+ "products": null,
293
+ "resources": null,
294
+ "street": "Spenglerallee",
295
+ "sub_market_id": 3,
296
+ "updated_at": "2011-02-23T03:06:24+01:00",
297
+ "url_primary": "http://www.oan.de",
298
+ "url_secondary": "http://www.oan.de",
299
+ "sub_branches": [
300
+ 22,
301
+ 24
302
+ ],
303
+ "people": [
304
+ 49,
305
+ 50
306
+ ]
307
+ },
308
+ {
309
+ "city": "Leipzig",
310
+ "created_at": "2011-02-23T03:06:24+01:00",
311
+ "email_primary": "ffl-leipzig@web.de",
312
+ "email_secondary": null,
313
+ "fax_primary": null,
314
+ "fax_secondary": null,
315
+ "housenumber": 28,
316
+ "housenumber_additional": " (Haus des Buches)",
317
+ "id": 27,
318
+ "main_activity": null,
319
+ "main_branch_id": 57,
320
+ "mkw_branch_id": null,
321
+ "mobile_primary": null,
322
+ "mobile_secondary": null,
323
+ "name": "Förderkreis Freie Literaturgesellschaft e.V. Sitz Leipzig",
324
+ "old_id": 54,
325
+ "past_customers": null,
326
+ "phone_primary": "+49 341 9954721",
327
+ "phone_secondary": null,
328
+ "postcode": "04103",
329
+ "products": null,
330
+ "resources": null,
331
+ "street": "Gerichtsweg",
332
+ "sub_market_id": 3,
333
+ "updated_at": "2011-02-23T03:06:24+01:00",
334
+ "url_primary": null,
335
+ "url_secondary": null,
336
+ "people": [
337
+ 51,
338
+ 52
339
+ ]
340
+ },
341
+ {
342
+ "city": "Leipzig",
343
+ "created_at": "2011-02-23T03:06:24+01:00",
344
+ "email_primary": "kartenbestellung@leipzigerbrettl.de",
345
+ "email_secondary": null,
346
+ "fax_primary": null,
347
+ "fax_secondary": null,
348
+ "housenumber": 12,
349
+ "housenumber_additional": null,
350
+ "id": 36,
351
+ "main_activity": null,
352
+ "main_branch_id": 55,
353
+ "mkw_branch_id": null,
354
+ "mobile_primary": null,
355
+ "mobile_secondary": null,
356
+ "name": "Kabarett Leipziger Brettl - Kleine Wintergartenbühne im Gambrinus",
357
+ "old_id": 68,
358
+ "past_customers": null,
359
+ "phone_primary": "+49 341 9613547",
360
+ "phone_secondary": null,
361
+ "postcode": "04177",
362
+ "products": null,
363
+ "resources": null,
364
+ "street": "Odermannstraße",
365
+ "sub_market_id": 7,
366
+ "updated_at": "2011-02-23T03:06:24+01:00",
367
+ "url_primary": "http://www.leipzigerbrettl.de",
368
+ "url_secondary": "http://www.leipzigerbrettl.de",
369
+ "people": [
370
+ 69,
371
+ 70
372
+ ]
373
+ },
374
+ {
375
+ "city": "Espenhain",
376
+ "created_at": "2011-02-23T03:06:25+01:00",
377
+ "email_primary": "uhaft@lkg-service.de",
378
+ "email_secondary": null,
379
+ "fax_primary": null,
380
+ "fax_secondary": null,
381
+ "housenumber": 1,
382
+ "housenumber_additional": " -12",
383
+ "id": 54,
384
+ "main_activity": null,
385
+ "main_branch_id": 23,
386
+ "mkw_branch_id": null,
387
+ "mobile_primary": null,
388
+ "mobile_secondary": null,
389
+ "name": "LKG Leipziger Kommissions- und Großbuchhandelsgesellschaft mbH",
390
+ "old_id": 94,
391
+ "past_customers": null,
392
+ "phone_primary": "+49 34206 650",
393
+ "phone_secondary": null,
394
+ "postcode": "04579",
395
+ "products": null,
396
+ "resources": null,
397
+ "street": "An der Südspitze",
398
+ "sub_market_id": 3,
399
+ "updated_at": "2011-02-23T03:06:25+01:00",
400
+ "url_primary": "http://www.lkg-va.de",
401
+ "url_secondary": "http://www.lkg-va.de",
402
+ "sub_branches": [
403
+ 24
404
+ ],
405
+ "people": [
406
+ 100,
407
+ 101
408
+ ]
409
+ }
410
+ ],
411
+ "paging": {
412
+ "next": "http://www.apileipzig.de/api/v1/mediahandbook/companies/search?api_key=1tmNnlYnUkHaRVacsS6o&limit=12&name=leipzig&offset=12"
413
+ }
414
+ }
@@ -0,0 +1,24 @@
1
+ require 'json'
2
+
3
+ class ResponseBuilder
4
+ DATA_FILE = File.expand_path('../companies.json', __FILE__)
5
+ KEYS = %w{name api_key limit offset format}
6
+
7
+ def initialize
8
+ @json = JSON.parse(File.read(DATA_FILE), :symbolize_names => true)
9
+ end
10
+
11
+ def response(params)
12
+ params = params.inject({}) { |param,(k,v)| param[k.to_sym] = v; param }
13
+ data = @json[:data]
14
+
15
+ if params.has_key?(:limit) && data.size > params[:limit].to_i
16
+ data = data.first params[:limit].to_i
17
+ end
18
+
19
+ conditions = params.reject { |key| KEYS.include? key.to_s }
20
+ @json[:data] = data.select { |e| (conditions.to_a - e.to_a).empty? }
21
+
22
+ JSON.dump(@json)
23
+ end
24
+ end
@@ -0,0 +1,5 @@
1
+ require 'support/helpers'
2
+
3
+ RSpec.configure do |config|
4
+ config.include LeipzigHelpers
5
+ end
@@ -0,0 +1,5 @@
1
+ module LeipzigHelpers
2
+ def realworld_spec?
3
+ 'real' == ENV['API_TYPE']
4
+ end
5
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: leipzig
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
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: 2012-12-22 00:00:00.000000000 Z
12
+ date: 2012-12-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rest-client
@@ -18,7 +18,7 @@ dependencies:
18
18
  requirements:
19
19
  - - ! '>='
20
20
  - !ruby/object:Gem::Version
21
- version: '0'
21
+ version: 1.6.7
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
@@ -26,39 +26,55 @@ dependencies:
26
26
  requirements:
27
27
  - - ! '>='
28
28
  - !ruby/object:Gem::Version
29
- version: '0'
29
+ version: 1.6.7
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: rspec
32
32
  requirement: !ruby/object:Gem::Requirement
33
33
  none: false
34
34
  requirements:
35
- - - ! '>='
35
+ - - ~>
36
36
  - !ruby/object:Gem::Version
37
- version: '0'
37
+ version: 2.12.0
38
38
  type: :development
39
39
  prerelease: false
40
40
  version_requirements: !ruby/object:Gem::Requirement
41
41
  none: false
42
42
  requirements:
43
- - - ! '>='
43
+ - - ~>
44
44
  - !ruby/object:Gem::Version
45
- version: '0'
45
+ version: 2.12.0
46
46
  - !ruby/object:Gem::Dependency
47
47
  name: rake
48
48
  requirement: !ruby/object:Gem::Requirement
49
49
  none: false
50
50
  requirements:
51
- - - ! '>='
51
+ - - ~>
52
52
  - !ruby/object:Gem::Version
53
- version: '0'
53
+ version: 10.0.3
54
54
  type: :development
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  none: false
58
58
  requirements:
59
- - - ! '>='
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 10.0.3
62
+ - !ruby/object:Gem::Dependency
63
+ name: webmock
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: 1.9.0
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
60
76
  - !ruby/object:Gem::Version
61
- version: '0'
77
+ version: 1.9.0
62
78
  description: Tiny client for API Leipzig
63
79
  email:
64
80
  - info@mario-behrendt.de
@@ -79,10 +95,14 @@ files:
79
95
  - lib/leipzig/district.rb
80
96
  - lib/leipzig/mediahandbook.rb
81
97
  - lib/leipzig/version.rb
82
- - spec/leipzig/mediahandbook_spec.rb
98
+ - spec/leipzig/.DS_Store
99
+ - spec/leipzig/client_spec.rb
100
+ - spec/leipzig/companies.json
101
+ - spec/leipzig/response_builder.rb
83
102
  - spec/leipzig/spec_helper.rb
84
103
  - spec/leipzig/version_spec.rb
85
- homepage: ''
104
+ - spec/support/helpers.rb
105
+ homepage: http://github.com/mbehrendt/leipzig.rb
86
106
  licenses: []
87
107
  post_install_message:
88
108
  rdoc_options: []
@@ -96,7 +116,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
96
116
  version: '0'
97
117
  segments:
98
118
  - 0
99
- hash: 1076362203260376975
119
+ hash: -2127133567103634922
100
120
  required_rubygems_version: !ruby/object:Gem::Requirement
101
121
  none: false
102
122
  requirements:
@@ -105,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
105
125
  version: '0'
106
126
  segments:
107
127
  - 0
108
- hash: 1076362203260376975
128
+ hash: -2127133567103634922
109
129
  requirements: []
110
130
  rubyforge_project:
111
131
  rubygems_version: 1.8.24
@@ -113,6 +133,10 @@ signing_key:
113
133
  specification_version: 3
114
134
  summary: Tiny client for API Leipzig
115
135
  test_files:
116
- - spec/leipzig/mediahandbook_spec.rb
136
+ - spec/leipzig/.DS_Store
137
+ - spec/leipzig/client_spec.rb
138
+ - spec/leipzig/companies.json
139
+ - spec/leipzig/response_builder.rb
117
140
  - spec/leipzig/spec_helper.rb
118
141
  - spec/leipzig/version_spec.rb
142
+ - spec/support/helpers.rb
@@ -1,44 +0,0 @@
1
- require 'leipzig/mediahandbook'
2
-
3
- KEY = ENV['API_KEY']
4
- LIMIT = 5
5
-
6
- describe 'Mediahandbook' do
7
- let(:client) { Leipzig::Mediahandbook.new(KEY) }
8
-
9
- it 'returns given API key' do
10
- client.api_key.should eq(KEY)
11
- end
12
-
13
- it 'reponds to all three mediahandbook types' do
14
- client.should respond_to(:find_branches)
15
- client.should respond_to(:find_companies)
16
- client.should respond_to(:find_people)
17
- end
18
-
19
- it 'returns json representation of resource with default limit' do
20
- data = client.find_companies
21
- data.should be_instance_of(Array)
22
- data.size.should eq(10)
23
- end
24
-
25
- it 'returns json representation of resource with given limit' do
26
- data = client.find_companies(:limit => LIMIT)
27
- data.should be_instance_of(Array)
28
- data.size.should eq(LIMIT)
29
- end
30
-
31
- it 'takes search parameter into account' do
32
- zip = '04319'
33
- data = client.find_companies(:limit => 2, :postcode => zip)
34
- data.map { |company| company.postcode.should eq(zip) }
35
- end
36
-
37
- it 'raises exception if invalid key is used' do
38
- lambda { Leipzig::Mediahandbook.new('wrong').find_companies }.should raise_error
39
- end
40
-
41
- it 'raises exception if undefined method is called' do
42
- lambda { client.find_something }.should raise_error
43
- end
44
- end