comicvine-mongo 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 34cf61f387ea7c4cb89bebc48c9f8fb9df50f9f0
4
+ data.tar.gz: 6f7e118f2a83c1e7754ebda4544833a687952504
5
+ SHA512:
6
+ metadata.gz: e9ce4b53dcf99f7a91637c5b94600b8b047274d53b9591bde959839ef6f7b58878956d7ce2a1f8f5cb7a0d3b5824ce3a92b4486965009787f46a196e11e8cbb0
7
+ data.tar.gz: d43fd87b9b1dd65ae8032d459e3e94d60755a4e1e3b463cff1538d044fba1b1bf6f8d92b1eb67cc89e62175bb668b590ea17223f6bd79dbfadb331cf6c987cd7
checksums.yaml.gz.sig ADDED
Binary file
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.1
5
+ before_install: gem install bundler -v 1.13.6
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in comicvine-mongo.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Holden Omans
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,76 @@
1
+ # ComicVine::Mongo
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/comicvine/mongo`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'comicvine-mongo'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install comicvine-mongo
22
+
23
+ You additionally will need to set up your ComicVine Api key [[See the comicvine gem page](https://github.com/kalinon/ruby-comicvine-api)] as well as set up your mongoid connection [[See mongoid documentaion](https://docs.mongodb.com/ruby-driver/master/tutorials/6.0.0/mongoid-installation/#configuration)]
24
+
25
+ ```ruby
26
+ # Example config
27
+ ComicVine::API.api_key = '18357f40df87fb4a4aa6bbbb27cd8ad1deb08d3e'
28
+ Mongoid.load!('/path/to/mongo.yml', :env_name)
29
+ ```
30
+ ## Usage
31
+
32
+ You can use the same syntax used with the comicvine gem to interact with the api. Now, however, you functions will return a resource subclass appropriate for the api call
33
+
34
+ ```ruby
35
+ ComicVine::API.get_details(:issue, 6) #=> ComicVine::Resource::Issue
36
+ ```
37
+
38
+ These are subclasses of ComicVine::Resource and are each a [Mongoid::Document](http://www.rubydoc.info/github/mongoid/mongoid/Mongoid/Document). Here are the current subclasses:
39
+
40
+ > Character, Concept, Episode, Issue, Location, Movie, Object, Origin, Person, Power, Promo, Publisher, Series, StoryArc, Team, Volume
41
+
42
+ Here is some example usages:
43
+
44
+ ```ruby
45
+ # Gather an issue from the api
46
+ issue = ComicVine::API.get_details(:issue, 6)
47
+ # You can then save the issue
48
+ issue.save!
49
+ # You can also then save its parent and children objects (i.e Publisher, Characters, etc)
50
+ issue.save_assoc!
51
+
52
+ # You can also query objects that were saved via Mongoid
53
+ pub = ComicVine::Resource::Publisher.find(4)
54
+ # To update the object with newest API information or to fill missing children/parent relations
55
+ pub.fetch!
56
+ # Then you can save your changes
57
+ pub.save!
58
+ pub.save_assoc!
59
+ ```
60
+
61
+
62
+ ## Development
63
+
64
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
65
+
66
+ To install this gem onto your local machine, run `gem install comicvine`. Or you can download it from https://rubygems.org/gems/comicvine-mongo
67
+
68
+ ## Contributing
69
+
70
+ Bug reports and pull requests are welcome on GitHub at https://github.com/kalinon/ruby-comicvine-mongo.
71
+
72
+
73
+ ## License
74
+
75
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
76
+
data/Rakefile ADDED
@@ -0,0 +1,42 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rake/testtask'
3
+ require 'yard'
4
+
5
+ # Test tasks
6
+ Rake::TestTask.new(:test) do |t|
7
+ t.libs << 'test'
8
+ t.libs << 'lib'
9
+ t.test_files = FileList['test/**/*_test.rb']
10
+ t.warning = false
11
+ end
12
+
13
+ YARD::Rake::YardocTask.new do |t|
14
+ begin
15
+ #require 'yard-mongoid'
16
+ rescue LoadError => e
17
+ puts 'Could not require yard-mongoid'
18
+ end
19
+
20
+ t.files = ['lib/**/*.rb'] # optional
21
+ t.options = %w{--private} # optional
22
+ t.stats_options = ['--list-undoc'] # optional
23
+ end
24
+
25
+ # Default task
26
+ task :default => :test
27
+
28
+ task :console do
29
+ require 'irb'
30
+ require 'irb/completion'
31
+ require 'comicvine/scraper' # You know what to do.
32
+ ARGV.clear
33
+ IRB.start
34
+ end
35
+
36
+ Rake::Task['build'].enhance do
37
+ require 'digest/sha2'
38
+ built_gem_path = 'pkg/comicvine-mongo-'+ComicVine::Mongo::VERSION+'.gem'
39
+ checksum = Digest::SHA256.new.hexdigest(File.read(built_gem_path))
40
+ checksum_path = 'checksum/comicvine-mongo-'+ComicVine::Mongo::VERSION+'.gem.sha256'
41
+ File.open(checksum_path, 'w' ) {|f| f.write(checksum) }
42
+ end
data/bin/console ADDED
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'comicvine/mongo'
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ ENV['RACK_ENV'] = 'development'
14
+ #Mongoid.load!(File.join(File.expand_path('../../test', __FILE__), 'mongo.yml'), ENV['RACK_ENV'])
15
+
16
+
17
+ require 'irb'
18
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/certs/homans.pem ADDED
@@ -0,0 +1,21 @@
1
+ -----BEGIN CERTIFICATE-----
2
+ MIIDgDCCAmigAwIBAgIBATANBgkqhkiG9w0BAQUFADBDMRUwEwYDVQQDDAxob2xk
3
+ ZW4ub21hbnMxFTATBgoJkiaJk/IsZAEZFgVnbWFpbDETMBEGCgmSJomT8ixkARkW
4
+ A2NvbTAeFw0xNjExMDkxNTU5MTdaFw0xNzExMDkxNTU5MTdaMEMxFTATBgNVBAMM
5
+ DGhvbGRlbi5vbWFuczEVMBMGCgmSJomT8ixkARkWBWdtYWlsMRMwEQYKCZImiZPy
6
+ LGQBGRYDY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2V7yrTuO
7
+ 4FNzWlhQL2R8Vdx5LKX/oewZ7bKh/2GJcR5R7mowdqejlfzJb7abtmYsQfyvwNfy
8
+ NrKneghJ/rLflQ1NrlehYSYLlBFTVuymPvejG+EH5C2/RJqhm2zyfjkisasqhWk8
9
+ Bq6IUPX1l8C78Kkd6t3QR/n3zr1Ip25NicpJ2flBMHPg3IV9qaNXywkCzutkEMoW
10
+ FuHdHMN2cDMUnhM9qGOK7nvRk7rkP/yJAp+sf2nv+C99s5CMNuvnGeSgnX7IMcRV
11
+ Ks2FrSvqKDj24Xf5kHdlcpDrS1VcFsAkIT6bVBm19KO8pFvZkDJE76Yshy80FRpQ
12
+ bijjrYQhYXiM4QIDAQABo38wfTAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNV
13
+ HQ4EFgQUbbbHhJ0Z4S/c5FcDSqEVx7Yk1agwIQYDVR0RBBowGIEWaG9sZGVuLm9t
14
+ YW5zQGdtYWlsLmNvbTAhBgNVHRIEGjAYgRZob2xkZW4ub21hbnNAZ21haWwuY29t
15
+ MA0GCSqGSIb3DQEBBQUAA4IBAQCoC/7FnCsRFIV/rwAJRXY3Ao0qdbnksPrqUhP0
16
+ 7A8m8PccIDuUspq/WtkhzSMLZvzurlXEw1qdLtRLS2LnftQQuo5YPz6PQj4XAx8w
17
+ yF48j5e3XvUZJiMQ+cIsXPnjes13JgnP/KOfILgfIz9ad0pGMMUCTLYahu+fXqxE
18
+ if+otWjB2is7MBxd+krcr8vCJ4E46a8H3zyBN/tSgGw4RwkxHnXekTJvMy4skcSB
19
+ VpDNqh/BlGMQ0mqAEuBFZFSNaroph6JLUz1ykVvQENOQLThxAjolK7SAUrdoBDOc
20
+ fXEVP1s+hpJB6IEU8/LW016TU8WpnA+MHGfJRtkrUm/cEsWU
21
+ -----END CERTIFICATE-----
@@ -0,0 +1 @@
1
+ c41a9e3d7ea4f6345b6f8aed801de86dd2e15c1544f35e69b335839eb5d61a6e
@@ -0,0 +1,39 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'comicvine/mongo/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'comicvine-mongo'
8
+ spec.version = ComicVine::Mongo::VERSION
9
+ spec.authors = ['Holden Omans']
10
+ spec.email = ['holden.omans@gmail.com']
11
+
12
+ spec.summary = %q{Mongo extension to the comicvine gem}
13
+ spec.description = %q{Allows saving of comicvine resources to a Mongodb using Mongoid}
14
+ spec.homepage = 'https://github.com/kalinon/ruby-comicvine-mongo'
15
+ spec.license = 'MIT'
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+ spec.bindir = 'exe'
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ['lib']
23
+ spec.required_ruby_version = '>= 2.2'
24
+
25
+ spec.cert_chain = ['certs/homans.pem']
26
+ spec.signing_key = File.expand_path('~/.ssh/gem-private_key.pem') if $0 =~ /gem\z/
27
+
28
+ spec.add_development_dependency 'bundler', '~> 1.13'
29
+ spec.add_development_dependency 'rake', '~> 10.0'
30
+ spec.add_development_dependency 'minitest', '~> 5.9', '>= 5.9.1'
31
+ spec.add_development_dependency 'minitest-reporters', '~> 1.1', '>= 1.1.12'
32
+ spec.add_development_dependency 'rdoc', '~> 4.2', '>= 4.2.1'
33
+ spec.add_development_dependency 'yard', '~> 0.9', '>= 0.9.5'
34
+ #spec.add_development_dependency 'yard-mongoid', '~> 0.0.4' # pending merge acceptance and update
35
+
36
+ # Dependencies
37
+ spec.add_dependency 'comicvine', '~> 0.1', '>= 0.1.2'
38
+ spec.add_dependency 'mongoid', '~> 6.0', '>= 6.0.2'
39
+ end
@@ -0,0 +1,5 @@
1
+ module ComicVine
2
+ module Mongo
3
+ VERSION = '0.1.0'
4
+ end
5
+ end
@@ -0,0 +1,783 @@
1
+ require 'comicvine/mongo/version'
2
+ require 'comicvine'
3
+ require 'mongoid'
4
+
5
+ ## Yardoc macros
6
+ # @!macro [new] return.sub_resources
7
+ # @return [ Resource::Character, Resource::Concept, Resource::Episode, Resource::Issue, Resource::Location, Resource::Movie, Resource::Object, Resource::Origin, Resource::Person, Resource::Power, Resource::Promo, Resource::Publisher, Resource::Series, Resource::StoryArc, Resource::Team, Resource::Volume ]
8
+
9
+
10
+ module ComicVine
11
+
12
+ ##
13
+ # Module to hold our mongoid specific methods and overrides for {ComicVine::Resource}
14
+ # @since 0.1.0
15
+ module Mongo
16
+ ##
17
+ # Replaces the default {ComicVine::Resource::initialize} function, allowing us to create mongo enabled classes
18
+ # @since 0.1.0
19
+ def initialize(args)
20
+
21
+ args.each do |k, v|
22
+
23
+ # Convert sub arrays to objects
24
+ v.collect! { |i| ComicVine::Resource::create_resource(i) } if v.kind_of?(Array) && !v.empty? && v.first.key?('api_detail_url')
25
+
26
+ # Convert sub hashes to objects
27
+ if v.kind_of?(Hash) && v.key?('api_detail_url')
28
+ v = ComicVine::Resource::create_resource(v)
29
+ end
30
+
31
+ # Set the instance variable to value
32
+ args[k] = v
33
+ end
34
+ #puts args.to_json
35
+ super
36
+ end
37
+
38
+ ##
39
+ # Cycles through associated id's on the object and loads/fetches the child/parent objects and saves them to mongo
40
+ # @since 0.1.0
41
+ def save_assoc!
42
+ # Identify methods that end in id or ids
43
+ self.methods.each do |attr|
44
+ # Match attribute ids
45
+ next if attr !~ /^(?!_)([\w\d\_]+)(_ids?)$/
46
+
47
+ # endings with ids imply multiple
48
+ if attr =~ /^(?!_)([\w\d\_]+)(_ids)$/
49
+ assoc = $1.to_s.pluralize.to_sym
50
+
51
+ next if self.reflect_on_association(assoc).nil?
52
+
53
+ meta = self.reflect_on_association(assoc)
54
+ self.method(attr).call.each do |id|
55
+ obj = self._fetch_by_assoc_and_id(meta, id)
56
+ obj.fetch!.save! unless obj.nil?
57
+ end
58
+ elsif attr =~ /^(?!_)([\w\d\_]+)(_id)$/
59
+ assoc = $1.to_s.to_sym
60
+
61
+ next if self.reflect_on_association(assoc).nil?
62
+
63
+ meta = self.reflect_on_association(assoc)
64
+ obj = self._fetch_by_assoc_and_id(meta, self.method(attr).call)
65
+ obj.fetch!.save! unless obj.nil?
66
+ else
67
+ next
68
+ end
69
+ end
70
+ end
71
+
72
+ ##
73
+ # Will parse the relation metadata to identify the class and resource type. A check is performed to see if it is saved in the mongodb, if so it will then load it. It will then query ComicVine::API for the latest information, and return the resource
74
+ # @param meta [Mongoid::Relations::Metadata]
75
+ # @param id [Integer]
76
+ # @macro return.sub_resources
77
+ # @since 0.1.0
78
+ def _fetch_by_assoc_and_id(meta, id)
79
+ if Object.class_eval(meta.class_name).where(id: id).exists?
80
+ Object.class_eval(meta.class_name).find(id)
81
+ else
82
+ type = meta.class_name.demodulize.underscore.to_sym
83
+
84
+ if ComicVine::API.find_detail(type).nil?
85
+ nil
86
+ else
87
+ resource_name = ComicVine::API.find_detail(type)['detail_resource_name'].to_sym
88
+
89
+ begin
90
+ ComicVine::API.get_details(resource_name, id)
91
+ rescue ComicVine::API::ComicVineAPIError
92
+ return nil
93
+ end
94
+
95
+ end
96
+ end
97
+ end
98
+ end
99
+
100
+ class Resource
101
+
102
+ ##
103
+ # Takes hash and returns a {http://www.rubydoc.info/github/mongoid/mongoid/Mongoid/Document Mongoid::Document} subclass of {ComicVine::Resource} based on identified type
104
+ #
105
+ # @example
106
+ # ComicVine::Resource.create_resource(hash) #=> #<ComicVine::Resource::Issue:0x007fa6a427bbe8>
107
+ #
108
+ # @param attr [Hash]
109
+ # @macro return.sub_resources
110
+ # @since 0.1.0
111
+ def self.create_resource(attr)
112
+ type = ComicVine::Resource::identify_and_update_response(attr)
113
+
114
+ if type
115
+
116
+ # if its a review the api doesnt actually exist, so return the hash
117
+ return attr if type.equal? :review
118
+
119
+ c = Object.class_eval('ComicVine::Resource::' + type.to_s.camelcase)
120
+
121
+ if c.where(id: attr['id']).exists?
122
+ c.find(attr['id'])
123
+ else
124
+ c.new attr
125
+ end
126
+ else
127
+ raise ScriptError, 'Unknown type for api_detail_url: ' + attr['api_detail_url']
128
+ end
129
+ end
130
+
131
+ ##
132
+ # Extends {ComicVine::Resource::Issue} to add mongoid functions
133
+ # @since 0.1.2
134
+ class Issue < ComicVine::Resource
135
+ include Mongoid::Document
136
+ include ComicVine::Mongo
137
+
138
+ field :aliases, type: String
139
+ field :api_detail_url, type: String
140
+ field :cover_date, type: Date
141
+ field :date_added, type: DateTime
142
+ field :date_last_updated, type: DateTime
143
+ field :deck, type: String
144
+ field :description, type: String
145
+ field :has_staff_review, type: Hash
146
+ field :id, type: Integer
147
+ field :image, type: Hash
148
+ field :issue_number, type: Integer
149
+ field :name, type: String
150
+ field :site_detail_url, type: String
151
+ field :store_date, type: Date
152
+
153
+ ##
154
+ # Accounts for ComicVine's miss-match return of false if no review exists. Sets an empty hash
155
+ # @param value [Hash]
156
+ # @since 0.1.0
157
+ def has_staff_review=(value)
158
+ if value.nil? || value.kind_of?(FalseClass)
159
+ self.has_staff_review = {}
160
+ else
161
+ super
162
+ end
163
+ end
164
+
165
+ ##
166
+ # @return [true, false]
167
+ def has_staff_review?
168
+ !self.has_staff_review.empty?
169
+ end
170
+
171
+
172
+ belongs_to :volume, class_name: 'ComicVine::Resource::Volume', inverse_of: :issues, optional: true
173
+
174
+ has_many :first_appearance_teams, class_name: 'ComicVine::Resource::Team', inverse_of: :first_appeared_in_issue, validate: false
175
+ has_and_belongs_to_many :team_credits, class_name: 'ComicVine::Resource::Team', inverse_of: :issue_credits, validate: false
176
+ has_and_belongs_to_many :team_disbanded_in, class_name: 'ComicVine::Resource::Team', inverse_of: :issues_disbanded_in, validate: false
177
+
178
+ has_many :first_appearance_characters, class_name: 'ComicVine::Resource::Character', inverse_of: :first_appeared_in_issue, validate: false
179
+ has_and_belongs_to_many :character_credits, class_name: 'ComicVine::Resource::Character', inverse_of: :issue_credits, validate: false
180
+ has_and_belongs_to_many :character_died_in, class_name: 'ComicVine::Resource::Character', inverse_of: :issues_died_in, validate: false
181
+
182
+ has_many :first_appearance_concepts, class_name: 'ComicVine::Resource::Concept', inverse_of: :first_appeared_in_issue, validate: false
183
+ has_and_belongs_to_many :concept_credits, class_name: 'ComicVine::Resource::Concept', inverse_of: :issue_credits, validate: false
184
+
185
+ has_many :first_appearance_objects, class_name: 'ComicVine::Resource::Object', inverse_of: :first_appeared_in_issue, validate: false
186
+ has_and_belongs_to_many :object_credits, class_name: 'ComicVine::Resource::Object', inverse_of: :issue_credits, validate: false
187
+
188
+ has_many :first_appearance_storyarcs, class_name: 'ComicVine::Resource::StoryArc', inverse_of: :first_appeared_in_issue, validate: false
189
+ has_and_belongs_to_many :story_arc_credits, class_name: 'ComicVine::Resource::StoryArc', inverse_of: :issues, validate: false
190
+
191
+ has_many :first_appearance_locations, class_name: 'ComicVine::Resource::Location', inverse_of: :first_appeared_in_issue, validate: false
192
+ has_and_belongs_to_many :location_credits, class_name: 'ComicVine::Resource::Location', inverse_of: :issue_credits, validate: false
193
+
194
+ has_and_belongs_to_many :person_credits, class_name: 'ComicVine::Resource::Person', inverse_of: :issue_credits, validate: false
195
+ end
196
+
197
+ ##
198
+ # Extends {ComicVine::Resource::Volume} to add mongoid functions
199
+ # @since 0.1.2
200
+ class Volume < ComicVine::Resource
201
+ include Mongoid::Document
202
+ include ComicVine::Mongo
203
+
204
+ field :aliases, type: String
205
+ field :api_detail_url, type: String
206
+ field :count_of_issues, type: Integer
207
+ field :date_added, type: DateTime
208
+ field :date_last_updated, type: DateTime
209
+ field :deck, type: String
210
+ field :description, type: String
211
+ field :id, type: Integer
212
+ field :image, type: Hash
213
+ field :name, type: String
214
+ field :site_detail_url, type: String
215
+ field :start_year, type: Integer
216
+
217
+ has_and_belongs_to_many :teams, class_name: 'ComicVine::Resource::Team', inverse_of: :volume_credits, validate: false
218
+ has_and_belongs_to_many :characters, class_name: 'ComicVine::Resource::Character', inverse_of: :volume_credits, validate: false
219
+ has_and_belongs_to_many :concepts, class_name: 'ComicVine::Resource::Concept', inverse_of: :volume_credits, validate: false
220
+
221
+ has_many :issues, class_name: 'ComicVine::Resource::Issue', inverse_of: :volume, validate: false
222
+ has_one :first_issue, class_name: 'ComicVine::Resource::Issue', validate: false
223
+ has_one :last_issue, class_name: 'ComicVine::Resource::Issue', validate: false
224
+
225
+ has_and_belongs_to_many :locations, class_name: 'ComicVine::Resource::Location', inverse_of: :volume_credits, validate: false
226
+ has_and_belongs_to_many :objects, class_name: 'ComicVine::Resource::Object', inverse_of: :volume_credits, validate: false
227
+ has_and_belongs_to_many :people, class_name: 'ComicVine::Resource::Person', inverse_of: :volume_credits, validate: false
228
+
229
+ belongs_to :publisher, class_name: 'ComicVine::Resource::Publisher', inverse_of: :volumes, validate: false
230
+
231
+ end
232
+
233
+ ##
234
+ # Extends {ComicVine::Resource::Character} to add mongoid functions
235
+ # # @since 0.1.2
236
+ class Character < ComicVine::Resource
237
+ include Mongoid::Document
238
+ include ComicVine::Mongo
239
+
240
+ field :aliases, type: String
241
+ field :api_detail_url, type: String
242
+ field :date_added, type: DateTime
243
+ field :date_last_updated, type: DateTime
244
+ field :deck, type: String
245
+ field :description, type: String
246
+ field :id, type: Integer
247
+ field :image, type: Hash
248
+ field :name, type: String
249
+ field :site_detail_url, type: String
250
+ field :birth, type: String
251
+ field :count_of_issue_appearances, type: Integer
252
+ field :real_name, type: String
253
+ field :gender, type: Integer
254
+
255
+ has_and_belongs_to_many :character_enemies, class_name: 'ComicVine::Resource::Character', inverse_of: nil, validate: false
256
+ has_and_belongs_to_many :character_friends, class_name: 'ComicVine::Resource::Character', inverse_of: nil, validate: false
257
+
258
+ belongs_to :origin, class_name: 'ComicVine::Resource::Origin', inverse_of: :characters, validate: false, optional: true
259
+
260
+ has_and_belongs_to_many :creators, class_name: 'ComicVine::Resource::Person', inverse_of: :created_characters, validate: false
261
+
262
+ belongs_to :first_appeared_in_issue, class_name: 'ComicVine::Resource::Issue', inverse_of: :first_appearance_characters, validate: false
263
+ has_and_belongs_to_many :issue_credits, class_name: 'ComicVine::Resource::Issue', inverse_of: :character_credits, validate: false
264
+ has_and_belongs_to_many :issues_died_in, class_name: 'ComicVine::Resource::Issue', inverse_of: :character_died_in, validate: false
265
+
266
+ has_and_belongs_to_many :movies, class_name: 'ComicVine::Resource::Movie', inverse_of: :characters, validate: false
267
+ has_and_belongs_to_many :powers, class_name: 'ComicVine::Resource::Power', inverse_of: :characters, validate: false
268
+
269
+ belongs_to :publisher, class_name: 'ComicVine::Resource::Publisher', inverse_of: :characters, validate: false
270
+ has_and_belongs_to_many :story_arc_credits, class_name: 'ComicVine::Resource::StoryArc', inverse_of: :characters, validate: false
271
+
272
+ has_and_belongs_to_many :team_enemies, class_name: 'ComicVine::Resource::Team', inverse_of: nil, validate: false
273
+ has_and_belongs_to_many :team_friends, class_name: 'ComicVine::Resource::Team', inverse_of: nil, validate: false
274
+ has_and_belongs_to_many :teams, class_name: 'ComicVine::Resource::Team', inverse_of: :characters, validate: false
275
+
276
+ has_and_belongs_to_many :volume_credits, class_name: 'ComicVine::Resource::Volume', inverse_of: :characters, validate: false
277
+
278
+ accepts_nested_attributes_for :origin, :publisher, :first_appeared_in_issue, validate: false
279
+ end
280
+
281
+ ##
282
+ # Extends {ComicVine::Resource::Concept} to add mongoid functions
283
+ # @since 0.1.2
284
+ class Concept < ComicVine::Resource
285
+ include Mongoid::Document
286
+ include ComicVine::Mongo
287
+
288
+ field :aliases, type: String
289
+ field :api_detail_url, type: String
290
+ field :date_added, type: DateTime
291
+ field :date_last_updated, type: DateTime
292
+ field :deck, type: String
293
+ field :description, type: String
294
+ field :id, type: Integer
295
+ field :image, type: Hash
296
+ field :name, type: String
297
+ field :site_detail_url, type: String
298
+ field :count_of_issue_appearances, type: Integer
299
+ field :start_year, type: Integer
300
+
301
+ ##
302
+ # Accounts for ComicVine's miss-spelling of issue in key. Maps count_of_isssue_appearances to count_of_issue_appearances
303
+ # @param value [Integer]
304
+ # @since 0.1.0
305
+ def count_of_isssue_appearances=(value)
306
+ self[:count_of_issue_appearances] = value
307
+ end
308
+
309
+ ##
310
+ # Accounts for ComicVine's miss-spelling of issue in key. returns count_of_issue_appearances
311
+ # @return [Integer]
312
+ # @since 0.1.0
313
+ def count_of_isssue_appearances
314
+ self[:count_of_issue_appearances]
315
+ end
316
+
317
+ belongs_to :first_appeared_in_issue, class_name: 'ComicVine::Resource::Issue', inverse_of: :first_appearance_concepts, validate: false
318
+ has_and_belongs_to_many :issue_credits, class_name: 'ComicVine::Resource::Issue', inverse_of: :concept_credits, validate: false
319
+ has_and_belongs_to_many :movies, class_name: 'ComicVine::Resource::Movie', inverse_of: :concept_credits, validate: false
320
+ has_and_belongs_to_many :volume_credits, class_name: 'ComicVine::Resource::Volume', inverse_of: :concepts, validate: false
321
+
322
+ end
323
+
324
+ ##
325
+ # Extends {ComicVine::Resource::Episode} to add mongoid functions
326
+ # @since 0.1.2
327
+ class Episode < ComicVine::Resource
328
+ include Mongoid::Document
329
+ include ComicVine::Mongo
330
+
331
+ field :aliases, type: String
332
+ field :api_detail_url, type: String
333
+ field :date_added, type: DateTime
334
+ field :date_last_updated, type: DateTime
335
+ field :deck, type: String
336
+ field :description, type: String
337
+ field :id, type: Integer
338
+ field :image, type: Hash
339
+ field :name, type: String
340
+ field :site_detail_url, type: String
341
+ field :has_staff_review, type: Hash
342
+ field :episode_number, type: Integer
343
+ field :air_date, type: Date
344
+
345
+ ##
346
+ # Accounts for ComicVine's miss-match return of false if no review exists. Sets an empty hash
347
+ # @param value [Hash]
348
+ # @since 0.1.0
349
+ def has_staff_review=(value)
350
+ if value.nil? || value.kind_of?(FalseClass)
351
+ self.has_staff_review = {}
352
+ else
353
+ super
354
+ end
355
+ end
356
+
357
+ ##
358
+ # @return [true, false]
359
+ def has_staff_review?
360
+ !self.has_staff_review.empty?
361
+ end
362
+
363
+
364
+ has_and_belongs_to_many :character_credits, class_name: 'ComicVine::Resource::Character', inverse_of: nil, validate: false
365
+ has_and_belongs_to_many :characters_died_in, class_name: 'ComicVine::Resource::Character', inverse_of: nil, validate: false
366
+ has_and_belongs_to_many :concept_credits, class_name: 'ComicVine::Resource::Concept', inverse_of: nil, validate: false
367
+
368
+ has_many :first_appearance_characters, class_name: 'ComicVine::Resource::Character', inverse_of: nil, validate: false
369
+ has_many :first_appearance_concepts, class_name: 'ComicVine::Resource::Concept', inverse_of: nil, validate: false
370
+ has_many :first_appearance_locations, class_name: 'ComicVine::Resource::Location', inverse_of: nil, validate: false
371
+ has_many :first_appearance_objects, class_name: 'ComicVine::Resource::Object', inverse_of: nil, validate: false
372
+ has_many :first_appearance_storyarcs, class_name: 'ComicVine::Resource::StoryArc', inverse_of: :first_appeared_in_episode, validate: false
373
+ has_many :first_appearance_teams, class_name: 'ComicVine::Resource::Team', inverse_of: nil, validate: false
374
+ has_many :first_appearance_locations, class_name: 'ComicVine::Resource::Location', inverse_of: nil, validate: false
375
+
376
+ has_and_belongs_to_many :location_credits, class_name: 'ComicVine::Resource::Location', inverse_of: nil, validate: false
377
+ has_and_belongs_to_many :object_credits, class_name: 'ComicVine::Resource::Object', inverse_of: nil, validate: false
378
+ has_and_belongs_to_many :person_credits, class_name: 'ComicVine::Resource::Person', inverse_of: nil, validate: false
379
+ has_and_belongs_to_many :team_credits, class_name: 'ComicVine::Resource::Team', inverse_of: nil, validate: false
380
+
381
+ has_and_belongs_to_many :story_arc_credits, class_name: 'ComicVine::Resource::StoryArc', inverse_of: :episodes, validate: false
382
+ belongs_to :series, class_name: 'ComicVine::Resource::Series', inverse_of: :episodes, validate: false
383
+ end
384
+
385
+ ##
386
+ # Extends {ComicVine::Resource::Location} to add mongoid functions
387
+ # @since 0.1.2
388
+ class Location < ComicVine::Resource
389
+ include Mongoid::Document
390
+ include ComicVine::Mongo
391
+
392
+ field :aliases, type: String
393
+ field :api_detail_url, type: String
394
+ field :count_of_issue_appearances, type: Integer
395
+ field :date_added, type: DateTime
396
+ field :date_last_updated, type: DateTime
397
+ field :deck, type: String
398
+ field :description, type: String
399
+ field :id, type: Integer
400
+ field :image, type: Hash
401
+ field :name, type: String
402
+ field :site_detail_url, type: String
403
+ field :start_year, type: Integer
404
+
405
+ belongs_to :first_appeared_in_issue, class_name: 'ComicVine::Resource::Issue', inverse_of: :first_appearance_locations, validate: false
406
+ has_and_belongs_to_many :issue_credits, class_name: 'ComicVine::Resource::Issue', inverse_of: :location_credits, validate: false
407
+
408
+ has_and_belongs_to_many :movies, class_name: 'ComicVine::Resource::Movie', inverse_of: :location_credits, validate: false
409
+ has_and_belongs_to_many :story_arc_credits, class_name: 'ComicVine::Resource::StoryArc', inverse_of: nil, validate: false
410
+ has_and_belongs_to_many :volume_credits, class_name: 'ComicVine::Resource::Volume', inverse_of: :locations, validate: false
411
+ end
412
+
413
+ ##
414
+ # Extends {ComicVine::Resource::Movie} to add mongoid functions
415
+ # @since 0.1.2
416
+ class Movie < ComicVine::Resource
417
+ include Mongoid::Document
418
+ include ComicVine::Mongo
419
+
420
+ field :api_detail_url, type: String
421
+ field :box_office_revenue, type: Integer
422
+ field :budget, type: Integer
423
+ field :date_added, type: DateTime
424
+ field :date_last_updated, type: DateTime
425
+ field :deck, type: String
426
+ field :description, type: String
427
+ field :id, type: Integer
428
+ field :image, type: Hash
429
+ field :name, type: String
430
+ field :site_detail_url, type: String
431
+ field :release_date, type: DateTime
432
+ field :rating, type: String
433
+ field :has_staff_review, type: Hash
434
+ field :total_revenue, type: Integer
435
+ field :runtime, type: Integer
436
+ field :distributor, type: String
437
+
438
+ ##
439
+ # Accounts for ComicVine's miss-match return of false if no review exists. Sets an empty hash
440
+ # @param value [Hash]
441
+ # @since 0.1.0
442
+ def has_staff_review=(value)
443
+ if value.nil? || value.kind_of?(FalseClass)
444
+ self.has_staff_review = {}
445
+ else
446
+ super
447
+ end
448
+ end
449
+
450
+ ##
451
+ # @return [true, false]
452
+ def has_staff_review?
453
+ !self.has_staff_review.empty?
454
+ end
455
+
456
+ has_and_belongs_to_many :studios, class_name: 'ComicVine::Resource::Publisher', inverse_of: nil, validate: false
457
+ has_and_belongs_to_many :concepts, class_name: 'ComicVine::Resource::Concept', inverse_of: nil, validate: false
458
+ has_and_belongs_to_many :locations, class_name: 'ComicVine::Resource::Location', inverse_of: nil, validate: false
459
+ has_and_belongs_to_many :writers, class_name: 'ComicVine::Resource::Person', inverse_of: nil, validate: false
460
+ has_and_belongs_to_many :producers, class_name: 'ComicVine::Resource::Person', inverse_of: nil, validate: false
461
+ has_and_belongs_to_many :teams, class_name: 'ComicVine::Resource::Team', inverse_of: :movies, validate: false
462
+ has_and_belongs_to_many :objects, class_name: 'ComicVine::Resource::Object', inverse_of: :movies, validate: false
463
+ has_and_belongs_to_many :story_arc_credits, class_name: 'ComicVine::Resource::StoryArc', inverse_of: :movies, validate: false
464
+ has_and_belongs_to_many :characters, class_name: 'ComicVine::Resource::Character', inverse_of: :movies, validate: false
465
+
466
+ end
467
+
468
+ ##
469
+ # Extends {ComicVine::Resource::Object} to add mongoid functions
470
+ # @since 0.1.2
471
+ class Object < ComicVine::Resource
472
+ include Mongoid::Document
473
+ include ComicVine::Mongo
474
+
475
+ field :aliases, type: String
476
+ field :api_detail_url, type: String
477
+ field :count_of_issue_appearances, type: Integer
478
+ field :date_added, type: DateTime
479
+ field :date_last_updated, type: DateTime
480
+ field :deck, type: String
481
+ field :description, type: String
482
+ field :id, type: Integer
483
+ field :image, type: Hash
484
+ field :name, type: String
485
+ field :site_detail_url, type: String
486
+ field :start_year, type: Integer
487
+
488
+ belongs_to :first_appeared_in_issue, class_name: 'ComicVine::Resource::Issue', inverse_of: :first_appearance_characters, validate: false
489
+ has_and_belongs_to_many :issue_credits, class_name: 'ComicVine::Resource::Issue', inverse_of: :object_credits, validate: false
490
+ has_and_belongs_to_many :movies, class_name: 'ComicVine::Resource::Movie', inverse_of: :objects, validate: false
491
+ has_and_belongs_to_many :story_arc_credits, class_name: 'ComicVine::Resource::StoryArc', inverse_of: :objects, validate: false
492
+ has_and_belongs_to_many :volume_credits, class_name: 'ComicVine::Resource::Volume', inverse_of: :objects, validate: false
493
+ end
494
+
495
+ ##
496
+ # Extends {ComicVine::Resource::Origin} to add mongoid functions
497
+ # @since 0.1.2
498
+ class Origin < ComicVine::Resource
499
+ include Mongoid::Document
500
+ include ComicVine::Mongo
501
+
502
+ field :api_detail_url, type: String
503
+ field :character_set, type: String
504
+ field :id, type: Integer
505
+ field :name, type: String
506
+ field :profiles, type: Array
507
+ field :site_detail_url, type: String
508
+
509
+ has_many :characters, class_name: 'ComicVine::Resource::Character', inverse_of: :origin, validate: false
510
+ end
511
+
512
+ ##
513
+ # Extends {ComicVine::Resource::Person} to add mongoid functions
514
+ # @since 0.1.2
515
+ class Person < ComicVine::Resource
516
+ include Mongoid::Document
517
+ include ComicVine::Mongo
518
+
519
+ field :aliases, type: String
520
+ field :api_detail_url, type: String
521
+ field :birth, type: Date
522
+ field :death, type: Date
523
+ field :count_of_issue_appearances, type: Integer
524
+ field :country, type: String
525
+ field :date_added, type: DateTime
526
+ field :date_last_updated, type: DateTime
527
+ field :deck, type: String
528
+ field :description, type: String
529
+ field :email, type: String
530
+ field :id, type: Integer
531
+ field :gender, type: Integer
532
+ field :image, type: Hash
533
+ field :name, type: String
534
+ field :site_detail_url, type: String
535
+ field :website, type: String
536
+ field :role, type: String
537
+
538
+ ##
539
+ # Override to handle ComicVine hash results
540
+ # @param value [DateTime]
541
+ # @since 0.1.0
542
+ def death=(value)
543
+ if value.nil?
544
+ # Do nothing
545
+ elsif value.kind_of?(Hash) && value.has_key?('date')
546
+ # Translate the string
547
+ #TODO: Parse the remaining keys: timezone_type && timezone into correct dateTime. See person: 2756
548
+ super DateTime.parse(value['date'])
549
+ elsif value.kind_of?(DateTime)
550
+ super
551
+ end
552
+ end
553
+
554
+ ##
555
+ # Accounts for ComicVine's miss-spelling of issue in key. Maps count_of_isssue_appearances to count_of_issue_appearances
556
+ # @param value [Integer]
557
+ # @since 0.1.0
558
+ def count_of_isssue_appearances=(value)
559
+ self[:count_of_issue_appearances] = value
560
+ end
561
+
562
+ ##
563
+ # Accounts for ComicVine's miss-spelling of issue in key. returns count_of_issue_appearances
564
+ # @return [Integer]
565
+ # @since 0.1.0
566
+ def count_of_isssue_appearances
567
+ self[:count_of_issue_appearances]
568
+ end
569
+
570
+ has_one :hometown, class_name: 'ComicVine::Resource::Location', validate: false
571
+ has_and_belongs_to_many :created_characters, class_name: 'ComicVine::Resource::Character', inverse_of: :creators, validate: false
572
+ has_and_belongs_to_many :issues, class_name: 'ComicVine::Resource::Issue', inverse_of: :person_credits, validate: false
573
+ has_and_belongs_to_many :story_arc_credits, class_name: 'ComicVine::Resource::StoryArc', inverse_of: :person_credits, validate: false
574
+ has_and_belongs_to_many :volume_credits, class_name: 'ComicVine::Resource::Volume', inverse_of: :people, validate: false
575
+
576
+ end
577
+
578
+ ##
579
+ # Extends {ComicVine::Resource::Power} to add mongoid functions
580
+ # @since 0.1.2
581
+ class Power < ComicVine::Resource
582
+ include Mongoid::Document
583
+ include ComicVine::Mongo
584
+
585
+ field :aliases, type: String
586
+ field :api_detail_url, type: String
587
+ field :name, type: String
588
+ field :site_detail_url, type: String
589
+ field :id, type: Integer
590
+ field :description, type: String
591
+ field :date_added, type: DateTime
592
+ field :date_last_updated, type: DateTime
593
+ has_and_belongs_to_many :characters, class_name: 'ComicVine::Resource::Character', inverse_of: :powers, validate: false
594
+ end
595
+
596
+ ##
597
+ # Extends {ComicVine::Resource::Promo} to add mongoid functions
598
+ # @since 0.1.2
599
+ class Promo < ComicVine::Resource
600
+ include Mongoid::Document
601
+ include ComicVine::Mongo
602
+
603
+ field :api_detail_url, type: String
604
+ field :date_added, type: DateTime
605
+ field :deck, type: String
606
+ field :id, type: Integer
607
+ field :image, type: Hash
608
+ field :link, type: String
609
+ field :name, type: String
610
+ field :resource_type, type: String
611
+ field :user, type: String
612
+ end
613
+
614
+ ##
615
+ # Extends {ComicVine::Resource::Publisher} to add mongoid functions
616
+ # @since 0.1.2
617
+ class Publisher < ComicVine::Resource
618
+ include Mongoid::Document
619
+ include ComicVine::Mongo
620
+
621
+ field :aliases, type: String
622
+ field :api_detail_url, type: String
623
+ field :date_added, type: DateTime
624
+ field :date_last_updated, type: DateTime
625
+ field :deck, type: String
626
+ field :description, type: String
627
+ field :id, type: Integer
628
+ field :image, type: Hash
629
+ field :name, type: String
630
+ field :site_detail_url, type: String
631
+ field :location_address, type: String
632
+ field :location_city, type: String
633
+ field :location_state, type: String
634
+
635
+ has_many :characters, class_name: 'ComicVine::Resource::Character', inverse_of: :publisher, validate: false
636
+ has_many :story_arcs, class_name: 'ComicVine::Resource::StoryArc', inverse_of: :publisher, validate: false
637
+ has_many :teams, class_name: 'ComicVine::Resource::Team', inverse_of: :publisher, validate: false
638
+ has_many :volumes, class_name: 'ComicVine::Resource::Volume', inverse_of: :publisher, validate: false
639
+ has_many :series, class_name: 'ComicVine::Resource::Series', inverse_of: :publisher, validate: false
640
+ end
641
+
642
+ ##
643
+ # Extends {ComicVine::Resource::Series} to add mongoid functions
644
+ # @since 0.1.2
645
+ class Series < ComicVine::Resource
646
+ include Mongoid::Document
647
+ include ComicVine::Mongo
648
+
649
+ field :aliases, type: String
650
+ field :api_detail_url, type: String
651
+ field :date_added, type: DateTime
652
+ field :date_last_updated, type: DateTime
653
+ field :deck, type: String
654
+ field :description, type: String
655
+ field :id, type: Integer
656
+ field :image, type: Hash
657
+ field :name, type: String
658
+ field :site_detail_url, type: String
659
+
660
+ field :count_of_episodes, type: Integer
661
+ field :start_year, type: Integer
662
+
663
+ has_and_belongs_to_many :characters, class_name: 'ComicVine::Resource::Character', inverse_of: nil, validate: false
664
+
665
+ has_many :episodes, class_name: 'ComicVine::Resource::Episode', inverse_of: :series, validate: false
666
+ has_one :first_episode, class_name: 'ComicVine::Resource::Episode', validate: false
667
+ has_one :last_episode, class_name: 'ComicVine::Resource::Episode', validate: false
668
+
669
+ has_and_belongs_to_many :location_credits, class_name: 'ComicVine::Resource::Location', inverse_of: nil, validate: false
670
+ belongs_to :publisher, class_name: 'ComicVine::Resource::Publisher', inverse_of: :series, validate: false
671
+ end
672
+
673
+ ##
674
+ # Extends {ComicVine::Resource::StoryArc} to add mongoid functions
675
+ # @since 0.1.2
676
+ class StoryArc < ComicVine::Resource
677
+ include Mongoid::Document
678
+ include ComicVine::Mongo
679
+
680
+ field :aliases, type: String
681
+ field :api_detail_url, type: String
682
+ field :date_added, type: DateTime
683
+ field :date_last_updated, type: DateTime
684
+ field :deck, type: String
685
+ field :description, type: String
686
+ field :id, type: Integer
687
+ field :image, type: Hash
688
+ field :name, type: String
689
+ field :site_detail_url, type: String
690
+
691
+ field :count_of_issue_appearances, type: Integer
692
+
693
+ def count_of_isssue_appearances=(value)
694
+ self[:count_of_isssue_appearances] = value
695
+ end
696
+
697
+ def count_of_isssue_appearances
698
+ self[:count_of_isssue_appearances]
699
+ end
700
+
701
+
702
+ belongs_to :publisher, class_name: 'ComicVine::Resource::Publisher', inverse_of: :story_arcs, validate: false
703
+
704
+ belongs_to :first_appeared_in_issue, class_name: 'ComicVine::Resource::Issue', inverse_of: :first_appearance_storyarcs, validate: false
705
+ has_and_belongs_to_many :issues, class_name: 'ComicVine::Resource::Issue', inverse_of: :story_arc_credits, validate: false
706
+
707
+ has_and_belongs_to_many :movies, class_name: 'ComicVine::Resource::Movie', inverse_of: :story_arc_credits, validate: false
708
+ has_and_belongs_to_many :teams, class_name: 'ComicVine::Resource::Team', inverse_of: :story_arc_credits, validate: false
709
+ has_and_belongs_to_many :characters, class_name: 'ComicVine::Resource::Character', inverse_of: :story_arc_credits, validate: false
710
+
711
+ belongs_to :first_appeared_in_episode, class_name: 'ComicVine::Resource::Episode', inverse_of: :first_appearance_storyarcs, validate: false, optional: true
712
+ has_and_belongs_to_many :episodes, class_name: 'ComicVine::Resource::Episode', inverse_of: :story_arc_credits, validate: false
713
+ end
714
+
715
+ ##
716
+ # Extends {ComicVine::Resource::Team} to add mongoid functions
717
+ # @since 0.1.2
718
+ class Team < ComicVine::Resource
719
+ include Mongoid::Document
720
+ include ComicVine::Mongo
721
+
722
+ field :aliases, type: String
723
+ field :api_detail_url, type: String
724
+ field :date_added, type: DateTime
725
+ field :date_last_updated, type: DateTime
726
+ field :deck, type: String
727
+ field :description, type: String
728
+ field :id, type: Integer
729
+ field :image, type: Hash
730
+ field :name, type: String
731
+ field :site_detail_url, type: String
732
+ field :count_of_issue_appearances, type: Integer
733
+ field :count_of_team_members, type: Integer
734
+
735
+ def count_of_isssue_appearances=(value)
736
+ self[:count_of_isssue_appearances] = value
737
+ end
738
+
739
+ def count_of_isssue_appearances
740
+ self[:count_of_isssue_appearances]
741
+ end
742
+
743
+ def disbanded_in_issues=(value)
744
+ if value.kind_of? ComicVine::Resource::Issue
745
+ self.issues_disbanded_in << value
746
+ elsif value.kind_of? Array
747
+ self.issues_disbanded_in = value
748
+ end
749
+ end
750
+
751
+ def disbanded_in_issues
752
+ self.issues_disbanded_in
753
+ end
754
+
755
+ def isssues_disbanded_in=(value)
756
+ if value.kind_of? ComicVine::Resource::Issue
757
+ self.issues_disbanded_in << value
758
+ elsif value.kind_of? Array
759
+ self.issues_disbanded_in = value
760
+ end
761
+ end
762
+
763
+ def isssues_disbanded_in
764
+ self.issues_disbanded_in
765
+ end
766
+
767
+ has_and_belongs_to_many :character_enemies, class_name: 'ComicVine::Resource::Character', inverse_of: nil, validate: false
768
+ has_and_belongs_to_many :character_friends, class_name: 'ComicVine::Resource::Character', inverse_of: nil, validate: false
769
+ has_and_belongs_to_many :characters, class_name: 'ComicVine::Resource::Character', inverse_of: :teams, validate: false
770
+
771
+ belongs_to :first_appeared_in_issue, class_name: 'ComicVine::Resource::Issue', inverse_of: :first_appearance_teams, validate: false
772
+ has_and_belongs_to_many :issue_credits, class_name: 'ComicVine::Resource::Issue', inverse_of: :team_credits, validate: false
773
+ has_and_belongs_to_many :issues_disbanded_in, class_name: 'ComicVine::Resource::Issue', inverse_of: :team_disbanded_in, validate: false
774
+
775
+ belongs_to :publisher, class_name: 'ComicVine::Resource::Publisher', inverse_of: :teams, validate: false
776
+ has_and_belongs_to_many :movies, class_name: 'ComicVine::Resource::Movie', inverse_of: :teams, validate: false
777
+ has_and_belongs_to_many :story_arc_credits, class_name: 'ComicVine::Resource::StoryArc', inverse_of: :teams, validate: false
778
+ has_and_belongs_to_many :volume_credits, class_name: 'ComicVine::Resource::Volume', inverse_of: :teams, validate: false
779
+
780
+ end
781
+
782
+ end
783
+ end
data.tar.gz.sig ADDED
@@ -0,0 +1,2 @@
1
+ jf�k9�7�݁g�P=�� �p��u[��ܴB`uh.�dvi�=/[ =�S���A�upI������㥿��`��C�SJIn"�n™0�f����0k�5J��w� ykE����{9ޕ�u"!��)d6\���S�����|͈A�y"�aa���N����G��U0L�s���~��* �nș��akgnH���Bp!�����)x) 5�u#�������5j�̾��B�� ��
2
+ &��o�Biب�f8�T�
metadata ADDED
@@ -0,0 +1,228 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: comicvine-mongo
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Holden Omans
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain:
11
+ - |
12
+ -----BEGIN CERTIFICATE-----
13
+ MIIDgDCCAmigAwIBAgIBATANBgkqhkiG9w0BAQUFADBDMRUwEwYDVQQDDAxob2xk
14
+ ZW4ub21hbnMxFTATBgoJkiaJk/IsZAEZFgVnbWFpbDETMBEGCgmSJomT8ixkARkW
15
+ A2NvbTAeFw0xNjExMDkxNTU5MTdaFw0xNzExMDkxNTU5MTdaMEMxFTATBgNVBAMM
16
+ DGhvbGRlbi5vbWFuczEVMBMGCgmSJomT8ixkARkWBWdtYWlsMRMwEQYKCZImiZPy
17
+ LGQBGRYDY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2V7yrTuO
18
+ 4FNzWlhQL2R8Vdx5LKX/oewZ7bKh/2GJcR5R7mowdqejlfzJb7abtmYsQfyvwNfy
19
+ NrKneghJ/rLflQ1NrlehYSYLlBFTVuymPvejG+EH5C2/RJqhm2zyfjkisasqhWk8
20
+ Bq6IUPX1l8C78Kkd6t3QR/n3zr1Ip25NicpJ2flBMHPg3IV9qaNXywkCzutkEMoW
21
+ FuHdHMN2cDMUnhM9qGOK7nvRk7rkP/yJAp+sf2nv+C99s5CMNuvnGeSgnX7IMcRV
22
+ Ks2FrSvqKDj24Xf5kHdlcpDrS1VcFsAkIT6bVBm19KO8pFvZkDJE76Yshy80FRpQ
23
+ bijjrYQhYXiM4QIDAQABo38wfTAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNV
24
+ HQ4EFgQUbbbHhJ0Z4S/c5FcDSqEVx7Yk1agwIQYDVR0RBBowGIEWaG9sZGVuLm9t
25
+ YW5zQGdtYWlsLmNvbTAhBgNVHRIEGjAYgRZob2xkZW4ub21hbnNAZ21haWwuY29t
26
+ MA0GCSqGSIb3DQEBBQUAA4IBAQCoC/7FnCsRFIV/rwAJRXY3Ao0qdbnksPrqUhP0
27
+ 7A8m8PccIDuUspq/WtkhzSMLZvzurlXEw1qdLtRLS2LnftQQuo5YPz6PQj4XAx8w
28
+ yF48j5e3XvUZJiMQ+cIsXPnjes13JgnP/KOfILgfIz9ad0pGMMUCTLYahu+fXqxE
29
+ if+otWjB2is7MBxd+krcr8vCJ4E46a8H3zyBN/tSgGw4RwkxHnXekTJvMy4skcSB
30
+ VpDNqh/BlGMQ0mqAEuBFZFSNaroph6JLUz1ykVvQENOQLThxAjolK7SAUrdoBDOc
31
+ fXEVP1s+hpJB6IEU8/LW016TU8WpnA+MHGfJRtkrUm/cEsWU
32
+ -----END CERTIFICATE-----
33
+ date: 2016-11-16 00:00:00.000000000 Z
34
+ dependencies:
35
+ - !ruby/object:Gem::Dependency
36
+ name: bundler
37
+ requirement: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '1.13'
42
+ type: :development
43
+ prerelease: false
44
+ version_requirements: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - "~>"
47
+ - !ruby/object:Gem::Version
48
+ version: '1.13'
49
+ - !ruby/object:Gem::Dependency
50
+ name: rake
51
+ requirement: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: '10.0'
56
+ type: :development
57
+ prerelease: false
58
+ version_requirements: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - "~>"
61
+ - !ruby/object:Gem::Version
62
+ version: '10.0'
63
+ - !ruby/object:Gem::Dependency
64
+ name: minitest
65
+ requirement: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: '5.9'
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: 5.9.1
73
+ type: :development
74
+ prerelease: false
75
+ version_requirements: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - "~>"
78
+ - !ruby/object:Gem::Version
79
+ version: '5.9'
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: 5.9.1
83
+ - !ruby/object:Gem::Dependency
84
+ name: minitest-reporters
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '1.1'
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: 1.1.12
93
+ type: :development
94
+ prerelease: false
95
+ version_requirements: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - "~>"
98
+ - !ruby/object:Gem::Version
99
+ version: '1.1'
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: 1.1.12
103
+ - !ruby/object:Gem::Dependency
104
+ name: rdoc
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - "~>"
108
+ - !ruby/object:Gem::Version
109
+ version: '4.2'
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ version: 4.2.1
113
+ type: :development
114
+ prerelease: false
115
+ version_requirements: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - "~>"
118
+ - !ruby/object:Gem::Version
119
+ version: '4.2'
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ version: 4.2.1
123
+ - !ruby/object:Gem::Dependency
124
+ name: yard
125
+ requirement: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - "~>"
128
+ - !ruby/object:Gem::Version
129
+ version: '0.9'
130
+ - - ">="
131
+ - !ruby/object:Gem::Version
132
+ version: 0.9.5
133
+ type: :development
134
+ prerelease: false
135
+ version_requirements: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - "~>"
138
+ - !ruby/object:Gem::Version
139
+ version: '0.9'
140
+ - - ">="
141
+ - !ruby/object:Gem::Version
142
+ version: 0.9.5
143
+ - !ruby/object:Gem::Dependency
144
+ name: comicvine
145
+ requirement: !ruby/object:Gem::Requirement
146
+ requirements:
147
+ - - "~>"
148
+ - !ruby/object:Gem::Version
149
+ version: '0.1'
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: 0.1.2
153
+ type: :runtime
154
+ prerelease: false
155
+ version_requirements: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: '0.1'
160
+ - - ">="
161
+ - !ruby/object:Gem::Version
162
+ version: 0.1.2
163
+ - !ruby/object:Gem::Dependency
164
+ name: mongoid
165
+ requirement: !ruby/object:Gem::Requirement
166
+ requirements:
167
+ - - "~>"
168
+ - !ruby/object:Gem::Version
169
+ version: '6.0'
170
+ - - ">="
171
+ - !ruby/object:Gem::Version
172
+ version: 6.0.2
173
+ type: :runtime
174
+ prerelease: false
175
+ version_requirements: !ruby/object:Gem::Requirement
176
+ requirements:
177
+ - - "~>"
178
+ - !ruby/object:Gem::Version
179
+ version: '6.0'
180
+ - - ">="
181
+ - !ruby/object:Gem::Version
182
+ version: 6.0.2
183
+ description: Allows saving of comicvine resources to a Mongodb using Mongoid
184
+ email:
185
+ - holden.omans@gmail.com
186
+ executables: []
187
+ extensions: []
188
+ extra_rdoc_files: []
189
+ files:
190
+ - ".gitignore"
191
+ - ".rspec"
192
+ - ".travis.yml"
193
+ - Gemfile
194
+ - LICENSE.txt
195
+ - README.md
196
+ - Rakefile
197
+ - bin/console
198
+ - bin/setup
199
+ - certs/homans.pem
200
+ - checksum/comicvine-mongo-0.1.0.gem.sha256
201
+ - comicvine-mongo.gemspec
202
+ - lib/comicvine/mongo.rb
203
+ - lib/comicvine/mongo/version.rb
204
+ homepage: https://github.com/kalinon/ruby-comicvine-mongo
205
+ licenses:
206
+ - MIT
207
+ metadata: {}
208
+ post_install_message:
209
+ rdoc_options: []
210
+ require_paths:
211
+ - lib
212
+ required_ruby_version: !ruby/object:Gem::Requirement
213
+ requirements:
214
+ - - ">="
215
+ - !ruby/object:Gem::Version
216
+ version: '2.2'
217
+ required_rubygems_version: !ruby/object:Gem::Requirement
218
+ requirements:
219
+ - - ">="
220
+ - !ruby/object:Gem::Version
221
+ version: '0'
222
+ requirements: []
223
+ rubyforge_project:
224
+ rubygems_version: 2.5.1
225
+ signing_key:
226
+ specification_version: 4
227
+ summary: Mongo extension to the comicvine gem
228
+ test_files: []
metadata.gz.sig ADDED
Binary file