tweek_catalogue 0.0.33

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ YWZmM2Q2NjUwNjlkZmJkMzg1YTg0MGRiMzIwNmFhMWZiYmNkMGI4MQ==
5
+ data.tar.gz: !binary |-
6
+ NzgwZDVkOWRiMWEyNDkyM2FjOWIzNDY5NjhhYjY4YjAyMGQ1NjkzMg==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ OWE0YTIyMzRiMThiZGEyYjU2MDc2ZmFiMTgzNmMwMDUyMDVmNjg3NjU5NGY0
10
+ NjMzYmE2YWQzYjA3ZDNmMTkxZTUxNDQ0ZmNmOTFlZjNmZjg5NDZlYjJhYTIz
11
+ NmI2Nzg4ODZhMmMwN2M5NTY5YTZiNWRlNWNkZTczNTc5OGJjNWQ=
12
+ data.tar.gz: !binary |-
13
+ MjA2ZDczZmNmNzYzN2IxOWIxNzZkODQ1MmE1NjRlOTk2YWVhMGEzOWVhNzA2
14
+ MTFiNzkxZjg4ZTI3YTAzYWQxNDliODEyN2M3N2I2NjAxYjBiMjI2YjQxYzJk
15
+ NGY3YzMzZjU2MjhmZmNhMWMzZTNiYjQ1ODdkNzRlZTQyNzg3M2M=
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in tweek_catalogue.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Geoffroy GOBERT
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,29 @@
1
+ # TweekCatalogue
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'tweek_catalogue'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install tweek_catalogue
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
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
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,49 @@
1
+ # require "bundler"
2
+ # Bundler.require
3
+ require 'mongo_mapper'
4
+ require 'active_support'
5
+
6
+ require File.join(File.dirname(__FILE__), 'tweek_catalogue', 'version')
7
+ require File.join(File.dirname(__FILE__), 'tweek_catalogue', 'concerns')
8
+ require File.join(File.dirname(__FILE__), 'tweek_catalogue', 'video')
9
+ Dir.glob(File.join(File.dirname(__FILE__), 'tweek_catalogue', '*.rb')).each do |f|
10
+ require f
11
+ end
12
+
13
+ module TweekCatalogue
14
+ # mongo_config: result of a YAML.load_file call e.g:
15
+ # {
16
+ # 'development': {
17
+ # 'uri': 'mongodb://localhost:27017/database_namee'
18
+ # 'poolsize': 5
19
+ # }
20
+ # }
21
+ # environment: development, test, staging, production
22
+ #
23
+
24
+ # def self.included(base)
25
+ # base.extend(ClassMethods)
26
+ # end
27
+
28
+ def self.connect_mongodb!(mongo_config, environment)
29
+ MongoMapper.setup(mongo_config, environment.to_s, {pool_size: find_pool_size(mongo_config, environment)})
30
+ end
31
+
32
+ def self.find_pool_size(mongo_config, environment)
33
+ (mongo_config[environment.to_s]['pool_size'].presence || 5).to_i
34
+ end
35
+
36
+
37
+
38
+ module ClassMethods
39
+ def connect_mongodb!(mongo_config, environment)
40
+ MongoMapper.setup(mongo_config, environment.to_s, {pool_size: find_pool_size(mongo_config, environment)})
41
+ end
42
+
43
+ private
44
+
45
+ def find_pool_size(mongo_config, environment)
46
+ (mongo_config[environment.to_s]['pool_size'].presence || 5).to_i
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,8 @@
1
+ module TweekCatalogue
2
+ class AlternativeTitle
3
+ include MongoMapper::EmbeddedDocument
4
+
5
+ key :country_code, String
6
+ key :title, String
7
+ end
8
+ end
@@ -0,0 +1,7 @@
1
+ module TweekCatalogue
2
+ module Concerns
3
+ autoload :I18nSupport, 'tweek_catalogue/concerns/i18n_support'
4
+ autoload :ObjectFactories, 'tweek_catalogue/concerns/object_factories'
5
+ autoload :HasManyRelationship, 'tweek_catalogue/concerns/has_many_relationship'
6
+ end
7
+ end
@@ -0,0 +1,35 @@
1
+ module TweekCatalogue
2
+ module Concerns::HasManyRelationship
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+ class_attribute :model_namespace
7
+ self.model_namespace = 'TweekCatalogue'
8
+ end
9
+
10
+ module ClassMethods
11
+ def set_model_namespace!(namespace)
12
+ self.model_namespace = namespace
13
+ end
14
+
15
+ # Hides all complexity to create one to many relationship between two models.
16
+ # Under the hood this will create a field with _ids suffix and it will make
17
+ # call to mongomapper +many+ with the +in+ option.
18
+ #
19
+ # Paramters:
20
+ # field - Name your target field names, ie, it_has_many :countries
21
+ #
22
+ # Returns nil
23
+ def it_has_many(field, opts = {})
24
+ _key = opts[:in] || :"#{field.to_s.singularize}_ids"
25
+ _class_name = opts[:class_name] || "#{self.model_namespace}::#{field.to_s.to_s.classify}"
26
+
27
+ # Set field where all references will be stored
28
+ key _key, Array
29
+
30
+ # Set many relationship with in and class_name
31
+ many field, in: _key, class_name: _class_name
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,110 @@
1
+ module TweekCatalogue
2
+ module Concerns
3
+ module I18nSupport
4
+ extend ActiveSupport::Concern
5
+
6
+ included do
7
+ class_attribute :supported_locales, :i18n_keys, :i18n_relations
8
+ end
9
+
10
+ module ClassMethods
11
+
12
+ # Set boundary for supported locales.
13
+ #
14
+ # You can set which set of locales should be supported by +i18n_key+ and
15
+ def i18n_keys_for(*locales)
16
+ self.supported_locales = locales.map(&:to_sym)
17
+ end
18
+
19
+ def i18n_many(attr, opts = {})
20
+ add_i18n_relationship!(attr)
21
+ generate_i18n_many(attr, opts)
22
+ end
23
+
24
+ def i18n_one(attr, opts = {})
25
+ add_i18n_relationship!(attr)
26
+ generate_i18n_one(attr, opts)
27
+ end
28
+
29
+ def i18n_validates_presence_of(*fields)
30
+ fields.each do |field|
31
+ supported_locales.each do |locale|
32
+ other_locales = supported_locales - [locale]
33
+ other_fields = other_locales.map { |l| "#{field}_#{l}" }
34
+ class_eval <<-CODE, __FILE__, __LINE__
35
+ validates_presence_of :"#{field}_#{locale}", unless: -> { [#{other_fields.join('.present?, ')}].any? }
36
+ CODE
37
+ end
38
+ end
39
+ end
40
+
41
+ # Create key with I18n support.
42
+ #
43
+ # Actually this field will create one ore more fields based on the
44
+ # +i18n_keys_for+ locale list. Also additionally an accessor which will
45
+ # available the attribute value based on the +I18n.locale+ settings.
46
+ def i18n_key(attr_name, opts = {})
47
+ add_i18n_key!(attr_name)
48
+ generate_i18n_helper_methods! attr_name, opts
49
+ end
50
+
51
+ def i18n_fields
52
+ @i18n_fields ||= (i18n_keys + i18n_relations).uniq
53
+ end
54
+
55
+ private
56
+
57
+ def add_i18n_key! attr_name
58
+ self.i18n_keys ||= []
59
+ self.i18n_keys += [attr_name]
60
+ end
61
+
62
+ def add_i18n_relationship! attr_name
63
+ self.i18n_relations ||= []
64
+ self.i18n_relations += [attr_name]
65
+ end
66
+
67
+ def generate_i18n_one(attr_name, opts)
68
+ supported_locales.each do |locale|
69
+ one :"#{locale}_#{attr_name}", opts
70
+
71
+ class_eval <<-CODE, __FILE__, __LINE__
72
+ def #{attr_name}
73
+ self.send(:"\#{I18n.locale}_#{attr_name}")
74
+ end
75
+ CODE
76
+ end
77
+ end
78
+
79
+ def generate_i18n_many(attr_name, opts)
80
+ supported_locales.each do |locale|
81
+ many :"#{locale}_#{attr_name}", opts
82
+
83
+ class_eval <<-CODE, __FILE__, __LINE__
84
+ def #{attr_name}
85
+ self.send(:"\#{I18n.locale}_#{attr_name}")
86
+ end
87
+ CODE
88
+ end
89
+ end
90
+
91
+ def generate_i18n_helper_methods!(attr_name, opts)
92
+ self.supported_locales ||= ['en']
93
+
94
+ supported_locales.each do |locale|
95
+
96
+ # Set mongomapper key
97
+ key :"#{attr_name}_#{locale.to_s}"
98
+
99
+ # Generate attr_name_for suffix which accepts locale parameter
100
+ class_eval <<-CODE, __FILE__, __LINE__
101
+ def #{attr_name}_for(locale)
102
+ self.send :"#{attr_name}_\#{locale}"
103
+ end
104
+ CODE
105
+ end
106
+ end
107
+ end
108
+ end
109
+ end
110
+ end
@@ -0,0 +1,37 @@
1
+ module TweekCatalogue
2
+ module Concerns
3
+ module ObjectFactories
4
+ extend ActiveSupport::Concern
5
+
6
+ module ClassMethods
7
+
8
+ def update_or_create!(primary_key, attrs)
9
+ map_id!(primary_key) if primary_key.present?
10
+
11
+ record = first(primary_key)
12
+ if record
13
+ record.update_attributes(attrs)
14
+ record
15
+ else
16
+ create!(primary_key.merge(attrs))
17
+ end
18
+ end
19
+
20
+ def first_or_create!(primary_key, attrs = {})
21
+ map_id!(primary_key) if primary_key.present?
22
+
23
+ _primary_key = primary_key ? primary_key : send(:build_primary_key, attrs)
24
+ first(_primary_key) || create!(_primary_key.merge(attrs))
25
+ end
26
+
27
+ def build_primary_key(*args); raise NotImplementedError end
28
+
29
+ private
30
+
31
+ def map_id!(attrs)
32
+ attrs[:tmdb_id] = attrs[:tmdb_id].to_s if attrs[:tmdb_id].present?
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,17 @@
1
+ module TweekCatalogue
2
+ class Genre
3
+ include MongoMapper::Document
4
+ include Concerns::ObjectFactories
5
+
6
+ key :tmdb_id, String
7
+ key :name, String
8
+
9
+ timestamps!
10
+
11
+ validates_uniqueness_of :tmdb_id
12
+
13
+ def self.build_primary_key(attrs)
14
+ { tmdb_id: attrs[:tmdb_id].to_s }
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,11 @@
1
+ module TweekCatalogue
2
+ class Image
3
+ include MongoMapper::EmbeddedDocument
4
+
5
+ key :lang_code, String
6
+ key :aspect_ratio, Float
7
+ key :file_path, String
8
+ key :height, Integer
9
+ key :width, Integer
10
+ end
11
+ end
@@ -0,0 +1,18 @@
1
+ module TweekCatalogue
2
+ class Keyword
3
+
4
+ include MongoMapper::Document
5
+ include Concerns::ObjectFactories
6
+
7
+ key :tmdb_id, String
8
+ key :name, String
9
+
10
+ timestamps!
11
+
12
+ validates_uniqueness_of :tmdb_id
13
+
14
+ def self.build_primary_key(attrs)
15
+ { tmdb_id: attrs[:tmdb_id].to_s }
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,8 @@
1
+ module TweekCatalogue
2
+ class Movie < Video
3
+
4
+ def release_date
5
+ first_air_at
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,15 @@
1
+ module TweekCatalogue
2
+ class Network
3
+ include MongoMapper::Document
4
+ include Concerns::ObjectFactories
5
+
6
+ key :tmdb_id, String
7
+ key :name, String
8
+
9
+ timestamps!
10
+
11
+ def self.build_primary_key(attrs)
12
+ { tmdb_id: attrs[:tmdb_id].to_s }
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,44 @@
1
+ module TweekCatalogue
2
+ class Participant
3
+
4
+ include MongoMapper::Document
5
+ include Concerns::ObjectFactories
6
+
7
+ key :video_tmdb_id, String
8
+ key :person_tmdb_id, String
9
+ key :name, String
10
+ key :work, String # :author, :director, ...
11
+ key :character, String
12
+ key :order, Integer
13
+ key :profile_path, String
14
+
15
+ timestamps!
16
+
17
+ belongs_to :person, class_name: 'TweekCatalogue::Person'
18
+
19
+ scope :not_syncd, -> { where(person_id: nil) }
20
+
21
+ def self.build_primary_key(attrs)
22
+ {
23
+ video_tmdb_id: attrs[:video_tmdb_id].to_s,
24
+ person_tmdb_id: attrs[:person_tmdb_id].to_s,
25
+ character: attrs[:character].to_s,
26
+ work: attrs[:work].to_s
27
+ }
28
+ end
29
+
30
+ def cast?
31
+ !!character
32
+ end
33
+
34
+ def crew?
35
+ !!work
36
+ end
37
+
38
+ def type
39
+ return :cast if cast?
40
+ return :crew if crew?
41
+ return :undefined
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,35 @@
1
+ module TweekCatalogue
2
+
3
+ class Person
4
+ include MongoMapper::Document
5
+ include Concerns::I18nSupport
6
+ include Concerns::ObjectFactories
7
+
8
+ i18n_keys_for :en, :de
9
+
10
+ key :adult, Boolean, default: false
11
+
12
+ key :tmdb_id, String
13
+ key :imdb_id, String
14
+
15
+ key :name, String
16
+ key :also_known_as, Array
17
+
18
+ key :profile_path, String
19
+ key :tmdb_popularity, String
20
+ key :place_of_birth, String
21
+
22
+ key :biography, String
23
+
24
+ key :birthday, Date
25
+ key :deathday, Date
26
+
27
+ timestamps!
28
+
29
+ validates_uniqueness_of :tmdb_id
30
+
31
+ before_destroy do
32
+ Participant.where(:person_tmdb_id => self.tmdb_id).destroy_all
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,18 @@
1
+ module TweekCatalogue
2
+ class ProductionCompany
3
+
4
+ include MongoMapper::Document
5
+ include Concerns::ObjectFactories
6
+
7
+ key :tmdb_id, String
8
+ key :name, String
9
+
10
+ timestamps!
11
+
12
+ validates_uniqueness_of :tmdb_id
13
+
14
+ def self.build_primary_key(attrs)
15
+ { tmdb_id: attrs[:tmdb_id].to_s }
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,18 @@
1
+ module TweekCatalogue
2
+ class ProductionCountry
3
+
4
+ include MongoMapper::Document
5
+ include Concerns::ObjectFactories
6
+
7
+ key :country_code, String
8
+ key :name, String
9
+
10
+ timestamps!
11
+
12
+ validates_uniqueness_of :country_code
13
+
14
+ def self.build_primary_key(attrs)
15
+ { country_code: attrs[:country_code] }
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,9 @@
1
+ module TweekCatalogue
2
+ class Release
3
+ include MongoMapper::EmbeddedDocument
4
+
5
+ key :country_code, String
6
+ key :certification, String
7
+ key :release_date, Date
8
+ end
9
+ end
@@ -0,0 +1,16 @@
1
+ module TweekCatalogue
2
+ class Serie < Video
3
+
4
+ key :runtime, Array
5
+
6
+ def seasons
7
+ SerieSeason.where(:serie_tmdb_id => tmdb_id).all
8
+ end
9
+
10
+ def episodes
11
+ seasons.map do |s|
12
+ s.episodes
13
+ end.flatten
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,15 @@
1
+ module TweekCatalogue
2
+ class SerieEpisode < Video
3
+ key :runtime, Array
4
+
5
+ # belongs_to :serie
6
+ def serie
7
+ TweekCatalogue::Serie.where(tmdb_id: serie_tmdb_id).first
8
+ end
9
+
10
+ # belongs_to :season
11
+ def season
12
+ TweekCatalogue::SerieSeason.where(serie_tmdb_id: serie_tmdb_id, season_number: season_number).first
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ module TweekCatalogue
2
+ class SerieSeason < Video
3
+
4
+ key :runtime, Array
5
+
6
+ def episodes
7
+ SerieEpisode.where(serie_tmdb_id: serie_tmdb_id, season_number: season_number).all
8
+ end
9
+
10
+ # belongs_to :serie
11
+ def serie
12
+ TweekCatalogue::Serie.where(tmdb_id: serie_tmdb_id).first
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,18 @@
1
+ module TweekCatalogue
2
+ class SpokenLanguage
3
+
4
+ include MongoMapper::Document
5
+ include Concerns::ObjectFactories
6
+
7
+ key :lang_code, String
8
+ key :name, String
9
+
10
+ timestamps!
11
+
12
+ validates_uniqueness_of :lang_code
13
+
14
+ def self.build_primary_key(attrs)
15
+ { lang_code: attrs[:lang_code] }
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,13 @@
1
+ module TweekCatalogue
2
+ class Trailer
3
+ include MongoMapper::EmbeddedDocument
4
+
5
+ key :source_name #ie. :youtube or :quicktime
6
+ key :source, String # ie. pglIVtu9Jio or
7
+ key :sources, Array
8
+ key :name, String
9
+ key :video_format, String # ie. HD
10
+ key :video_type, String # ie. Trailer
11
+ key :lang_code, String
12
+ end
13
+ end
@@ -0,0 +1,3 @@
1
+ module TweekCatalogue
2
+ VERSION = '0.0.33'
3
+ end
@@ -0,0 +1,99 @@
1
+ module TweekCatalogue
2
+ class Video
3
+
4
+ include MongoMapper::Document
5
+
6
+ include ::TweekCatalogue::Concerns::I18nSupport
7
+ include ::TweekCatalogue::Concerns::ObjectFactories
8
+ include ::TweekCatalogue::Concerns::HasManyRelationship
9
+
10
+ # Support i18n fields with en and de locales
11
+ i18n_keys_for :en, :de
12
+
13
+ # Movie id references
14
+ key :unique_tmdb_id, String
15
+ key :tmdb_id, String
16
+ key :imdb_id, String
17
+ key :freebase_id, String
18
+ key :freebase_mid, String
19
+ key :tvdb_id, String
20
+ key :tvrage_id, String
21
+
22
+ # Movie financial, length and popularity related data
23
+ key :budget, Float
24
+ key :revenue, Float
25
+ key :runtime, Float
26
+
27
+ # Movie status related fields
28
+ key :adult, Boolean
29
+ key :status, String
30
+ key :production, Boolean
31
+
32
+ # Resource related path references
33
+ key :backdrop_path, String
34
+ key :poster_path, String
35
+
36
+ key :original_title, String
37
+ # Movie localized data attributes
38
+ i18n_key :title, String
39
+ i18n_key :overview, String
40
+ i18n_key :tagline, String
41
+
42
+ key :homepage, String
43
+ key :first_air_at, Date
44
+ key :last_air_at, Date
45
+
46
+ key :episode_number
47
+ key :season_number
48
+
49
+ # Movie related objects
50
+ it_has_many :production_companies
51
+ it_has_many :production_countries
52
+ it_has_many :spoken_languages
53
+ it_has_many :genres
54
+ it_has_many :keywords
55
+ it_has_many :networks, class_name: 'TweekCatalogue::Network'
56
+
57
+ it_has_many :creators, class_name: 'TweekCatalogue::Participant'
58
+ it_has_many :guest_stars, class_name: 'TweekCatalogue::Participant'
59
+ it_has_many :crew, class_name: 'TweekCatalogue::Participant'
60
+ it_has_many :cast, class_name: 'TweekCatalogue::Participant'
61
+
62
+ # Embedded objects
63
+ many :trailers, class_name: 'TweekCatalogue::Trailer'
64
+ many :alternative_titles, class_name: 'TweekCatalogue::AlternativeTitle'
65
+ many :releases, class_name: 'TweekCatalogue::Release'
66
+
67
+ many :backdrops, class_name: 'TweekCatalogue::Image'
68
+ many :stills, class_name: 'TweekCatalogue::Image'
69
+ many :posters, class_name: 'TweekCatalogue::Image'
70
+
71
+ key :serie_tmdb_id, String # belongs_to :serie
72
+
73
+ belongs_to :video_collection, class_name: 'TweekCatalogue::VideoCollection'
74
+
75
+ timestamps!
76
+
77
+ scope :recently_released, -> { sort(:first_air_at.desc) }
78
+
79
+ before_destroy do
80
+ Participant.where(:video_id => self.id).destroy_all
81
+ end
82
+
83
+ before_save do
84
+ self.unique_tmdb_id = "#{self.class.to_s.split('::').last.underscore}_#{tmdb_id}"
85
+ end
86
+
87
+ #has_many seasons
88
+ def seasons; [] end
89
+
90
+ #has_many seasons
91
+ def episodes; [] end
92
+
93
+ # belongs_to :serie
94
+ def serie; nil end
95
+
96
+ # belongs_to :season
97
+ def season; nil end
98
+ end
99
+ end
@@ -0,0 +1,25 @@
1
+ module TweekCatalogue
2
+ class VideoCollection
3
+
4
+ include MongoMapper::Document
5
+ include Concerns::I18nSupport
6
+ include Concerns::ObjectFactories
7
+
8
+ # Support i18n fields with en and de locales
9
+ i18n_keys_for :en, :de
10
+
11
+ key :tmdb_id, String
12
+ key :backdrop_path, String
13
+
14
+ i18n_key :name, String
15
+ i18n_key :poster_path, String
16
+
17
+ many :videos, class_name: 'TweekCatalogue::Video', foreign_key: :video_collection_id
18
+
19
+ timestamps!
20
+
21
+ def self.build_primary_key(attrs)
22
+ { tmdb_id: attrs[:tmdb_id].to_s }
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'tweek_catalogue/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "tweek_catalogue"
8
+ spec.version = TweekCatalogue::VERSION
9
+ spec.authors = ["Jeff GOBERT"]
10
+ spec.email = ["jeff@tweek.tv"]
11
+ spec.description = %q{Write a gem description}
12
+ spec.summary = %q{Write a gem summary}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+
24
+ spec.add_runtime_dependency 'mongo_mapper'
25
+ spec.add_runtime_dependency 'activesupport'
26
+ end
metadata ADDED
@@ -0,0 +1,131 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tweek_catalogue
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.33
5
+ platform: ruby
6
+ authors:
7
+ - Jeff GOBERT
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-06-04 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: mongo_mapper
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ! '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: activesupport
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: Write a gem description
70
+ email:
71
+ - jeff@tweek.tv
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - .gitignore
77
+ - Gemfile
78
+ - LICENSE.txt
79
+ - README.md
80
+ - Rakefile
81
+ - lib/tweek_catalogue.rb
82
+ - lib/tweek_catalogue/alternative_title.rb
83
+ - lib/tweek_catalogue/concerns.rb
84
+ - lib/tweek_catalogue/concerns/has_many_relationship.rb
85
+ - lib/tweek_catalogue/concerns/i18n_support.rb
86
+ - lib/tweek_catalogue/concerns/object_factories.rb
87
+ - lib/tweek_catalogue/genre.rb
88
+ - lib/tweek_catalogue/image.rb
89
+ - lib/tweek_catalogue/keyword.rb
90
+ - lib/tweek_catalogue/movie.rb
91
+ - lib/tweek_catalogue/network.rb
92
+ - lib/tweek_catalogue/participant.rb
93
+ - lib/tweek_catalogue/person.rb
94
+ - lib/tweek_catalogue/production_company.rb
95
+ - lib/tweek_catalogue/production_country.rb
96
+ - lib/tweek_catalogue/release.rb
97
+ - lib/tweek_catalogue/serie.rb
98
+ - lib/tweek_catalogue/serie_episode.rb
99
+ - lib/tweek_catalogue/serie_season.rb
100
+ - lib/tweek_catalogue/spoken_language.rb
101
+ - lib/tweek_catalogue/trailer.rb
102
+ - lib/tweek_catalogue/version.rb
103
+ - lib/tweek_catalogue/video.rb
104
+ - lib/tweek_catalogue/video_collection.rb
105
+ - tweek_catalogue.gemspec
106
+ homepage: ''
107
+ licenses:
108
+ - MIT
109
+ metadata: {}
110
+ post_install_message:
111
+ rdoc_options: []
112
+ require_paths:
113
+ - lib
114
+ required_ruby_version: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ! '>='
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ required_rubygems_version: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ! '>='
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ requirements: []
125
+ rubyforge_project:
126
+ rubygems_version: 2.0.3
127
+ signing_key:
128
+ specification_version: 4
129
+ summary: Write a gem summary
130
+ test_files: []
131
+ has_rdoc: