ultron 0.1.4 → 0.1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 69b914d9f16335035655a79ba254c6dddb28fdea
4
- data.tar.gz: 99eaf8d276b7036e57376c2b9539032417c73600
3
+ metadata.gz: 6195265a3aa3ffae282744daa6ffaaab7415d9fe
4
+ data.tar.gz: 8f647150c7d3d127967591e1bf089907243d1420
5
5
  SHA512:
6
- metadata.gz: 237d10bf3c136b2dd6433eb0b0703b328ae09f9b6c9811232f5e848b6f1e9dd8b31a00f8a20ea11d1c17da6ade53503e12be7fb1dd70ef63e60d2960ffcd1986
7
- data.tar.gz: d6b43d18a54ae12ab359055153445f1b828a0ab760963e3cf1f52b575a6383631130dd6c7c7177ff4b7cdc1c43e26a3e7053283238b4172df7ba847c37821a5e
6
+ metadata.gz: 19cea53dd77e216e09839cc1617b51ae0cff573973196ecdd77d223db1ca581239f940221713d5e2f5d35ea94be161a3d89359c2932bb29dcee2346342b4fb44
7
+ data.tar.gz: c1916685fb592072dbacddb8e6864f87475a9e1a728b082900671108df8506212d02b4f61b3c2bcce944a41a7c218d7baa69ece68608e6010e39d4f1dcd3c5b4
data/README.md CHANGED
@@ -14,13 +14,17 @@ Ruby bindings for the [Marvel Comics API](http://developer.marvel.com/)
14
14
  ultron
15
15
  bundle
16
16
  rake
17
+
18
+ Or just
19
+
20
+ gem install ultron
17
21
 
18
- To actually use it you need an API key and secret which you can get from [here](https://developer.marvel.com/signup), put them into `.env` like this
22
+ To actually use it you need an API keypair which you can get from [here](https://developer.marvel.com/signup), put them into `.env` like this
19
23
 
20
24
  PUBLIC_KEY: this_r_public_key
21
25
  PRIVATE_KEY: this_one_r_private_key
22
-
23
- This all got a lot more elegant after chat over a fry-up with @floppy at the always-superb [First-Step Cafe](https://plus.google.com/100027883675109761806/about?gl=uk&hl=en) in Shoreditch.
26
+
27
+ I've made a [little toy app](https://github.com/pikesley/powerman) which uses this gem to explore the data.
24
28
 
25
29
  ## API
26
30
 
@@ -92,12 +96,14 @@ I've tried to follow the [Marvel API](http://developer.marvel.com/docs#!/public/
92
96
  end
93
97
  end
94
98
 
95
- ### Raise a custom exception when no results are found
99
+ ### Raise a custom exception when we do something dumb
96
100
 
97
- it 'should throw an Ultron exception for something internal to Ultron', :vcr do
101
+ it 'should throw a Resource Not Found exception when we search for something nonsensical', :vcr do
98
102
  begin
99
- comics = Comics.where offset: 1000000
103
+ characters = Characters.by_creator 186 # characters by creator is a nonsense concept in the Marvel API
100
104
  rescue UltronException => e
101
- e.status.should == 'The search returned no results'
105
+ e.status.should == 'Resource does not exist. Check http://developer.marvel.com/docs'
102
106
  end
103
- end
107
+ end
108
+
109
+ This all got a lot more elegant after a chat over a fry-up with @floppy at the always-superb [First-Step Cafe](https://plus.google.com/100027883675109761806/about?gl=uk&hl=en) in Shoreditch.
@@ -31,7 +31,7 @@ module Ultron
31
31
  def self.response url
32
32
  response = Ultron::Connection.perform url
33
33
  case response['code'].to_s
34
- when /^4/
34
+ when /^4/, /^5/
35
35
  raise MarvelException.new response
36
36
  when 'ResourceNotFound'
37
37
  raise UltronException.new 'Resource does not exist. Check %s' % Config.instance.config.api_docs
@@ -1,3 +1,3 @@
1
1
  module Ultron
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
3
3
  end
@@ -0,0 +1,33 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://gateway.marvel.com/v1/public/creators/186/characters?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.4: 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
+ - '181'
23
+ Date:
24
+ - Sat, 15 Feb 2014 21:34:57 GMT
25
+ Connection:
26
+ - keep-alive
27
+ body:
28
+ encoding: ASCII-8BIT
29
+ string: "{\"code\":\"ResourceNotFound\",\"message\":\"/v1/public/creators/186/characters?ts=1392317244&apikey=<PUBLIC_KEY>&hash=a304d29c7e65217654f6ddd18daf2b3c
30
+ does not exist\"}"
31
+ http_version:
32
+ recorded_at: Thu, 13 Feb 2014 18:47:24 GMT
33
+ recorded_with: VCR 2.8.0
@@ -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.4: 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
+ - Sun, 16 Feb 2014 16:52:41 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
@@ -24,7 +24,7 @@ module Ultron
24
24
  end
25
25
  end
26
26
 
27
- it 'should throw an Ultron exception for something internal to Ultron', :vcr do
27
+ it 'should throw an Ultron exception when we do something dumb', :vcr do
28
28
  begin
29
29
  comics = Comics.where offset: 1000000
30
30
  rescue UltronException => e
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
4
+ version: 0.1.5
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-15 00:00:00.000000000 Z
11
+ date: 2014-02-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: curb
@@ -298,7 +298,9 @@ files:
298
298
  - spec/cassettes/exceptions/should_throw_a_No_Results_exception.yml
299
299
  - spec/cassettes/exceptions/should_throw_a_Not_Found_exception.yml
300
300
  - spec/cassettes/exceptions/should_throw_a_Resource_Not_Found_exception_when_we_search_for_something_non-sensical.yml
301
+ - spec/cassettes/exceptions/should_throw_a_Resource_Not_Found_exception_when_we_search_for_something_nonsensical.yml
301
302
  - spec/cassettes/exceptions/should_throw_an_Ultron_exception_for_something_internal_to_Ultron.yml
303
+ - spec/cassettes/exceptions/should_throw_an_Ultron_exception_when_we_do_something_dumb.yml
302
304
  - spec/cassettes/sample/let_us_pick_a_random_item/should_get_a_count_of_items_for_a_lookup.yml
303
305
  - spec/cassettes/sample/let_us_pick_a_random_item/should_give_us_a_random_comic.yml
304
306
  - spec/cassettes/sample/let_us_pick_a_random_item/should_give_us_a_random_comic_for_a_more_complex_search.yml
@@ -378,7 +380,9 @@ test_files:
378
380
  - spec/cassettes/exceptions/should_throw_a_No_Results_exception.yml
379
381
  - spec/cassettes/exceptions/should_throw_a_Not_Found_exception.yml
380
382
  - spec/cassettes/exceptions/should_throw_a_Resource_Not_Found_exception_when_we_search_for_something_non-sensical.yml
383
+ - spec/cassettes/exceptions/should_throw_a_Resource_Not_Found_exception_when_we_search_for_something_nonsensical.yml
381
384
  - spec/cassettes/exceptions/should_throw_an_Ultron_exception_for_something_internal_to_Ultron.yml
385
+ - spec/cassettes/exceptions/should_throw_an_Ultron_exception_when_we_do_something_dumb.yml
382
386
  - spec/cassettes/sample/let_us_pick_a_random_item/should_get_a_count_of_items_for_a_lookup.yml
383
387
  - spec/cassettes/sample/let_us_pick_a_random_item/should_give_us_a_random_comic.yml
384
388
  - spec/cassettes/sample/let_us_pick_a_random_item/should_give_us_a_random_comic_for_a_more_complex_search.yml