thetvdb_mapper 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +19 -0
  3. data/.travis.yml +6 -0
  4. data/Gemfile +4 -0
  5. data/LICENSE.txt +22 -0
  6. data/README.md +41 -0
  7. data/Rakefile +1 -0
  8. data/lib/thetvdb_mapper/actors.rb +13 -0
  9. data/lib/thetvdb_mapper/banners.rb +13 -0
  10. data/lib/thetvdb_mapper/base.rb +11 -0
  11. data/lib/thetvdb_mapper/episode.rb +9 -0
  12. data/lib/thetvdb_mapper/fetcher.rb +25 -0
  13. data/lib/thetvdb_mapper/full_series.rb +37 -0
  14. data/lib/thetvdb_mapper/mapping/actor.rb +11 -0
  15. data/lib/thetvdb_mapper/mapping/banner.rb +17 -0
  16. data/lib/thetvdb_mapper/mapping/base.rb +17 -0
  17. data/lib/thetvdb_mapper/mapping/episode.rb +45 -0
  18. data/lib/thetvdb_mapper/mapping/series.rb +36 -0
  19. data/lib/thetvdb_mapper/mapping/string_list.rb +5 -0
  20. data/lib/thetvdb_mapper/series.rb +9 -0
  21. data/lib/thetvdb_mapper/version.rb +3 -0
  22. data/lib/thetvdb_mapper.rb +18 -0
  23. data/spec/functionals/mapping/actor_spec.rb +31 -0
  24. data/spec/functionals/mapping/banner_spec.rb +56 -0
  25. data/spec/functionals/mapping/episode_spec.rb +135 -0
  26. data/spec/functionals/mapping/series_spec.rb +105 -0
  27. data/spec/integrations/classes/actors_spec.rb +11 -0
  28. data/spec/integrations/classes/banners_spec.rb +11 -0
  29. data/spec/integrations/classes/episode_spec.rb +11 -0
  30. data/spec/integrations/classes/fetcher_spec.rb +35 -0
  31. data/spec/integrations/classes/full_series_spec.rb +11 -0
  32. data/spec/integrations/classes/series_spec.rb +11 -0
  33. data/spec/integrations/integration_spec_helper.rb +2 -0
  34. data/spec/integrations/support/.keep +0 -0
  35. data/spec/spec_helper.rb +10 -0
  36. data/spec/units/actors_spec.rb +33 -0
  37. data/spec/units/banners_spec.rb +33 -0
  38. data/spec/units/base_spec.rb +15 -0
  39. data/spec/units/episode_spec.rb +26 -0
  40. data/spec/units/fetcher_spec.rb +67 -0
  41. data/spec/units/full_series_spec.rb +109 -0
  42. data/spec/units/mapping/actor_spec.rb +27 -0
  43. data/spec/units/mapping/banner_spec.rb +51 -0
  44. data/spec/units/mapping/base_spec.rb +29 -0
  45. data/spec/units/mapping/episode_spec.rb +141 -0
  46. data/spec/units/mapping/series_spec.rb +113 -0
  47. data/spec/units/mapping/string_list_spec.rb +11 -0
  48. data/spec/units/series_spec.rb +26 -0
  49. data/thetvdb_mapper.gemspec +27 -0
  50. metadata +188 -0
