thetvdb_mapper 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +1 -1
  3. data/README.md +5 -14
  4. data/lib/thetvdb_mapper.rb +4 -10
  5. data/lib/thetvdb_mapper/actor.rb +7 -0
  6. data/lib/thetvdb_mapper/banner.rb +14 -0
  7. data/lib/thetvdb_mapper/base.rb +3 -9
  8. data/lib/thetvdb_mapper/episode.rb +32 -11
  9. data/lib/thetvdb_mapper/series.rb +25 -11
  10. data/lib/thetvdb_mapper/version.rb +1 -1
  11. data/spec/functionals/actor_spec.rb +34 -0
  12. data/spec/functionals/banner_spec.rb +49 -0
  13. data/spec/functionals/episode_spec.rb +88 -0
  14. data/spec/functionals/series_spec.rb +72 -0
  15. data/thetvdb_mapper.gemspec +2 -1
  16. metadata +29 -65
  17. data/lib/thetvdb_mapper/actors.rb +0 -17
  18. data/lib/thetvdb_mapper/banners.rb +0 -17
  19. data/lib/thetvdb_mapper/fetcher.rb +0 -25
  20. data/lib/thetvdb_mapper/full_series.rb +0 -53
  21. data/lib/thetvdb_mapper/mapping/actor.rb +0 -11
  22. data/lib/thetvdb_mapper/mapping/banner.rb +0 -18
  23. data/lib/thetvdb_mapper/mapping/base.rb +0 -27
  24. data/lib/thetvdb_mapper/mapping/episode.rb +0 -45
  25. data/lib/thetvdb_mapper/mapping/series.rb +0 -36
  26. data/lib/thetvdb_mapper/mapping/string_list.rb +0 -5
  27. data/spec/functionals/mapping/actor_spec.rb +0 -36
  28. data/spec/functionals/mapping/banner_spec.rb +0 -72
  29. data/spec/functionals/mapping/episode_spec.rb +0 -165
  30. data/spec/functionals/mapping/series_spec.rb +0 -128
  31. data/spec/integrations/classes/actors_spec.rb +0 -11
  32. data/spec/integrations/classes/banners_spec.rb +0 -11
  33. data/spec/integrations/classes/episode_spec.rb +0 -11
  34. data/spec/integrations/classes/fetcher_spec.rb +0 -35
  35. data/spec/integrations/classes/full_series_spec.rb +0 -11
  36. data/spec/integrations/classes/series_spec.rb +0 -11
  37. data/spec/integrations/integration_spec_helper.rb +0 -2
  38. data/spec/integrations/support/.keep +0 -0
  39. data/spec/units/actors_spec.rb +0 -40
  40. data/spec/units/banners_spec.rb +0 -40
  41. data/spec/units/base_spec.rb +0 -15
  42. data/spec/units/episode_spec.rb +0 -33
  43. data/spec/units/fetcher_spec.rb +0 -67
  44. data/spec/units/full_series_spec.rb +0 -140
  45. data/spec/units/mapping/actor_spec.rb +0 -27
  46. data/spec/units/mapping/banner_spec.rb +0 -54
  47. data/spec/units/mapping/base_spec.rb +0 -36
  48. data/spec/units/mapping/episode_spec.rb +0 -142
  49. data/spec/units/mapping/series_spec.rb +0 -114
  50. data/spec/units/mapping/string_list_spec.rb +0 -11
  51. data/spec/units/series_spec.rb +0 -33
@@ -18,7 +18,8 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ['lib']
20
20
 
21
- spec.add_runtime_dependency 'thetvdb_api', '~> 0.2.3'
21
+ spec.add_runtime_dependency 'thetvdb_api', '~> 0.2.4'
22
+ spec.add_runtime_dependency 'hashie', '~> 3.0.0'
22
23
 
23
24
  spec.add_development_dependency 'bundler', '~> 1.3'
24
25
  spec.add_development_dependency 'rake'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thetvdb_mapper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Krzysztof Wawer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-08 00:00:00.000000000 Z
