thanos 0.0.1 → 0.5.0
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 +4 -4
- data/.gitignore +15 -0
- data/.hound.yml +64 -0
- data/.rspec +2 -0
- data/.rubocop.yml +2 -0
- data/.travis.yml +4 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +17 -18
- data/README.md +93 -16
- data/Rakefile +16 -0
- data/bin/console +13 -0
- data/bin/setup +7 -0
- data/lib/thanos.rb +9 -4
- data/lib/thanos/api/authentication.rb +19 -0
- data/lib/thanos/api/client.rb +26 -0
- data/lib/thanos/api/response.rb +16 -0
- data/lib/thanos/authentication.rb +5 -0
- data/lib/thanos/client.rb +21 -0
- data/lib/thanos/factories/character.rb +17 -0
- data/lib/thanos/factories/comic.rb +17 -0
- data/lib/thanos/factories/creator.rb +17 -0
- data/lib/thanos/factories/date.rb +17 -0
- data/lib/thanos/factories/event.rb +17 -0
- data/lib/thanos/factories/image.rb +17 -0
- data/lib/thanos/factories/item/character.rb +19 -0
- data/lib/thanos/factories/item/comic.rb +19 -0
- data/lib/thanos/factories/item/creator.rb +19 -0
- data/lib/thanos/factories/item/event.rb +23 -0
- data/lib/thanos/factories/item/series.rb +23 -0
- data/lib/thanos/factories/item/story.rb +19 -0
- data/lib/thanos/factories/price.rb +17 -0
- data/lib/thanos/factories/series.rb +17 -0
- data/lib/thanos/factories/story.rb +17 -0
- data/lib/thanos/factories/text_object.rb +17 -0
- data/lib/thanos/factories/thumbnail.rb +22 -0
- data/lib/thanos/factories/url.rb +17 -0
- data/lib/thanos/finders/character_finder.rb +28 -0
- data/lib/thanos/finders/comic_finder.rb +30 -0
- data/lib/thanos/finders/creator_finder.rb +31 -0
- data/lib/thanos/finders/event_finder.rb +26 -0
- data/lib/thanos/finders/finder_validator.rb +15 -0
- data/lib/thanos/finders/series_finder.rb +24 -0
- data/lib/thanos/finders/story_finder.rb +24 -0
- data/lib/thanos/mappers/character_data_mapper.rb +26 -0
- data/lib/thanos/mappers/comic_data_mapper.rb +41 -0
- data/lib/thanos/mappers/creator_data_mapper.rb +30 -0
- data/lib/thanos/mappers/event_data_mapper.rb +31 -0
- data/lib/thanos/mappers/mappable.rb +100 -0
- data/lib/thanos/mappers/series_data_mapper.rb +33 -0
- data/lib/thanos/mappers/story_data_mapper.rb +25 -0
- data/lib/thanos/resources/character.rb +19 -0
- data/lib/thanos/resources/comic.rb +27 -0
- data/lib/thanos/resources/creator.rb +13 -0
- data/lib/thanos/resources/date.rb +10 -0
- data/lib/thanos/resources/event.rb +26 -0
- data/lib/thanos/resources/image.rb +9 -0
- data/lib/thanos/resources/item/character.rb +20 -0
- data/lib/thanos/resources/item/comic.rb +20 -0
- data/lib/thanos/resources/item/creator.rb +19 -0
- data/lib/thanos/resources/item/event.rb +20 -0
- data/lib/thanos/resources/item/series.rb +18 -0
- data/lib/thanos/resources/item/story.rb +20 -0
- data/lib/thanos/resources/price.rb +10 -0
- data/lib/thanos/resources/series.rb +23 -0
- data/lib/thanos/resources/story.rb +18 -0
- data/lib/thanos/resources/text_object.rb +11 -0
- data/lib/thanos/resources/thumbnail.rb +11 -0
- data/lib/thanos/resources/url.rb +10 -0
- data/lib/thanos/response_holder.rb +10 -0
- data/lib/thanos/string_actions.rb +7 -0
- data/lib/thanos/version.rb +1 -1
- data/spikes/call_marvel_api.rb +50 -0
- data/spikes/call_marvel_via_thanos.rb +28 -0
- data/thanos.gemspec +44 -0
- metadata +171 -26
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'thanos/resources/character'
|
2
|
+
require 'thanos/mappers/character_data_mapper'
|
3
|
+
|
4
|
+
module Thanos
|
5
|
+
module Factory
|
6
|
+
class Character
|
7
|
+
def initialize(results)
|
8
|
+
@results = results
|
9
|
+
end
|
10
|
+
|
11
|
+
def build
|
12
|
+
attributes = Thanos::CharacterDataMapper.new(@results).map
|
13
|
+
Thanos::Character.new(attributes: attributes)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'thanos/mappers/comic_data_mapper'
|
2
|
+
require 'thanos/resources/comic'
|
3
|
+
|
4
|
+
module Thanos
|
5
|
+
module Factory
|
6
|
+
class Comic
|
7
|
+
def initialize(results)
|
8
|
+
@results = results
|
9
|
+
end
|
10
|
+
|
11
|
+
def build
|
12
|
+
attributes = Thanos::ComicDataMapper.new(@results).map
|
13
|
+
Thanos::Comic.new(attributes: attributes)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'thanos/mappers/creator_data_mapper'
|
2
|
+
require 'thanos/resources/creator'
|
3
|
+
|
4
|
+
module Thanos
|
5
|
+
module Factory
|
6
|
+
class Creator
|
7
|
+
def initialize(results)
|
8
|
+
@results = results
|
9
|
+
end
|
10
|
+
|
11
|
+
def build
|
12
|
+
attributes = Thanos::CreatorDataMapper.new(@results).map
|
13
|
+
Thanos::Creator.new(attributes: attributes)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'thanos/mappers/event_data_mapper'
|
2
|
+
require 'thanos/resources/event'
|
3
|
+
|
4
|
+
module Thanos
|
5
|
+
module Factory
|
6
|
+
class Event
|
7
|
+
def initialize(results)
|
8
|
+
@results = results
|
9
|
+
end
|
10
|
+
|
11
|
+
def build
|
12
|
+
attributes = Thanos::EventDataMapper.new(@results).map
|
13
|
+
Thanos::Event.new(attributes: attributes)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'thanos/resources/item/character'
|
2
|
+
|
3
|
+
module Thanos
|
4
|
+
module Factory
|
5
|
+
module Item
|
6
|
+
class Character
|
7
|
+
def initialize(results)
|
8
|
+
@results = results
|
9
|
+
end
|
10
|
+
|
11
|
+
def build
|
12
|
+
@results.collect do |character|
|
13
|
+
Thanos::Item::Character.new(character)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'thanos/resources/item/comic'
|
2
|
+
|
3
|
+
module Thanos
|
4
|
+
module Factory
|
5
|
+
module Item
|
6
|
+
class Comic
|
7
|
+
def initialize(results)
|
8
|
+
@results = results
|
9
|
+
end
|
10
|
+
|
11
|
+
def build
|
12
|
+
@results.collect do |comic|
|
13
|
+
Thanos::Item::Comic.new(comic)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'thanos/resources/item/creator'
|
2
|
+
|
3
|
+
module Thanos
|
4
|
+
module Factory
|
5
|
+
module Item
|
6
|
+
class Creator
|
7
|
+
def initialize(results)
|
8
|
+
@results = results
|
9
|
+
end
|
10
|
+
|
11
|
+
def build
|
12
|
+
@results.collect do |comic|
|
13
|
+
Thanos::Item::Creator.new(comic)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'thanos/resources/item/event'
|
2
|
+
|
3
|
+
module Thanos
|
4
|
+
module Factory
|
5
|
+
module Item
|
6
|
+
class Event
|
7
|
+
def initialize(results)
|
8
|
+
@results = results
|
9
|
+
end
|
10
|
+
|
11
|
+
def build
|
12
|
+
if @results.is_a?(Array)
|
13
|
+
@results.collect do |comic|
|
14
|
+
Thanos::Item::Event.new(comic)
|
15
|
+
end
|
16
|
+
else
|
17
|
+
[Thanos::Item::Event.new(@results)]
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'thanos/resources/item/series'
|
2
|
+
|
3
|
+
module Thanos
|
4
|
+
module Factory
|
5
|
+
module Item
|
6
|
+
class Series
|
7
|
+
def initialize(results)
|
8
|
+
@results = results
|
9
|
+
end
|
10
|
+
|
11
|
+
def build
|
12
|
+
if @results.is_a?(Array)
|
13
|
+
@results.collect do |comic|
|
14
|
+
Thanos::Item::Series.new(comic)
|
15
|
+
end
|
16
|
+
else
|
17
|
+
[Thanos::Item::Series.new(@results)]
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'thanos/resources/item/story'
|
2
|
+
|
3
|
+
module Thanos
|
4
|
+
module Factory
|
5
|
+
module Item
|
6
|
+
class Story
|
7
|
+
def initialize(results)
|
8
|
+
@results = results
|
9
|
+
end
|
10
|
+
|
11
|
+
def build
|
12
|
+
@results.collect do |comic|
|
13
|
+
Thanos::Item::Story.new(comic)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'thanos/mappers/series_data_mapper'
|
2
|
+
require 'thanos/resources/series'
|
3
|
+
|
4
|
+
module Thanos
|
5
|
+
module Factory
|
6
|
+
class Series
|
7
|
+
def initialize(results)
|
8
|
+
@results = results
|
9
|
+
end
|
10
|
+
|
11
|
+
def build
|
12
|
+
attributes = Thanos::SeriesDataMapper.new(@results).map
|
13
|
+
Thanos::Series.new(attributes: attributes)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'thanos/mappers/story_data_mapper'
|
2
|
+
require 'thanos/resources/story'
|
3
|
+
|
4
|
+
module Thanos
|
5
|
+
module Factory
|
6
|
+
class Story
|
7
|
+
def initialize(results)
|
8
|
+
@results = results
|
9
|
+
end
|
10
|
+
|
11
|
+
def build
|
12
|
+
attributes = Thanos::StoryDataMapper.new(@results).map
|
13
|
+
Thanos::Story.new(attributes: attributes)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'thanos/resources/text_object'
|
2
|
+
|
3
|
+
module Thanos
|
4
|
+
module Factory
|
5
|
+
class TextObject
|
6
|
+
def initialize(text_objects)
|
7
|
+
@text_objects = text_objects
|
8
|
+
end
|
9
|
+
|
10
|
+
def build
|
11
|
+
@text_objects.collect do |text_object|
|
12
|
+
Thanos::TextObject.new(text_object)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'thanos/resources/thumbnail'
|
2
|
+
|
3
|
+
module Thanos
|
4
|
+
module Factory
|
5
|
+
class Thumbnail
|
6
|
+
def initialize(thumbnails)
|
7
|
+
@thumbnails = thumbnails
|
8
|
+
end
|
9
|
+
|
10
|
+
def build
|
11
|
+
# TODO: Determine if an array is ever possible.
|
12
|
+
# If this is possible, I will need the following:
|
13
|
+
# if @thumbnails.is_a?(Array)
|
14
|
+
# @thumbnails.collect do |thumbnail|
|
15
|
+
# Thanos::Thumbnail.new(thumbnail)
|
16
|
+
# end
|
17
|
+
# else
|
18
|
+
Thanos::Thumbnail.new(@thumbnails)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'thanos/response_holder'
|
2
|
+
require 'thanos/string_actions'
|
3
|
+
require 'thanos/api/client'
|
4
|
+
require 'thanos/factories/character'
|
5
|
+
require 'thanos/finders/finder_validator'
|
6
|
+
|
7
|
+
module Thanos
|
8
|
+
class CharacterFinder
|
9
|
+
ATTRIBUTES = [:name, :comics, :series, :events, :series,
|
10
|
+
:nameStartsWith, :modifiedSince]
|
11
|
+
|
12
|
+
ATTRIBUTES.each do |attribute|
|
13
|
+
parameter = StringActions.parameterize(attribute.to_s)
|
14
|
+
define_method("find_by_#{parameter}") do |attr|
|
15
|
+
find("#{attribute}".to_sym => attr)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def find(attribute)
|
22
|
+
FinderValidator.validate(attribute, ATTRIBUTES)
|
23
|
+
response = Thanos::API::Client.new.get(:characters, attribute)
|
24
|
+
results = Thanos::ResponseHolder.new(response).results
|
25
|
+
Thanos::Factory::Character.new(results).build
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'thanos/api/client'
|
2
|
+
require 'thanos/response_holder'
|
3
|
+
require 'thanos/string_actions'
|
4
|
+
require 'thanos/factories/comic'
|
5
|
+
require 'thanos/finders/finder_validator'
|
6
|
+
|
7
|
+
module Thanos
|
8
|
+
class ComicFinder
|
9
|
+
ATTRIBUTES = [:title, :titleStarsWith, :format, :formatType, :upc, :isbn,
|
10
|
+
:issn, :ean, :noVariants, :digitalId, :hasDigitalIssue,
|
11
|
+
:issueNumber, :dateDescriptor, :dateRange, :startYear,
|
12
|
+
:modifiedSince, :diamondCode, :sharedAppearances,
|
13
|
+
:collaborators, :creators, :characters, :series, :events,
|
14
|
+
:stories]
|
15
|
+
|
16
|
+
ATTRIBUTES.each do |attribute|
|
17
|
+
parameter = StringActions.parameterize(attribute.to_s)
|
18
|
+
define_method("find_by_#{parameter}") do |attr|
|
19
|
+
find("#{attribute}".to_sym => attr)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def find(attribute)
|
24
|
+
FinderValidator.validate(attribute, ATTRIBUTES)
|
25
|
+
response = Thanos::API::Client.new.get(:comics, attribute)
|
26
|
+
results = Thanos::ResponseHolder.new(response).results
|
27
|
+
Thanos::Factory::Comic.new(results).build
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'thanos/response_holder'
|
2
|
+
require 'thanos/string_actions'
|
3
|
+
require 'thanos/api/client'
|
4
|
+
require 'thanos/factories/creator'
|
5
|
+
require 'thanos/finders/finder_validator'
|
6
|
+
|
7
|
+
module Thanos
|
8
|
+
class CreatorFinder
|
9
|
+
ATTRIBUTES = [:firstName, :middleName, :lastName, :suffix,
|
10
|
+
:nameStartsWith, :firstNameStartsWith,
|
11
|
+
:middleNameStartsWith, :lastNameStartsWith,
|
12
|
+
:modifiedSince, :comics, :series, :events,
|
13
|
+
:stories]
|
14
|
+
|
15
|
+
ATTRIBUTES.each do |attribute|
|
16
|
+
parameter = StringActions.parameterize(attribute.to_s)
|
17
|
+
define_method("find_by_#{parameter}") do |attr|
|
18
|
+
find("#{attribute}".to_sym => attr)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def find(attribute)
|
25
|
+
FinderValidator.validate(attribute, ATTRIBUTES)
|
26
|
+
response = Thanos::API::Client.new.get(:creators, attribute)
|
27
|
+
results = Thanos::ResponseHolder.new(response).results
|
28
|
+
Thanos::Factory::Creator.new(results).build
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|