@@ -0,0 +1,141 @@
1
+ require 'spec_helper'
2
+
3
+ describe ThetvdbMapper::Mapping::Episode do
4
+ let(:klass) { ThetvdbMapper::Mapping::Episode }
5
+
6
+ describe '#map' do
7
+ it 'should map id' do
8
+ klass.rules['id'].should == :id
9
+ end
10
+
11
+ it 'should map Combined_episodenumber' do
12
+ klass.rules['Combined_episodenumber'].should == :combined_episode_number
13
+ end
14
+
15
+ it 'should map Combined_season' do
16
+ klass.rules['Combined_season'].should == :combined_season
17
+ end
18
+
19
+ it 'should map DVD_episodenumber' do
20
+ klass.rules['DVD_episodenumber'].should == :dvd_episode_number
21
+ end
22
+
23
+ it 'should map DVD_season' do
24
+ klass.rules['DVD_season'].should == :dvd_season
25
+ end
26
+
27
+ it 'should map Director' do
28
+ klass.rules['Director'].should == :director
29
+ end
30
+
31
+ it 'should map EpImgFlag' do
32
+ klass.rules['EpImgFlag'].should == :ep_img_flag
33
+ end
34
+
35
+ it 'should map EpisodeName' do
36
+ klass.rules['EpisodeName'].should == :name
37
+ end
38
+
39
+ it 'should map EpisodeNumber' do
40
+ klass.rules['EpisodeNumber'].should == :number
41
+ end
42
+
43
+ it 'should map FirstAired' do
44
+ klass.rules['FirstAired'].should == :first_aired
45
+ end
46
+
47
+ it 'should map GuestStars' do
48
+ klass.rules['GuestStars'].should == :guest_stars
49
+ end
50
+
51
+ it 'should map IMDB_ID' do
52
+ klass.rules['IMDB_ID'].should == :imdb_id
53
+ end
54
+
55
+ it 'should map Language' do
56
+ klass.rules['Language'].should == :language
57
+ end
58
+
59
+ it 'should map Overview' do
60
+ klass.rules['Overview'].should == :overview
61
+ end
62
+
63
+ it 'should map ProductionCode' do
64
+ klass.rules['ProductionCode'].should == :production_code
65
+ end
66
+
67
+ it 'should map Rating' do
68
+ klass.rules['Rating'].should == :rating
69
+ end
70
+
71
+ it 'should map RatingCount' do
72
+ klass.rules['RatingCount'].should == :rating_count
73
+ end
74
+
75
+ it 'should map SeasonNumber' do
76
+ klass.rules['SeasonNumber'].should == :season
77
+ end
78
+
79
+ it 'should map Writer' do
80
+ klass.rules['Writer'].should == :writer
81
+ end
82
+
83
+ it 'should map absolute_number' do
84
+ klass.rules['absolute_number'].should == :absolute_number
85
+ end
86
+
87
+ it 'should map airsafter_season' do
88
+ klass.rules['airsafter_season'].should == :airs_after_season
89
+ end
90
+
91
+ it 'should map airsbefore_episode' do
92
+ klass.rules['airsbefore_episode'].should == :airs_before_episode
93
+ end
94
+
95
+ it 'should map airsbefore_season' do
96
+ klass.rules['airsbefore_season'].should == :airs_before_season
97
+ end
98
+
99
+ it 'should map filename' do
100
+ klass.rules['filename'].should == :filename_path
101
+ end
102
+
103
+ it 'should map lastupdated' do
104
+ klass.rules['lastupdated'].should == :last_updated_at
105
+ end
106
+
107
+ it 'should map season_id' do
108
+ klass.rules['season_id'].should == :season_id
109
+ end
110
+
111
+ it 'should map series_id' do
112
+ klass.rules['series_id'].should == :series_id
113
+ end
114
+
115
+ it 'should map thumb_added' do
116
+ klass.rules['thumb_added'].should == :thumbnail_added_at
117
+ end
118
+
119
+ it 'should map thumb_height' do
120
+ klass.rules['thumb_height'].should == :thumbnail_height
121
+ end
122
+
123
+ it 'should map thumb_weight' do
124
+ klass.rules['thumb_weight'].should == :thumbnail_width
125
+ end
126
+ end
127
+
128
+ describe '#convert' do
129
+ let(:input) { { director: true, guest_stars: true, writer: true, last_updated_at: 1} }
130
+ let(:output) { { director: 'LIST', guest_stars: 'LIST', writer: 'LIST', last_updated_at: 'TIME'} }
131
+
132
+ before do
133
+ klass.stub(:convert_to_list).and_return('LIST')
134
+ Time.stub(:at).and_return('TIME')
135
+ end
136
+
137
+ it 'should return correct hash' do
138
+ klass.convert(input).should == output
139
+ end
140
+ end
141
+ end
@@ -0,0 +1,113 @@
1
+ require 'spec_helper'
2
+
3
+ describe ThetvdbMapper::Mapping::Series do
4
+ let(:klass) { ThetvdbMapper::Mapping::Series }
5
+
6
+ describe '#rules' do
7
+ it 'should map id' do
8
+ klass.rules['id'].should == :id
9
+ end
10
+
11
+ it 'should map Airs_DayOfWeek' do
12
+ klass.rules['Airs_DayOfWeek'].should == :airs_day_of_week
13
+ end
14
+
15
+ it 'should map Airs_Time' do
16
+ klass.rules['Airs_Time'].should == :airs_time
17
+ end
18
+
19
+ it 'should map ContentRating' do
20
+ klass.rules['ContentRating'].should == :content_rating
21
+ end
22
+
23
+ it 'should map FirstAired' do
24
+ klass.rules['FirstAired'].should == :first_aired
25
+ end
26
+
27
+ it 'should map genre' do
28
+ klass.rules['genre'].should == :genres
29
+ end
30
+
31
+ it 'should map IMDB_ID' do
32
+ klass.rules['IMDB_ID'].should == :imdb_id
33
+ end
34
+
35
+ it 'should map Language' do
36
+ klass.rules['Language'].should == :language
37
+ end
38
+
39
+ it 'should map Network' do
40
+ klass.rules['Network'].should == :network
41
+ end
42
+
43
+ it 'should map NetworkID' do
44
+ klass.rules['NetworkID'].should == :network_id
45
+ end
46
+
47
+ it 'should map Overview' do
48
+ klass.rules['Overview'].should == :overview
49
+ end
50
+
51
+ it 'should map Rating' do
52
+ klass.rules['Rating'].should == :rating
53
+ end
54
+
55
+ it 'should map RatingCount' do
56
+ klass.rules['RatingCount'].should == :rating_count
57
+ end
58
+
59
+ it 'should map Runtime' do
60
+ klass.rules['Runtime'].should == :runtime
61
+ end
62
+
63
+ it 'should map SeriesName' do
64
+ klass.rules['SeriesName'].should == :name
65
+ end
66
+
67
+ it 'should map Status' do
68
+ klass.rules['Status'].should == :status
69
+ end
70
+
71
+ it 'should map added' do
72
+ klass.rules['added'].should == :added_at
73
+ end
74
+
75
+ it 'should map added_by' do
76
+ klass.rules['added_by'].should == :added_by
77
+ end
78
+
79
+ it 'should map banner' do
80
+ klass.rules['banner'].should == :banner_path
81
+ end
82
+
83
+ it 'should map fanart' do
84
+ klass.rules['fanart'].should == :fanart_path
85
+ end
86
+
87
+ it 'should map lastupdated' do
88
+ klass.rules['lastupdated'].should == :last_updated_at
89
+ end
90
+
91
+ it 'should map poster' do
92
+ klass.rules['poster'].should == :poster_path
93
+ end
94
+
95
+ it 'should map zap2it_id' do
96
+ klass.rules['zap2it_id'].should == :zap2it_id
97
+ end
98
+ end
99
+
100
+ describe '#convert' do
101
+ let(:input) { { genres: true, last_updated_at: 1} }
102
+ let(:output) { { genres: 'LIST', last_updated_at: 'TIME'} }
103
+
104
+ before do
105
+ klass.stub(:convert_to_list).and_return('LIST')
106
+ Time.stub(:at).and_return('TIME')
107
+ end
108
+
109
+ it 'should return correct hash' do
110
+ klass.convert(input).should == output
111
+ end
112
+ end
113
+ end
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ describe ThetvdbMapper::Mapping::StringList do
4
+ let(:klass) { ThetvdbMapper::Mapping::StringList }
5
+
6
+ describe '#map' do
7
+ it 'should return array' do
8
+ klass.map('|test|').should == ['test']
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,26 @@
1
+ require 'spec_helper'
2
+
3
+ describe ThetvdbMapper::Series do
4
+ let(:model) { ThetvdbMapper::Series.new(1) }
5
+
6
+ describe '.data' do
7
+ before do
8
+ model.stub_chain(:fetcher, :series, :body).and_return(sample: true)
9
+ end
10
+
11
+ it 'should call map on mapping class' do
12
+ ThetvdbMapper::Mapping::Series.should_receive(:map).with(sample: true)
13
+ model.data
14
+ end
15
+ end
16
+
17
+ describe '.inspect' do
18
+ before do
19
+ model.stub(:data).and_return('DATA')
20
+ end
21
+
22
+ it 'should return correct string' do
23
+ model.inspect.should == '<ThetvdbMapper::Series data=DATA >'
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'thetvdb_mapper/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'thetvdb_mapper'
8
+ spec.version = ThetvdbMapper::VERSION
9
+ spec.authors = ['Krzysztof Wawer']
10
+ spec.email = ['krzysztof.wawer@gmail.com']
11
+ spec.description = %q{Mapping and normalizing data fetched by thetvdb_api}
12
+ spec.summary = %q{Mapping and normalizing data from thetvdb.com}
13
+ spec.homepage = %q{http://github.com/wafcio/thetvdb_mapper}
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_runtime_dependency 'thetvdb_api', '~> 0.2.3'
22
+
23
+ spec.add_development_dependency 'bundler', '~> 1.3'
24
+ spec.add_development_dependency 'rake'
25
+ spec.add_development_dependency 'rspec', '~> 2.14.1'
26
+ spec.add_development_dependency 'coveralls', '~> 0.7'
27
+ end
metadata ADDED
@@ -0,0 +1,188 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: thetvdb_mapper
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Krzysztof Wawer
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-01-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thetvdb_api
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: 0.2.3
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: 0.2.3
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '1.3'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
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: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 2.14.1
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: 2.14.1
69
+ - !ruby/object:Gem::Dependency
70
+ name: coveralls
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: '0.7'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: '0.7'
83
+ description: Mapping and normalizing data fetched by thetvdb_api
84
+ email:
85
+ - krzysztof.wawer@gmail.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - .gitignore
91
+ - .travis.yml
92
+ - Gemfile
93
+ - LICENSE.txt
94
+ - README.md
95
+ - Rakefile
96
+ - lib/thetvdb_mapper.rb
97
+ - lib/thetvdb_mapper/actors.rb
98
+ - lib/thetvdb_mapper/banners.rb
99
+ - lib/thetvdb_mapper/base.rb
100
+ - lib/thetvdb_mapper/episode.rb
101
+ - lib/thetvdb_mapper/fetcher.rb
102
+ - lib/thetvdb_mapper/full_series.rb
103
+ - lib/thetvdb_mapper/mapping/actor.rb
104
+ - lib/thetvdb_mapper/mapping/banner.rb
105
+ - lib/thetvdb_mapper/mapping/base.rb
106
+ - lib/thetvdb_mapper/mapping/episode.rb
107
+ - lib/thetvdb_mapper/mapping/series.rb
108
+ - lib/thetvdb_mapper/mapping/string_list.rb
109
+ - lib/thetvdb_mapper/series.rb
110
+ - lib/thetvdb_mapper/version.rb
111
+ - spec/functionals/mapping/actor_spec.rb
112
+ - spec/functionals/mapping/banner_spec.rb
113
+ - spec/functionals/mapping/episode_spec.rb
114
+ - spec/functionals/mapping/series_spec.rb
115
+ - spec/integrations/classes/actors_spec.rb
116
+ - spec/integrations/classes/banners_spec.rb
117
+ - spec/integrations/classes/episode_spec.rb
118
+ - spec/integrations/classes/fetcher_spec.rb
119
+ - spec/integrations/classes/full_series_spec.rb
120
+ - spec/integrations/classes/series_spec.rb
121
+ - spec/integrations/integration_spec_helper.rb
122
+ - spec/integrations/support/.keep
123
+ - spec/spec_helper.rb
124
+ - spec/units/actors_spec.rb
125
+ - spec/units/banners_spec.rb
126
+ - spec/units/base_spec.rb
127
+ - spec/units/episode_spec.rb
128
+ - spec/units/fetcher_spec.rb
129
+ - spec/units/full_series_spec.rb
130
+ - spec/units/mapping/actor_spec.rb
131
+ - spec/units/mapping/banner_spec.rb
132
+ - spec/units/mapping/base_spec.rb
133
+ - spec/units/mapping/episode_spec.rb
134
+ - spec/units/mapping/series_spec.rb
135
+ - spec/units/mapping/string_list_spec.rb
136
+ - spec/units/series_spec.rb
137
+ - thetvdb_mapper.gemspec
138
+ homepage: http://github.com/wafcio/thetvdb_mapper
139
+ licenses:
140
+ - MIT
141
+ metadata: {}
142
+ post_install_message:
143
+ rdoc_options: []
144
+ require_paths:
145
+ - lib
146
+ required_ruby_version: !ruby/object:Gem::Requirement
147
+ requirements:
148
+ - - '>='
149
+ - !ruby/object:Gem::Version
150
+ version: '0'
151
+ required_rubygems_version: !ruby/object:Gem::Requirement
152
+ requirements:
153
+ - - '>='
154
+ - !ruby/object:Gem::Version
155
+ version: '0'
156
+ requirements: []
157
+ rubyforge_project:
158
+ rubygems_version: 2.0.0
159
+ signing_key:
160
+ specification_version: 4
161
+ summary: Mapping and normalizing data from thetvdb.com
162
+ test_files:
163
+ - spec/functionals/mapping/actor_spec.rb
164
+ - spec/functionals/mapping/banner_spec.rb
165
+ - spec/functionals/mapping/episode_spec.rb
166
+ - spec/functionals/mapping/series_spec.rb
167
+ - spec/integrations/classes/actors_spec.rb
168
+ - spec/integrations/classes/banners_spec.rb
169
+ - spec/integrations/classes/episode_spec.rb
170
+ - spec/integrations/classes/fetcher_spec.rb
171
+ - spec/integrations/classes/full_series_spec.rb
172
+ - spec/integrations/classes/series_spec.rb
173
+ - spec/integrations/integration_spec_helper.rb
174
+ - spec/integrations/support/.keep
175
+ - spec/spec_helper.rb
176
+ - spec/units/actors_spec.rb
177
+ - spec/units/banners_spec.rb
178
+ - spec/units/base_spec.rb
179
+ - spec/units/episode_spec.rb
180
+ - spec/units/fetcher_spec.rb
181
+ - spec/units/full_series_spec.rb
182
+ - spec/units/mapping/actor_spec.rb
183
+ - spec/units/mapping/banner_spec.rb
184
+ - spec/units/mapping/base_spec.rb
185
+ - spec/units/mapping/episode_spec.rb
186
+ - spec/units/mapping/series_spec.rb
187
+ - spec/units/mapping/string_list_spec.rb
188
+ - spec/units/series_spec.rb