ultron 0.0.1 → 0.0.2

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.
Files changed (145) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -1
  3. data/.rspec +1 -1
  4. data/.travis.yml +7 -0
  5. data/{LICENSE.txt → LICENSE.md} +2 -2
  6. data/README.md +19 -21
  7. data/Rakefile +1 -1
  8. data/config/params.yaml +0 -0
  9. data/config/ultron.yaml +2 -0
  10. data/examples/links.rb +0 -0
  11. data/lib/ultron.rb +29 -4
  12. data/lib/ultron/api/character.rb +19 -0
  13. data/lib/ultron/api/characters.rb +14 -0
  14. data/lib/ultron/api/comic.rb +15 -0
  15. data/lib/ultron/api/comics.rb +14 -0
  16. data/lib/ultron/api/creator.rb +19 -0
  17. data/lib/ultron/api/creators.rb +14 -0
  18. data/lib/ultron/api/entities.rb +45 -0
  19. data/lib/ultron/api/entity.rb +51 -0
  20. data/lib/ultron/api/event.rb +15 -0
  21. data/lib/ultron/api/events.rb +14 -0
  22. data/lib/ultron/api/series.rb +23 -0
  23. data/lib/ultron/api/serieses.rb +16 -0
  24. data/lib/ultron/api/stories.rb +14 -0
  25. data/lib/ultron/api/story.rb +15 -0
  26. data/lib/ultron/config.rb +35 -0
  27. data/lib/ultron/connection.rb +41 -0
  28. data/lib/ultron/helpers.rb +25 -0
  29. data/lib/ultron/version.rb +1 -1
  30. data/spec/cassettes/Ultron_API_Character/should_have_a_series_set.yml +88 -0
  31. data/spec/cassettes/Ultron_API_Character/should_have_an_events_set.yml +32 -0
  32. data/spec/cassettes/Ultron_API_Character/should_have_the_correct_name.yml +88 -0
  33. data/spec/cassettes/Ultron_API_Character/should_have_the_correct_sets/events.yml +32 -0
  34. data/spec/cassettes/Ultron_API_Character/should_not_have_any_events.yml +32 -0
  35. data/spec/cassettes/Ultron_API_CharacterSet/should_have_the_correct_first_character.yml +1616 -0
  36. data/spec/cassettes/Ultron_API_Characters/characters_filtered_by_comic/should_have_the_correct_first_character.yml +1616 -0
  37. data/spec/cassettes/Ultron_API_Characters/generate_filtered_lists_of_characters/by_comic.yml +1862 -0
  38. data/spec/cassettes/Ultron_API_Characters/generate_filtered_lists_of_characters/by_event.yml +3876 -0
  39. data/spec/cassettes/Ultron_API_Characters/generate_filtered_lists_of_characters/by_series.yml +743 -0
  40. data/spec/cassettes/Ultron_API_Characters/generate_filtered_lists_of_characters/by_story.yml +345 -0
  41. data/spec/cassettes/Ultron_API_Characters/get_a_character_by_name/should_have_the_correct_id.yml +114 -0
  42. data/spec/cassettes/Ultron_API_Characters/get_a_character_by_name/should_have_the_correct_name.yml +114 -0
  43. data/spec/cassettes/Ultron_API_Characters/get_a_character_with_a_space_in_their_name/should_have_the_correct_id.yml +99 -0
  44. data/spec/cassettes/Ultron_API_Characters/get_a_character_with_a_space_in_their_name/should_have_the_correct_name.yml +99 -0
  45. data/spec/cassettes/Ultron_API_Characters/get_the_first_character_off_the_list/should_have_the_correct_id.yml +644 -0
  46. data/spec/cassettes/Ultron_API_Characters/get_the_first_character_off_the_list/should_have_the_correct_name.yml +644 -0
  47. data/spec/cassettes/Ultron_API_Characters/get_the_first_character_off_the_list/should_have_the_correct_resourceURI.yml +644 -0
  48. data/spec/cassettes/Ultron_API_Characters/parameterize_the_request/should_let_us_set_multiple_parameters.yml +1595 -0
  49. data/spec/cassettes/Ultron_API_Characters/should_generate_a_list_of_characters_filtered_by_comic.yml +2737 -0
  50. data/spec/cassettes/Ultron_API_Characters/should_generate_a_list_of_characters_filtered_by_event.yml +7345 -0
  51. data/spec/cassettes/Ultron_API_Characters/should_generate_a_list_of_characters_filtered_by_series.yml +743 -0
  52. data/spec/cassettes/Ultron_API_Characters/should_generate_a_list_of_characters_filtered_by_story.yml +231 -0
  53. data/spec/cassettes/Ultron_API_Characters/should_have_genarate_a_list_of_characters_filtered_by_comic.yml +1616 -0
  54. data/spec/cassettes/Ultron_API_Characters/should_have_the_correct_first_character.yml +1616 -0
  55. data/spec/cassettes/Ultron_API_Characters/should_not_generate_a_list_of_characters_filtered_by_creator.yml +31 -0
  56. data/spec/cassettes/Ultron_API_Characters/should_not_generate_lists_of_characters/filtered_by_creator.yml +31 -0
  57. data/spec/cassettes/Ultron_API_Comic/should_have_a_list_of_characters.yml +46 -0
  58. data/spec/cassettes/Ultron_API_Comic/should_have_openstruct_method-style_attribute_accessors.yml +46 -0
  59. data/spec/cassettes/Ultron_API_Comic/should_have_the_correct_title.yml +46 -0
  60. data/spec/cassettes/Ultron_API_Comic/should_have_the_correct_year.yml +46 -0
  61. data/spec/cassettes/Ultron_API_ComicSet/should_have_the_correct_first_comic.yml +2013 -0
  62. data/spec/cassettes/Ultron_API_Comics/generate_filtered_lists_of_comics/by_character.yml +2059 -0
  63. data/spec/cassettes/Ultron_API_Comics/generate_filtered_lists_of_comics/by_creator.yml +2177 -0
  64. data/spec/cassettes/Ultron_API_Comics/generate_filtered_lists_of_comics/by_event.yml +1701 -0
  65. data/spec/cassettes/Ultron_API_Comics/generate_filtered_lists_of_comics/by_series.yml +123 -0
  66. data/spec/cassettes/Ultron_API_Comics/generate_filtered_lists_of_comics/by_stories.yml +499 -0
  67. data/spec/cassettes/Ultron_API_Comics/generate_filtered_lists_of_comics/by_story.yml +577 -0
  68. data/spec/cassettes/Ultron_API_Comics/get_the_first_comic_off_the_list/should_have_the_correct_id.yml +1039 -0
  69. data/spec/cassettes/Ultron_API_Comics/get_the_first_comic_off_the_list/should_have_the_correct_name.yml +946 -0
  70. data/spec/cassettes/Ultron_API_Comics/get_the_first_comic_off_the_list/should_have_the_correct_resourceURI.yml +1039 -0
  71. data/spec/cassettes/Ultron_API_Comics/get_the_first_comic_off_the_list/should_have_the_correct_title.yml +1039 -0
  72. data/spec/cassettes/Ultron_API_Comics/parameterize_the_request/should_let_us_set_a_dateRange.yml +1613 -0
  73. data/spec/cassettes/Ultron_API_Comics/parameterize_the_request/should_let_us_set_a_limit.yml +96 -0
  74. data/spec/cassettes/Ultron_API_Comics/should_generate_a_list_of_comics_filtered_by_character.yml +3955 -0
  75. data/spec/cassettes/Ultron_API_Comics/should_have_the_correct_first_comic.yml +2012 -0
  76. data/spec/cassettes/Ultron_API_ComicsSet/should_have_the_correct_first_comic.yml +2013 -0
  77. data/spec/cassettes/Ultron_API_Creator/it_should_have_the_correct_sets/comics.yml +2029 -0
  78. data/spec/cassettes/Ultron_API_Creator/should_have_a_comics_set.yml +2022 -0
  79. data/spec/cassettes/Ultron_API_Creator/should_have_the_correct_comic.yml +2029 -0
  80. data/spec/cassettes/Ultron_API_Creator/should_have_the_correct_name.yml +243 -0
  81. data/spec/cassettes/Ultron_API_Creators/generate_filtered_lists_of_creators/by_comic.yml +1205 -0
  82. data/spec/cassettes/Ultron_API_Creators/generate_filtered_lists_of_creators/by_event.yml +2778 -0
  83. data/spec/cassettes/Ultron_API_Creators/generate_filtered_lists_of_creators/by_series.yml +4555 -0
  84. data/spec/cassettes/Ultron_API_Creators/generate_filtered_lists_of_creators/by_story.yml +1253 -0
  85. data/spec/cassettes/Ultron_API_Creators/get_a_creator_by_name/should_return_the_correct_creator.yml +30 -0
  86. data/spec/cassettes/Ultron_API_Creators/get_the_fourth_creator_off_the_list/should_have_the_right_name.yml +1205 -0
  87. data/spec/cassettes/Ultron_API_Creators/get_the_second_creator_off_the_list/should_have_the_right_name.yml +384 -0
  88. data/spec/cassettes/Ultron_API_Creators/should_have_the_correct_first_comic.yml +32 -0
  89. data/spec/cassettes/Ultron_API_Creators/should_not_generate_a_list_of_creators_filtered_by_character.yml +31 -0
  90. data/spec/cassettes/Ultron_API_Creators/should_not_generate_lists_of_creators/filtered_by_character.yml +31 -0
  91. data/spec/cassettes/Ultron_API_Event/should_have_a_list_of_characters.yml +195 -0
  92. data/spec/cassettes/Ultron_API_Event/should_have_the_correct_first_character.yml +195 -0
  93. data/spec/cassettes/Ultron_API_Event/should_have_the_correct_title.yml +108 -0
  94. data/spec/cassettes/Ultron_API_Events/generate_filtered_lists_of_events/by_character.yml +5161 -0
  95. data/spec/cassettes/Ultron_API_Events/generate_filtered_lists_of_events/by_comic.yml +363 -0
  96. data/spec/cassettes/Ultron_API_Events/generate_filtered_lists_of_events/by_creator.yml +9257 -0
  97. data/spec/cassettes/Ultron_API_Events/generate_filtered_lists_of_events/by_series.yml +240 -0
  98. data/spec/cassettes/Ultron_API_Events/generate_filtered_lists_of_events/by_story.yml +375 -0
  99. data/spec/cassettes/Ultron_API_Events/get_the_second_event_off_the_list/should_have_the_right_name.yml +4762 -0
  100. data/spec/cassettes/Ultron_API_Series/should_have_the_correct_sets/not_series.yml +40 -0
  101. data/spec/cassettes/Ultron_API_Series/should_have_the_correct_title.yml +40 -0
  102. data/spec/cassettes/Ultron_API_Serieses/generate_filtered_lists_of_serieses/by_character.yml +3618 -0
  103. data/spec/cassettes/Ultron_API_Serieses/generate_filtered_lists_of_serieses/by_comic.yml +31 -0
  104. data/spec/cassettes/Ultron_API_Serieses/generate_filtered_lists_of_serieses/by_creator.yml +1104 -0
  105. data/spec/cassettes/Ultron_API_Serieses/generate_filtered_lists_of_serieses/by_event.yml +591 -0
  106. data/spec/cassettes/Ultron_API_Serieses/get_the_third_event_off_the_list/should_have_the_right_name.yml +1780 -0
  107. data/spec/cassettes/Ultron_API_Serieses/should_not_generate_lists_of_series/filtered_by_comic.yml +31 -0
  108. data/spec/cassettes/Ultron_API_Serieses/should_not_generate_lists_of_series/filtered_by_story.yml +31 -0
  109. data/spec/cassettes/Ultron_API_Stories/generate_filtered_lists_of_stories/by_character.yml +342 -0
  110. data/spec/cassettes/Ultron_API_Stories/generate_filtered_lists_of_stories/by_comic.yml +110 -0
  111. data/spec/cassettes/Ultron_API_Stories/generate_filtered_lists_of_stories/by_creator.yml +1041 -0
  112. data/spec/cassettes/Ultron_API_Stories/generate_filtered_lists_of_stories/by_event.yml +846 -0
  113. data/spec/cassettes/Ultron_API_Stories/generate_filtered_lists_of_stories/by_series.yml +143 -0
  114. data/spec/cassettes/Ultron_API_Stories/get_the_fourth_story_off_the_list/should_have_the_right_name.yml +686 -0
  115. data/spec/cassettes/Ultron_API_Stories/get_the_second_story_off_the_list/should_have_the_right_name.yml +686 -0
  116. data/spec/cassettes/Ultron_API_Story/should_have_the_correct_title.yml +40 -0
  117. data/spec/cassettes/Ultron_Connection/should_get_a_200.yml +559 -0
  118. data/spec/spec_helper.rb +3 -0
  119. data/spec/support/vcr_setup.rb +17 -0
  120. data/spec/ultron/api/character_spec.rb +50 -0
  121. data/spec/ultron/api/comic_spec.rb +55 -0
  122. data/spec/ultron/api/creator_spec.rb +50 -0
  123. data/spec/ultron/api/event_spec.rb +50 -0
  124. data/spec/ultron/api/filtered_sets/characters_filtered_spec.rb +53 -0
  125. data/spec/ultron/api/filtered_sets/comics_filtered_spec.rb +51 -0
  126. data/spec/ultron/api/filtered_sets/creators_filtered_spec.rb +51 -0
  127. data/spec/ultron/api/filtered_sets/events_filtered_spec.rb +51 -0
  128. data/spec/ultron/api/filtered_sets/series_filtered_spec.rb +50 -0
  129. data/spec/ultron/api/filtered_sets/stories_filtered_spec.rb +52 -0
  130. data/spec/ultron/api/series_spec.rb +46 -0
  131. data/spec/ultron/api/sets/characters_spec.rb +71 -0
  132. data/spec/ultron/api/sets/comics_spec.rb +46 -0
  133. data/spec/ultron/api/sets/creators_spec.rb +29 -0
  134. data/spec/ultron/api/sets/events_spec.rb +26 -0
  135. data/spec/ultron/api/sets/serieses_spec.rb +26 -0
  136. data/spec/ultron/api/sets/stories_spec.rb +26 -0
  137. data/spec/ultron/api/story_spec.rb +46 -0
  138. data/spec/ultron/auth_spec.rb +13 -0
  139. data/spec/ultron/config_spec.rb +16 -0
  140. data/spec/ultron/connection_spec.rb +33 -0
  141. data/spec/ultron/helpers_spec.rb +11 -0
  142. data/ultron.gemspec +16 -11
  143. metadata +346 -50
  144. data/lib/ultron/characters.rb +0 -9
  145. data/spec/ultron/characters_spec.rb +0 -12
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 019535ccc27624ead80c49fc7bf7b99e9816739f
4
- data.tar.gz: 0006387f10ea44a1ad3803041d13a7a13a0d7c6d
3
+ metadata.gz: c3aaf7379f93c11b5004a4b61a2634d3e5b47cc9
4
+ data.tar.gz: 010fdad665f622d6c3a1ffd268f09a7614565edc
5
5
  SHA512:
6
- metadata.gz: 83e1042b99782c8b599f754ca0c48e043b25554c6c0151800c9af4ca3f55798a47e627c752b5401cb3944b3b2596710d1b5ecf8eebdbbefea29dd58f514b06d9
7
- data.tar.gz: 39209787f13c6f97b9ef86b8ee3146f97170406b83a926e133fd744ae3146efde8d550d5e8a6181fd672494ad75eb785b7a983ca0371a1c167c73fc8a0641625
6
+ metadata.gz: 4ad4469d1b48e912d996984e639b5973c386dd4e43da57bfed47281df991401d22e850977c5d74a9bfb0a4d6c11e91221313177237ef0da532619c3d49f27631
7
+ data.tar.gz: 9911fbe134c142d4ac887b6f2df5dd86f2eaeb1b5877f06113a017ef9aad428540f85323b6ee7e422e9e6212f9d5c953a3b6efc71c0cadb202a5e40e3f6f27a0
data/.gitignore CHANGED
@@ -16,4 +16,6 @@ test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
18
 
19
- .idea
19
+ .idea
20
+ .env
21
+ scratch*
data/.rspec CHANGED
@@ -1,2 +1,2 @@
1
1
  --color
2
- --require rspec/pride --format RSpec::Pride
2
+ --format documentation
@@ -0,0 +1,7 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.0
4
+ env:
5
+ global:
6
+ - secure: I6w+eRCXNkVnye8y/NVU9FAiSGgSC6RKtClXUdM1ZbYZHYf/PtruM0eHQAA+2fMR3Vg3Ekg88D2ePWUwLG1HfJO694YMyYIMnaIsK1ESvnhavPSmpWxnXlQhrQcAsDi4QDLM1qpUtnwAOAmo+WNXpU5Jdaoa6024IGKm5VMwWtE=
7
+ - secure: V3Ebf8/4PMSD8vv/kto8OoUlKWk7RlvPmhySbDGkyO6XgPmCYhUMblvwP9gYBjZzowiZcU4bD5D0HUMBimz5XSojK4FpMKPtxtjt20wf3FS43LTxLbvpST6XWDcKfqcEPLIRn/9Z/o5I019O4LbkI7PmHNJyP2MXyNYfZuGvrvw=
@@ -1,6 +1,6 @@
1
- Copyright (c) 2014 pikesley
1
+ ##Copyright (c) 2013 Sam Pikesley
2
2
 
3
- MIT License
3
+ #MIT License
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining
6
6
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -1,29 +1,27 @@
1
- # Ultron
2
-
3
- TODO: Write a gem description
4
-
5
- ## Installation
1
+ [![Build Status](http://img.shields.io/travis/pikesley/ultron.svg)](https://travis-ci.org/pikesley/ultron)
2
+ [![Dependency Status](http://img.shields.io/gemnasium/pikesley/ultron.svg)](https://gemnasium.com/pikesley/ultron)
3
+ [![Coverage Status](http://img.shields.io/coveralls/pikesley/ultron.svg)](https://coveralls.io/r/pikesley/ultron)
4
+ [![Code Climate](http://img.shields.io/codeclimate/github/pikesley/ultron.svg)](https://codeclimate.com/github/pikesley/ultron)
5
+ [![Gem Version](http://img.shields.io/gem/v/ultron.svg)](https://rubygems.org/gems/ultron)
6
+ [![License](http://img.shields.io/:license-mit-blue.svg)](http://pikesley.mit-license.org)
7
+ [![Badges](http://img.shields.io/:badges-7/7-ff6799.svg)](https://github.com/pikesley/badger)
6
8
 
7
- Add this line to your application's Gemfile:
8
-
9
- gem 'ultron'
10
-
11
- And then execute:
9
+ # Ultron
12
10
 
13
- $ bundle
11
+ Wrapping some Ruby around the [Marvel Comics API](http://developer.marvel.com/)
14
12
 
15
- Or install it yourself as:
13
+ git clone https://github.com/pikesley/ultron
14
+ ultron
15
+ bundle
16
+ rake
16
17
 
17
- $ gem install ultron
18
+ Look at the [specs](https://github.com/pikesley/ultron/blob/master/spec/ultron/) to see what it's actually doing - I'm knocking things off one-at-a-time from [this list](http://developer.marvel.com/docs#!/public/).
18
19
 
19
- ## Usage
20
+ 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
20
21
 
21
- TODO: Write usage instructions here
22
+ PUBLIC_KEY: this_r_public_key
23
+ PRIVATE_KEY: this_one_r_private_key
22
24
 
23
- ## Contributing
25
+ ## Alpha alpha alpha
24
26
 
25
- 1. Fork it ( http://github.com/<my-github-username>/ultron/fork )
26
- 2. Create your feature branch (`git checkout -b my-new-feature`)
27
- 3. Commit your changes (`git commit -am 'Add some feature'`)
28
- 4. Push to the branch (`git push origin my-new-feature`)
29
- 5. Create new Pull Request
27
+ I'm working this out as I go along, my API is liable to get bent out of all recognition before I'm done.
data/Rakefile CHANGED
@@ -8,4 +8,4 @@ RSpec::Core::RakeTask.new
8
8
  Cucumber::Rake::Task.new
9
9
 
10
10
  #task :default => [:spec, :cucumber, 'coveralls:push']
11
- task :default => [:spec]
11
+ task :default => [:spec, 'coveralls:push']
File without changes
@@ -0,0 +1,2 @@
1
+ host: http://gateway.marvel.com
2
+ path: /v1/public/
File without changes
@@ -1,6 +1,31 @@
1
+ require 'singleton'
2
+ require 'curb'
3
+ require 'dotenv'
4
+
1
5
  require 'ultron/version'
2
- require 'ultron/characters'
6
+ require 'ultron/helpers'
7
+ require 'ultron/config'
8
+ require 'ultron/connection'
9
+
10
+ require 'ultron/api/entity'
11
+ require 'ultron/api/entities'
12
+
13
+ require 'ultron/api/character'
14
+ require 'ultron/api/characters'
15
+
16
+ require 'ultron/api/comic'
17
+ require 'ultron/api/comics'
18
+
19
+ require 'ultron/api/creator'
20
+ require 'ultron/api/creators'
21
+
22
+ require 'ultron/api/event'
23
+ require 'ultron/api/events'
24
+
25
+ require 'ultron/api/series'
26
+ require 'ultron/api/serieses'
27
+
28
+ require 'ultron/api/story'
29
+ require 'ultron/api/stories'
3
30
 
4
- module Ultron
5
- # Your code goes here...
6
- end
31
+ require 'pry'
@@ -0,0 +1,19 @@
1
+ module Ultron
2
+ module API
3
+ class Character < Entity
4
+ def initialize id
5
+ @id = id
6
+ @path = 'characters/%s' % @id
7
+ super @path
8
+ end
9
+
10
+ def characters
11
+ nil
12
+ end
13
+
14
+ def creators
15
+ nil
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,14 @@
1
+ module Ultron
2
+ module API
3
+ class Characters < Entities
4
+ def initialize path = nil
5
+ path = 'characters' if path.nil?
6
+ super path
7
+ end
8
+
9
+ def [] key
10
+ Character.new results[key]['id']
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,15 @@
1
+ module Ultron
2
+ module API
3
+ class Comic < Entity
4
+ def initialize id
5
+ @id = id
6
+ @path = 'comics/%s' % @id
7
+ super @path
8
+ end
9
+
10
+ def comics
11
+ nil
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,14 @@
1
+ module Ultron
2
+ module API
3
+ class Comics < Entities
4
+ def initialize path = nil
5
+ path = 'comics' if path.nil?
6
+ super path
7
+ end
8
+
9
+ def [] key
10
+ Comic.new results[key]['id']
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,19 @@
1
+ module Ultron
2
+ module API
3
+ class Creator < Entity
4
+ def initialize id
5
+ @id = id
6
+ @path = 'creators/%s' % @id
7
+ super @path
8
+ end
9
+
10
+ def characters
11
+ nil
12
+ end
13
+
14
+ def creators
15
+ nil
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,14 @@
1
+ module Ultron
2
+ module API
3
+ class Creators < Entities
4
+ def initialize path = nil
5
+ path = 'creators' if path.nil?
6
+ super path
7
+ end
8
+
9
+ def [] key
10
+ Creator.new results[key]['id']
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,45 @@
1
+ module Ultron
2
+ module API
3
+ class Entities
4
+ include Enumerable
5
+
6
+ def initialize type
7
+ @cnxn = Ultron::Connection.new type
8
+ end
9
+
10
+ def each
11
+ results.each do |item|
12
+ yield item
13
+ end
14
+ end
15
+
16
+ def add_params params
17
+ @cnxn.add_params params
18
+ end
19
+
20
+ def remove_param p
21
+ @cnxn.remove_param p
22
+ end
23
+
24
+ def length
25
+ results.length
26
+ end
27
+
28
+ def results
29
+ @results || begin
30
+ @cnxn.perform['data']['results']
31
+ rescue NoMethodError
32
+ []
33
+ end
34
+ end
35
+
36
+ def method_missing method_name, *args
37
+ method_name = method_name.to_s
38
+ if param = method_name.match(/^by_(.*)/)[1]
39
+ @cnxn.add_params param => args.join(' ')
40
+ @cnxn.perform['data']['results'][0]
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,51 @@
1
+ module Ultron
2
+ module API
3
+ class Entity
4
+ def initialize path
5
+ @cnxn = Ultron::Connection.new path
6
+ end
7
+
8
+ def [] key
9
+ results[key]
10
+ end
11
+
12
+ def method_missing method_name, *args
13
+ results.send(method_name)
14
+ end
15
+
16
+ def results
17
+ @results || begin
18
+ OpenStruct.new @cnxn.perform['data']['results'][0]
19
+ end
20
+ end
21
+
22
+ def comics
23
+ Comics.new '%s/comics' % @path
24
+ end
25
+
26
+ def characters
27
+ Characters.new '%s/characters' % @path
28
+ end
29
+
30
+ def creators
31
+ Creators.new '%s/creators' % @path
32
+ end
33
+
34
+ def events
35
+ Events.new '%s/events' % @path
36
+ end
37
+
38
+ def serieses
39
+ Serieses.new '%s/serieses' % @path
40
+ end
41
+
42
+ def stories
43
+ Stories.new '%s/stories' % @path
44
+ end
45
+
46
+ def has_events?
47
+ events.any?
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,15 @@
1
+ module Ultron
2
+ module API
3
+ class Event < Entity
4
+ def initialize id
5
+ @id = id
6
+ @path = 'events/%s' % @id
7
+ super @path
8
+ end
9
+
10
+ def events
11
+ nil
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,14 @@
1
+ module Ultron
2
+ module API
3
+ class Events < Entities
4
+ def initialize path = nil
5
+ path = 'events' if path.nil?
6
+ super path
7
+ end
8
+
9
+ def [] key
10
+ Event.new results[key]['id']
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,23 @@
1
+ module Ultron
2
+ module API
3
+ class Series < Entity
4
+ def initialize id
5
+ @id = id
6
+ @path = 'series/%s' % @id
7
+ super @path
8
+ end
9
+
10
+ def comics
11
+ nil
12
+ end
13
+
14
+ def stories
15
+ nil
16
+ end
17
+
18
+ def serieses
19
+ nil
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,16 @@
1
+ module Ultron
2
+ module API
3
+ class Serieses < Entities
4
+ def initialize path = nil
5
+ path = 'series' if path.nil?
6
+ super path
7
+ end
8
+
9
+ def [] key
10
+ Series.new results[key]['id']
11
+ end
12
+
13
+ # something something delete_method
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,14 @@
1
+ module Ultron
2
+ module API
3
+ class Stories < Entities
4
+ def initialize path = nil
5
+ path = 'stories' if path.nil?
6
+ super path
7
+ end
8
+
9
+ def [] key
10
+ Story.new results[key]['id']
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,15 @@
1
+ module Ultron
2
+ module API
3
+ class Story < Entity
4
+ def initialize id
5
+ @id = id
6
+ @path = 'stories/%s' % @id
7
+ super @path
8
+ end
9
+
10
+ def stories
11
+ nil
12
+ end
13
+ end
14
+ end
15
+ end