11
+ date: 2014-06-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thetvdb_api
@@ -16,14 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - ~>
18
18
  - !ruby/object:Gem::Version
19
- version: 0.2.3
19
+ version: 0.2.4
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ~>
25
25
  - !ruby/object:Gem::Version
26
- version: 0.2.3
26
+ version: 0.2.4
27
+ - !ruby/object:Gem::Dependency
28
+ name: hashie
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 3.0.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: 3.0.0
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: bundler
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -94,46 +108,17 @@ files:
94
108
  - README.md
95
109
  - Rakefile
96
110
  - lib/thetvdb_mapper.rb
97
- - lib/thetvdb_mapper/actors.rb
98
- - lib/thetvdb_mapper/banners.rb
111
+ - lib/thetvdb_mapper/actor.rb
112
+ - lib/thetvdb_mapper/banner.rb
99
113
  - lib/thetvdb_mapper/base.rb
100
114
  - 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
115
  - lib/thetvdb_mapper/series.rb
110
116
  - 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
117
+ - spec/functionals/actor_spec.rb
118
+ - spec/functionals/banner_spec.rb
119
+ - spec/functionals/episode_spec.rb
120
+ - spec/functionals/series_spec.rb
123
121
  - 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
122
  - thetvdb_mapper.gemspec
138
123
  homepage: http://github.com/wafcio/thetvdb_mapper
139
124
  licenses:
@@ -155,34 +140,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
155
140
  version: '0'
156
141
  requirements: []
157
142
  rubyforge_project:
158
- rubygems_version: 2.0.0
143
+ rubygems_version: 2.0.3
159
144
  signing_key:
160
145
  specification_version: 4
161
146
  summary: Mapping and normalizing data from thetvdb.com
162
147
  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
148
+ - spec/functionals/actor_spec.rb
149
+ - spec/functionals/banner_spec.rb
150
+ - spec/functionals/episode_spec.rb
151
+ - spec/functionals/series_spec.rb
175
152
  - 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
