ultron 0.1.0 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +1 -0
- data/README.md +65 -5
- data/lib/ultron.rb +4 -1
- data/lib/ultron/auth.rb +2 -12
- data/lib/ultron/config.rb +9 -13
- data/lib/ultron/connection.rb +9 -33
- data/lib/ultron/entities.rb +39 -35
- data/lib/ultron/exceptions/no_results_exception.rb +9 -0
- data/lib/ultron/exceptions/not_found_exception.rb +10 -0
- data/lib/ultron/version.rb +1 -1
- data/spec/cassettes/Ultron_Characters/should_find_a_list_of_comics_featuring_the_character.yml +1362 -413
- data/spec/cassettes/Ultron_Comics/should_find_a_comic.yml +1 -1
- data/spec/cassettes/Ultron_Creators/should_find_a_list_of_series_by_the_creator.yml +9 -9
- data/spec/cassettes/Ultron_Series/and_again_here.yml +244 -0
- data/spec/cassettes/Ultron_Series/should_give_a_default_set_of_series.yml +1714 -0
- data/spec/cassettes/Ultron_Series/should_let_us_reuse_the_connection_safely.yml +916 -0
- data/spec/cassettes/Ultron_Series/should_let_us_search_with_parameters.yml +244 -0
- data/spec/cassettes/searching/should_accept_with_as_a_synonym_for_where.yml +812 -0
- data/spec/cassettes/searching/should_handle_an_empty_response_gracefully.yml +34 -0
- data/spec/cassettes/searching/should_indicate_Not_Found.yml +61 -0
- data/spec/cassettes/searching/should_let_us_get_a_comic.yml +59 -0
- data/spec/cassettes/searching/should_let_us_get_comics_by_a_creator.yml +1935 -0
- data/spec/cassettes/searching/should_let_us_get_comics_by_a_creator_with_params_.yml +266 -0
- data/spec/cassettes/searching/should_let_us_get_more_than_the_default_20_results.yml +2263 -0
- data/spec/cassettes/searching/should_let_us_search_with_multiple_parameters.yml +583 -0
- data/spec/cassettes/searching/should_let_us_search_with_parameters.yml +2299 -0
- data/spec/cassettes/searching/should_throw_a_No_Results_exception.yml +34 -0
- data/spec/cassettes/searching/should_throw_a_Not_Found_exception.yml +32 -0
- data/spec/ultron/characters_spec.rb +8 -8
- data/spec/ultron/comics_spec.rb +2 -2
- data/spec/ultron/config_spec.rb +4 -0
- data/spec/ultron/creators_spec.rb +6 -6
- data/spec/ultron/events_spec.rb +6 -6
- data/spec/ultron/searches_spec.rb +67 -0
- data/spec/ultron/series_spec.rb +18 -0
- data/spec/ultron/ultron_spec.rb +10 -0
- metadata +40 -7
- data/lib/ultron/helpers.rb +0 -9
- data/spec/ultron/connection_spec.rb +0 -43
- data/spec/ultron/helpers_spec.rb +0 -11
@@ -0,0 +1,34 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: http://gateway.marvel.com/v1/public/comics?apikey=<PUBLIC_KEY>&hash=a304d29c7e65217654f6ddd18daf2b3c&offset=1000000&ts=1392317244
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- application/json
|
12
|
+
User-Agent:
|
13
|
+
- 'Ultron v0.1.1: https://rubygems.org/gems/ultron'
|
14
|
+
response:
|
15
|
+
status:
|
16
|
+
code: 200
|
17
|
+
message: OK
|
18
|
+
headers:
|
19
|
+
Etag:
|
20
|
+
- c6221500e62a7317e759c6bd37130ee5c62c0cba
|
21
|
+
Content-Type:
|
22
|
+
- application/json
|
23
|
+
Content-Length:
|
24
|
+
- '150'
|
25
|
+
Date:
|
26
|
+
- Sat, 15 Feb 2014 17:09:20 GMT
|
27
|
+
Connection:
|
28
|
+
- keep-alive
|
29
|
+
body:
|
30
|
+
encoding: ASCII-8BIT
|
31
|
+
string: "{\"code\":200,\"status\":\"Ok\",\"etag\":\"c6221500e62a7317e759c6bd37130ee5c62c0cba\",\"data\":{\"offset\":1000000,\"limit\":20,\"total\":31917,\"count\":0,\"results\":[]}}"
|
32
|
+
http_version:
|
33
|
+
recorded_at: Thu, 13 Feb 2014 18:47:24 GMT
|
34
|
+
recorded_with: VCR 2.8.0
|
@@ -0,0 +1,32 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: http://gateway.marvel.com/v1/public/comics/1000000?apikey=<PUBLIC_KEY>&hash=a304d29c7e65217654f6ddd18daf2b3c&ts=1392317244
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- application/json
|
12
|
+
User-Agent:
|
13
|
+
- 'Ultron v0.1.1: https://rubygems.org/gems/ultron'
|
14
|
+
response:
|
15
|
+
status:
|
16
|
+
code: 404
|
17
|
+
message: Not Found
|
18
|
+
headers:
|
19
|
+
Content-Type:
|
20
|
+
- application/json
|
21
|
+
Content-Length:
|
22
|
+
- '57'
|
23
|
+
Date:
|
24
|
+
- Sat, 15 Feb 2014 16:50:47 GMT
|
25
|
+
Connection:
|
26
|
+
- keep-alive
|
27
|
+
body:
|
28
|
+
encoding: ASCII-8BIT
|
29
|
+
string: "{\"code\":404,\"status\":\"We couldn't find that comic_issue\"}"
|
30
|
+
http_version:
|
31
|
+
recorded_at: Thu, 13 Feb 2014 18:47:24 GMT
|
32
|
+
recorded_with: VCR 2.8.0
|
@@ -11,17 +11,17 @@ module Ultron
|
|
11
11
|
end
|
12
12
|
|
13
13
|
it 'should find a character', :vcr do
|
14
|
-
|
15
|
-
|
14
|
+
character = Characters.find 1009685
|
15
|
+
character.name.should == 'Ultron'
|
16
16
|
end
|
17
17
|
|
18
18
|
it 'should find a list of comics featuring the character', :vcr do
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
19
|
+
character = Characters.find 1009610
|
20
|
+
character.name.should == 'Spider-Man'
|
21
|
+
comics = Comics.by_character 1009610
|
22
|
+
comics.first.title.should == 'Superior Spider-Man (2013) #22'
|
23
|
+
comics.class.should == Comics
|
24
|
+
comics.count.should == 20
|
25
25
|
end
|
26
26
|
|
27
27
|
after :each do
|
data/spec/ultron/comics_spec.rb
CHANGED
data/spec/ultron/config_spec.rb
CHANGED
@@ -13,6 +13,10 @@ module Ultron
|
|
13
13
|
@conf['path'].should == '/v1/public/'
|
14
14
|
end
|
15
15
|
|
16
|
+
it 'should have a root url' do
|
17
|
+
Ultron::Config.instance.root_url.should == 'http://gateway.marvel.com/v1/public/'
|
18
|
+
end
|
19
|
+
|
16
20
|
it 'should let us add arbitrary keys' do
|
17
21
|
@conf['doge'] = 'wow'
|
18
22
|
@conf['doge'].should == 'wow'
|
@@ -11,12 +11,12 @@ module Ultron
|
|
11
11
|
end
|
12
12
|
|
13
13
|
it 'should find a list of series by the creator', :vcr do
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
14
|
+
creator = Creators.find 196
|
15
|
+
creator.fullName.should == 'Jack Kirby'
|
16
|
+
series = Series.by_creator 196
|
17
|
+
series[3].title.should == 'Amazing Fantasy (1962)'
|
18
|
+
series.class.should == Series
|
19
|
+
series.count.should == 20
|
20
20
|
end
|
21
21
|
|
22
22
|
after :each do
|
data/spec/ultron/events_spec.rb
CHANGED
@@ -11,12 +11,12 @@ module Ultron
|
|
11
11
|
end
|
12
12
|
|
13
13
|
it 'should find a list of stories for the event', :vcr do
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
14
|
+
event = Events.find 271
|
15
|
+
event.title.should == 'Secret Wars II'
|
16
|
+
stories = Stories.by_event 271
|
17
|
+
stories[4].title.should == 'Doctor Doom Versus the Beyonder'
|
18
|
+
stories[4].id.should == 12850
|
19
|
+
stories.class.should == Stories
|
20
20
|
end
|
21
21
|
|
22
22
|
after :each do
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Ultron
|
4
|
+
describe 'searching' do
|
5
|
+
before :each do
|
6
|
+
Timecop.freeze '2014-02-13T18:47:24+00:00'
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'should let us get a comic', :vcr do
|
10
|
+
comic = Comics.find 10588
|
11
|
+
comic.title.should == 'Secret Wars (1984) #6'
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'should let us get comics by a creator', :vcr do
|
15
|
+
comics = Comics.by_creator 196 # Jack Kirby
|
16
|
+
comics[14].title.should == 'INHUMANS: THE ORIGIN OF THE INHUMANS TPB (Trade Paperback)'
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'should let us search with parameters', :vcr do
|
20
|
+
comics = Comics.where sharedAppearances: '1009351,1009718' # Hulk and Wolverine
|
21
|
+
comics[7].title.should == 'Deadpool (2008) #37'
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should let us search with multiple parameters', :vcr do
|
25
|
+
comics = Comics.where sharedAppearances: '1009610,1009718', events: 302 # Spider-Man and Wolverine, Fear Itself
|
26
|
+
comics.first.title.should == 'Fear Itself (2010) #7'
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'should accept with as a synonym for where', :vcr do
|
30
|
+
comics = Comics.with sharedAppearances: '1009685,1009351' # Ultron and Hulk
|
31
|
+
comics.first.title.should == 'Avengers: First to Last (Hardcover)'
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'should let us get comics by a creator *with params*', :vcr do
|
35
|
+
comics = Comics.by_creator_and_with 214, dateRange: '1980-01-01,1989-12-31'
|
36
|
+
comics.first.resourceURI.should == 'http://gateway.marvel.com/v1/public/comics/8268'
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'should let us get more than the default 20 results', :vcr do
|
40
|
+
comics = Comics.where limit: 50
|
41
|
+
comics.count.should == 50
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'should throw a Not Found exception', :vcr do
|
45
|
+
begin
|
46
|
+
comic = Comics.find 1000000 # there are not a million comics
|
47
|
+
rescue NotFoundException => e
|
48
|
+
e.code.should == 404
|
49
|
+
e.status.should == "We couldn't find that comic_issue"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'should throw a No Results exception', :vcr do
|
54
|
+
begin
|
55
|
+
comics = Comics.where offset: 1000000
|
56
|
+
rescue NoResultsException => e
|
57
|
+
e.status.should == 'That search returned no results'
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'should let us pick a random item'
|
62
|
+
|
63
|
+
after :each do
|
64
|
+
Timecop.return
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Ultron
|
4
|
+
describe Series do
|
5
|
+
before :each do
|
6
|
+
Timecop.freeze '2014-02-13T18:47:24+00:00'
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'should give a default set of series', :vcr do
|
10
|
+
series = Series.get
|
11
|
+
series.count.should == 20
|
12
|
+
end
|
13
|
+
|
14
|
+
after :each do
|
15
|
+
Timecop.return
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ultron
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- pikesley
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-02-
|
11
|
+
date: 2014-02-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: curb
|
@@ -275,7 +275,8 @@ files:
|
|
275
275
|
- lib/ultron/creators.rb
|
276
276
|
- lib/ultron/entities.rb
|
277
277
|
- lib/ultron/events.rb
|
278
|
-
- lib/ultron/
|
278
|
+
- lib/ultron/exceptions/no_results_exception.rb
|
279
|
+
- lib/ultron/exceptions/not_found_exception.rb
|
279
280
|
- lib/ultron/series.rb
|
280
281
|
- lib/ultron/stories.rb
|
281
282
|
- lib/ultron/version.rb
|
@@ -288,16 +289,32 @@ files:
|
|
288
289
|
- spec/cassettes/Ultron_Creators/should_find_a_list_of_series_by_the_creator.yml
|
289
290
|
- spec/cassettes/Ultron_Events/should_find_a_list_of_stories_for_the_event.yml
|
290
291
|
- spec/cassettes/Ultron_Events/should_find_an_event.yml
|
292
|
+
- spec/cassettes/Ultron_Series/and_again_here.yml
|
293
|
+
- spec/cassettes/Ultron_Series/should_give_a_default_set_of_series.yml
|
294
|
+
- spec/cassettes/Ultron_Series/should_let_us_reuse_the_connection_safely.yml
|
295
|
+
- spec/cassettes/Ultron_Series/should_let_us_search_with_parameters.yml
|
296
|
+
- spec/cassettes/searching/should_accept_with_as_a_synonym_for_where.yml
|
297
|
+
- spec/cassettes/searching/should_handle_an_empty_response_gracefully.yml
|
298
|
+
- spec/cassettes/searching/should_indicate_Not_Found.yml
|
299
|
+
- spec/cassettes/searching/should_let_us_get_a_comic.yml
|
300
|
+
- spec/cassettes/searching/should_let_us_get_comics_by_a_creator.yml
|
301
|
+
- spec/cassettes/searching/should_let_us_get_comics_by_a_creator_with_params_.yml
|
302
|
+
- spec/cassettes/searching/should_let_us_get_more_than_the_default_20_results.yml
|
303
|
+
- spec/cassettes/searching/should_let_us_search_with_multiple_parameters.yml
|
304
|
+
- spec/cassettes/searching/should_let_us_search_with_parameters.yml
|
305
|
+
- spec/cassettes/searching/should_throw_a_No_Results_exception.yml
|
306
|
+
- spec/cassettes/searching/should_throw_a_Not_Found_exception.yml
|
291
307
|
- spec/spec_helper.rb
|
292
308
|
- spec/support/vcr_setup.rb
|
293
309
|
- spec/ultron/auth_spec.rb
|
294
310
|
- spec/ultron/characters_spec.rb
|
295
311
|
- spec/ultron/comics_spec.rb
|
296
312
|
- spec/ultron/config_spec.rb
|
297
|
-
- spec/ultron/connection_spec.rb
|
298
313
|
- spec/ultron/creators_spec.rb
|
299
314
|
- spec/ultron/events_spec.rb
|
300
|
-
- spec/ultron/
|
315
|
+
- spec/ultron/searches_spec.rb
|
316
|
+
- spec/ultron/series_spec.rb
|
317
|
+
- spec/ultron/ultron_spec.rb
|
301
318
|
- ultron.gemspec
|
302
319
|
homepage: ''
|
303
320
|
licenses:
|
@@ -333,13 +350,29 @@ test_files:
|
|
333
350
|
- spec/cassettes/Ultron_Creators/should_find_a_list_of_series_by_the_creator.yml
|
334
351
|
- spec/cassettes/Ultron_Events/should_find_a_list_of_stories_for_the_event.yml
|
335
352
|
- spec/cassettes/Ultron_Events/should_find_an_event.yml
|
353
|
+
- spec/cassettes/Ultron_Series/and_again_here.yml
|
354
|
+
- spec/cassettes/Ultron_Series/should_give_a_default_set_of_series.yml
|
355
|
+
- spec/cassettes/Ultron_Series/should_let_us_reuse_the_connection_safely.yml
|
356
|
+
- spec/cassettes/Ultron_Series/should_let_us_search_with_parameters.yml
|
357
|
+
- spec/cassettes/searching/should_accept_with_as_a_synonym_for_where.yml
|
358
|
+
- spec/cassettes/searching/should_handle_an_empty_response_gracefully.yml
|
359
|
+
- spec/cassettes/searching/should_indicate_Not_Found.yml
|
360
|
+
- spec/cassettes/searching/should_let_us_get_a_comic.yml
|
361
|
+
- spec/cassettes/searching/should_let_us_get_comics_by_a_creator.yml
|
362
|
+
- spec/cassettes/searching/should_let_us_get_comics_by_a_creator_with_params_.yml
|
363
|
+
- spec/cassettes/searching/should_let_us_get_more_than_the_default_20_results.yml
|
364
|
+
- spec/cassettes/searching/should_let_us_search_with_multiple_parameters.yml
|
365
|
+
- spec/cassettes/searching/should_let_us_search_with_parameters.yml
|
366
|
+
- spec/cassettes/searching/should_throw_a_No_Results_exception.yml
|
367
|
+
- spec/cassettes/searching/should_throw_a_Not_Found_exception.yml
|
336
368
|
- spec/spec_helper.rb
|
337
369
|
- spec/support/vcr_setup.rb
|
338
370
|
- spec/ultron/auth_spec.rb
|
339
371
|
- spec/ultron/characters_spec.rb
|
340
372
|
- spec/ultron/comics_spec.rb
|
341
373
|
- spec/ultron/config_spec.rb
|
342
|
-
- spec/ultron/connection_spec.rb
|
343
374
|
- spec/ultron/creators_spec.rb
|
344
375
|
- spec/ultron/events_spec.rb
|
345
|
-
- spec/ultron/
|
376
|
+
- spec/ultron/searches_spec.rb
|
377
|
+
- spec/ultron/series_spec.rb
|
378
|
+
- spec/ultron/ultron_spec.rb
|
data/lib/ultron/helpers.rb
DELETED
@@ -1,43 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module Ultron
|
4
|
-
describe Connection do
|
5
|
-
before :each do
|
6
|
-
Timecop.freeze '2014-02-08T21:20:00+00:00'
|
7
|
-
@cnxn = Ultron::Connection.new
|
8
|
-
@cnxn.path = 'characters'
|
9
|
-
end
|
10
|
-
|
11
|
-
it 'should have the correct url', :vcr do
|
12
|
-
@cnxn.url.should match /http:\/\/gateway.marvel.com\/v1\/public\/characters/
|
13
|
-
end
|
14
|
-
|
15
|
-
it 'should get a 200', :vcr do
|
16
|
-
@cnxn.perform['code'].should == 200
|
17
|
-
end
|
18
|
-
|
19
|
-
it 'should accept additional params', :vcr do
|
20
|
-
@cnxn.add_params 'foo' => 'bar'
|
21
|
-
@cnxn.url.to_s.should match /&foo=bar/
|
22
|
-
end
|
23
|
-
|
24
|
-
it 'should know how to URL-encode things', :vcr do
|
25
|
-
@cnxn.add_params 'this' => 'has spaces'
|
26
|
-
@cnxn.url.to_s.should match /&this=has%20spaces/
|
27
|
-
end
|
28
|
-
|
29
|
-
it 'should accept parameters in different hash notation', :vcr do
|
30
|
-
@cnxn.add_params limit: 1
|
31
|
-
@cnxn.url.to_s.should match /&limit=1/
|
32
|
-
end
|
33
|
-
|
34
|
-
it 'should let us specify a different path', :vcr do
|
35
|
-
@cnxn.path = 'comics'
|
36
|
-
@cnxn.url.should match /http:\/\/gateway.marvel.com\/v1\/public\/comics/
|
37
|
-
end
|
38
|
-
|
39
|
-
after :each do
|
40
|
-
Timecop.return
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
data/spec/ultron/helpers_spec.rb
DELETED