@@ -1,17 +0,0 @@
1
- class ThetvdbMapper::Actors < ThetvdbMapper::Base
2
- def data
3
- @data ||= fetcher.actors(id).body.map { |actor| map(actor) }
4
- end
5
-
6
- def map(data)
7
- mapping_object(data).map
8
- end
9
-
10
- def inspect
11
- "<ThetvdbMapper::Actors data=#{data.to_s} >"
12
- end
13
-
14
- def mapping_object(data)
15
- ThetvdbMapper::Mapping::Actor.new(data)
16
- end
17
- end
@@ -1,17 +0,0 @@
1
- class ThetvdbMapper::Banners < ThetvdbMapper::Base
2
- def data
3
- @data ||= fetcher.banners(id).body.map { |banner| map(banner) }
4
- end
5
-
6
- def map(data)
7
- mapping_object(data).map
8
- end
9
-
10
- def inspect
11
- "<ThetvdbMapper::Banners data=#{data.to_s} >"
12
- end
13
-
14
- def mapping_object(data)
15
- ThetvdbMapper::Mapping::Banner.new(data)
16
- end
17
- end
@@ -1,25 +0,0 @@
1
- class ThetvdbMapper::Fetcher
2
- def series(id)
3
- @series ||= client.series.find(id, mapping: true)
4
- end
5
-
6
- def full_series(id)
7
- @full_series ||= client.series.find_full(id, mapping: true)
8
- end
9
-
10
- def actors(id)
11
- @actors ||= client.actor.find(id, mapping: true)
12
- end
13
-
14
- def banners(id)
15
- @banners ||= client.banner.find(id, mapping: true)
16
- end
17
-
18
- def episode(id)
19
- @episode ||= client.episode.find(id, mapping: true)
20
- end
21
-
22
- def client
23
- ThetvdbApi::Client.new
24
- end
25
- end
@@ -1,53 +0,0 @@
1
- class ThetvdbMapper::FullSeries < ThetvdbMapper::Base
2
- def data
3
- @data ||= series.merge(episodes: episodes, actors: actors, banners: banners)
4
- end
5
-
6
- def series
7
- mapping_series_object(fetcher.full_series(id).body['Series']).map
8
- end
9
-
10
- def episodes
11
- fetcher.full_series(id).body['Episode'].map { |episode| map_episode(episode) }
12
- end
13
-
14
- def map_episode(data)
15
- mapping_episode_object(data).map
16
- end
17
-
18
- def actors
19
- fetcher.actors(id).body.map { |actor| map_actor(actor) }
20
- end
21
-
22
- def map_actor(data)
23
- mapping_actor_object(data).map
24
- end
25
-
26
- def banners
27
- fetcher.banners(id).body.map { |banner| map_banner(banner) }
28
- end
29
-
30
- def map_banner(data)
31
- mapping_banner_object(data).map
32
- end
33
-
34
- def mapping_series_object(data)
35
- ThetvdbMapper::Mapping::Series.new(data)
36
- end
37
-
38
- def mapping_episode_object(data)
39
- ThetvdbMapper::Mapping::Episode.new(data)
40
- end
41
-
42
- def mapping_actor_object(data)
43
- ThetvdbMapper::Mapping::Actor.new(data)
44
- end
45
-
46
- def mapping_banner_object(data)
47
- ThetvdbMapper::Mapping::Banner.new(data)
48
- end
49
-
50
- def inspect
51
- "<ThetvdbMapper::FullSeries data=#{data.to_s} >"
52
- end
53
- end
@@ -1,11 +0,0 @@
1
- class ThetvdbMapper::Mapping::Actor < ThetvdbMapper::Mapping::Base
2
- def rules
3
- {
4
- 'id' => :id,
5
- 'Image' => :image_path,
6
- 'Name' => :name,
7
- 'Role' => :role,
8
- 'SortOrder' => :sort_order
9
- }
10
- end
11
- end
@@ -1,18 +0,0 @@
1
- class ThetvdbMapper::Mapping::Banner < ThetvdbMapper::Mapping::Base
2
- def rules
3
- {
4
- 'id' => :id,
5
- 'BannerPath' => :path,
6
- 'ThumbnailPath' => :thumbnail_path,
7
- 'VignettePath' => :vignette_path,
8
- 'BannerType' => :kind,
9
- 'BannerType2' => :kind2,
10
- 'Language' => :language,
11
- 'Season' => :season,
12
- 'Rating' => :rating,
13
- 'RatingCount' => :rating_count,
14
- 'SeriesName' => :series_name,
15
- 'Colors' => :colors,
16
- }
17
- end
18
- end
@@ -1,27 +0,0 @@
1
- class ThetvdbMapper::Mapping::Base
2
- attr_reader :data
3
-
4
- def initialize(data)
5
- @data = data
6
- end
7
-
8
- def map
9
- rules.each do |before, after|
10
- data[after] = data.delete(before)
11
- end
12
-
13
- convert.reject{ |key, _| key.is_a?(String) }
14
- end
15
-
16
- def convert
17
- data
18
- end
19
-
20
- def convert_to_list(data)
21
- list_mapping_object(data).map
22
- end
23
-
24
- def list_mapping_object(data)
25
- ThetvdbMapper::Mapping::StringList.new(data)
26
- end
27
- end
@@ -1,45 +0,0 @@
1
- class ThetvdbMapper::Mapping::Episode < ThetvdbMapper::Mapping::Base
2
- def rules
3
- {
4
- 'id' => :id,
5
- 'Combined_episodenumber' => :combined_episode_number,
6
- 'Combined_season' => :combined_season,
7
- 'DVD_episodenumber' => :dvd_episode_number,
8
- 'DVD_season' => :dvd_season,
9
- 'Director' => :director,
10
- 'EpImgFlag' => :ep_img_flag,
11
- 'EpisodeName' => :name,
12
- 'EpisodeNumber' => :number,
13
- 'FirstAired' => :first_aired,
14
- 'GuestStars' => :guest_stars,
15
- 'IMDB_ID' => :imdb_id,
16
- 'Language' => :language,
17
- 'Overview' => :overview,
18
- 'ProductionCode' => :production_code,
19
- 'Rating' => :rating,
20
- 'RatingCount' => :rating_count,
21
- 'SeasonNumber' => :season,
22
- 'Writer' => :writer,
23
- 'absolute_number' => :absolute_number,
24
- 'airsafter_season' => :airs_after_season,
25
- 'airsbefore_episode' => :airs_before_episode,
26
- 'airsbefore_season' => :airs_before_season,
27
- 'filename' => :filename_path,
28
- 'lastupdated' => :last_updated_at,
29
- 'seasonid' => :season_id,
30
- 'seriesid' => :series_id,
31
- 'thumb_added' => :thumbnail_added_at,
32
- 'thumb_height' => :thumbnail_height,
33
- 'thumb_width' => :thumbnail_width
34
- }
35
- end
36
-
37
- def convert
38
- data.merge({
39
- director: convert_to_list(data[:director]),
40
- guest_stars: convert_to_list(data[:guest_stars]),
41
- writer: convert_to_list(data[:writer]),
42
- last_updated_at: Time.at(data[:last_updated_at].to_i)
43
- })
44
- end
45
- end
@@ -1,36 +0,0 @@
1
- class ThetvdbMapper::Mapping::Series < ThetvdbMapper::Mapping::Base
2
- def rules
3
- {
4
- 'id' => :id,
5
- 'Airs_DayOfWeek' => :airs_day_of_week,
6
- 'Airs_Time' => :airs_time,
7
- 'ContentRating' => :content_rating,
8
- 'FirstAired' => :first_aired,
9
- 'Genre' => :genres,
10
- 'IMDB_ID' => :imdb_id,
11
- 'Language' => :language,
12
- 'Network' => :network,
13
- 'NetworkID' => :network_id,
14
- 'Overview' => :overview,
15
- 'Rating' => :rating,
16
- 'RatingCount' => :rating_count,
17
- 'Runtime' => :runtime,
18
- 'SeriesName' => :name,
19
- 'Status' => :status,
20
- 'added' => :added_at,
21
- 'addedBy' => :added_by,
22
- 'banner' => :banner_path,
23
- 'fanart' => :fanart_path,
24
- 'lastupdated' => :last_updated_at,
25
- 'poster' => :poster_path,
26
- 'zap2it_id' => :zap2it_id
27
- }
28
- end
29
-
30
- def convert
31
- data.merge({
32
- genres: convert_to_list(data[:genres]),
33
- last_updated_at: Time.at(data[:last_updated_at].to_i)
34
- })
35
- end
36
- end
@@ -1,5 +0,0 @@
1
- class ThetvdbMapper::Mapping::StringList < ThetvdbMapper::Mapping::Base
2
- def map
3
- data.to_s.split('|').reject{ |element| element.empty? }
4
- end
5
- end
@@ -1,36 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe ThetvdbMapper::Mapping::Actor do
4
- let(:model) { ThetvdbMapper::Mapping::Actor.new({}) }
5
-
6
- describe '.map' do
7
- it 'should return specific keys' do
8
- model.map.keys.sort.should == [:id, :image_path, :name, :role, :sort_order].sort
9
- end
10
-
11
- it 'should map id' do
12
- model.stub(:data).and_return('id' => 1234)
13
- model.map[:id].should == 1234
14
- end
15
-
16
- it 'should map Image' do
17
- model.stub(:data).and_return('Image' => 'test')
18
- model.map[:image_path].should == 'test'
19
- end
20
-
21
- it 'should map Name' do
22
- model.stub(:data).and_return('Name' => 'test')
23
- model.map[:name].should == 'test'
24
- end
25
-
26
- it 'should map Role' do
27
- model.stub(:data).and_return('Role' => 'test')
28
- model.map[:role].should == 'test'
29
- end
30
-
31
- it 'should map SortOrder' do
32
- model.stub(:data).and_return('SortOrder' => 1)
33
- model.map[:sort_order].should == 1
34
- end
35
- end
36
- end