thetvdb_mapper 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -0
- data/lib/thetvdb_mapper/actors.rb +5 -1
- data/lib/thetvdb_mapper/banners.rb +5 -1
- data/lib/thetvdb_mapper/episode.rb +5 -1
- data/lib/thetvdb_mapper/full_series.rb +20 -4
- data/lib/thetvdb_mapper/mapping/actor.rb +1 -1
- data/lib/thetvdb_mapper/mapping/banner.rb +1 -1
- data/lib/thetvdb_mapper/mapping/base.rb +17 -7
- data/lib/thetvdb_mapper/mapping/episode.rb +2 -2
- data/lib/thetvdb_mapper/mapping/series.rb +2 -2
- data/lib/thetvdb_mapper/mapping/string_list.rb +2 -2
- data/lib/thetvdb_mapper/series.rb +5 -1
- data/lib/thetvdb_mapper/version.rb +1 -1
- data/spec/functionals/mapping/actor_spec.rb +13 -8
- data/spec/functionals/mapping/banner_spec.rb +26 -14
- data/spec/functionals/mapping/episode_spec.rb +62 -32
- data/spec/functionals/mapping/series_spec.rb +48 -25
- data/spec/integrations/classes/episode_spec.rb +0 -1
- data/spec/units/actors_spec.rb +8 -1
- data/spec/units/banners_spec.rb +8 -1
- data/spec/units/episode_spec.rb +8 -1
- data/spec/units/full_series_spec.rb +35 -4
- data/spec/units/mapping/actor_spec.rb +6 -6
- data/spec/units/mapping/banner_spec.rb +13 -13
- data/spec/units/mapping/base_spec.rb +17 -10
- data/spec/units/mapping/episode_spec.rb +34 -33
- data/spec/units/mapping/series_spec.rb +27 -26
- data/spec/units/mapping/string_list_spec.rb +2 -2
- data/spec/units/series_spec.rb +8 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: df92a0026f71306f5581b42f4229459c664526f5
|
4
|
+
data.tar.gz: 5de89ef49942d7cfdb76385d0169edf6bb98ac20
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 55a049dfa7a7fd87bad41192f413eac9c25b285ab035e30ce092fd740d558580faab4b696a333c17c4ee9746ffd9b7e9ed141f432ce161f843a7f344e904de38
|
7
|
+
data.tar.gz: 8dc7e5deefb4b41b6f2f90eace3b295c4a3779281c0598e1574f4f4fb10b0ad1a369487e3a02c357da74f158a0f42fc9e5a27fba01e11aca02db93e4a99503a7
|
data/README.md
CHANGED
@@ -4,10 +4,14 @@ class ThetvdbMapper::Actors < ThetvdbMapper::Base
|
|
4
4
|
end
|
5
5
|
|
6
6
|
def map(data)
|
7
|
-
|
7
|
+
mapping_object(data).map
|
8
8
|
end
|
9
9
|
|
10
10
|
def inspect
|
11
11
|
"<ThetvdbMapper::Actors data=#{data.to_s} >"
|
12
12
|
end
|
13
|
+
|
14
|
+
def mapping_object(data)
|
15
|
+
ThetvdbMapper::Mapping::Actor.new(data)
|
16
|
+
end
|
13
17
|
end
|
@@ -4,10 +4,14 @@ class ThetvdbMapper::Banners < ThetvdbMapper::Base
|
|
4
4
|
end
|
5
5
|
|
6
6
|
def map(data)
|
7
|
-
|
7
|
+
mapping_object(data).map
|
8
8
|
end
|
9
9
|
|
10
10
|
def inspect
|
11
11
|
"<ThetvdbMapper::Banners data=#{data.to_s} >"
|
12
12
|
end
|
13
|
+
|
14
|
+
def mapping_object(data)
|
15
|
+
ThetvdbMapper::Mapping::Banner.new(data)
|
16
|
+
end
|
13
17
|
end
|
@@ -1,9 +1,13 @@
|
|
1
1
|
class ThetvdbMapper::Episode < ThetvdbMapper::Base
|
2
2
|
def data
|
3
|
-
@data ||=
|
3
|
+
@data ||= mapping_object(fetcher.episode(id).body).map
|
4
4
|
end
|
5
5
|
|
6
6
|
def inspect
|
7
7
|
"<ThetvdbMapper::Episode data=#{data.to_s} >"
|
8
8
|
end
|
9
|
+
|
10
|
+
def mapping_object(data)
|
11
|
+
ThetvdbMapper::Mapping::Episode.new(data)
|
12
|
+
end
|
9
13
|
end
|
@@ -4,7 +4,7 @@ class ThetvdbMapper::FullSeries < ThetvdbMapper::Base
|
|
4
4
|
end
|
5
5
|
|
6
6
|
def series
|
7
|
-
|
7
|
+
mapping_series_object(fetcher.full_series(id).body['Series']).map
|
8
8
|
end
|
9
9
|
|
10
10
|
def episodes
|
@@ -12,7 +12,7 @@ class ThetvdbMapper::FullSeries < ThetvdbMapper::Base
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def map_episode(data)
|
15
|
-
|
15
|
+
mapping_episode_object(data).map
|
16
16
|
end
|
17
17
|
|
18
18
|
def actors
|
@@ -20,7 +20,7 @@ class ThetvdbMapper::FullSeries < ThetvdbMapper::Base
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def map_actor(data)
|
23
|
-
|
23
|
+
mapping_actor_object(data).map
|
24
24
|
end
|
25
25
|
|
26
26
|
def banners
|
@@ -28,7 +28,23 @@ class ThetvdbMapper::FullSeries < ThetvdbMapper::Base
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def map_banner(data)
|
31
|
-
|
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)
|
32
48
|
end
|
33
49
|
|
34
50
|
def inspect
|
@@ -1,17 +1,27 @@
|
|
1
1
|
class ThetvdbMapper::Mapping::Base
|
2
|
-
|
2
|
+
attr_reader :data
|
3
|
+
|
4
|
+
def initialize(data)
|
5
|
+
@data = data
|
6
|
+
end
|
7
|
+
|
8
|
+
def map
|
3
9
|
rules.each do |before, after|
|
4
10
|
data[after] = data.delete(before)
|
5
11
|
end
|
6
12
|
|
7
|
-
|
8
|
-
|
9
|
-
|
13
|
+
convert.reject{ |key, _| key.is_a?(String) }
|
14
|
+
end
|
15
|
+
|
16
|
+
def convert
|
17
|
+
data
|
18
|
+
end
|
10
19
|
|
11
|
-
|
20
|
+
def convert_to_list(data)
|
21
|
+
list_mapping_object(data).map
|
12
22
|
end
|
13
23
|
|
14
|
-
def
|
15
|
-
ThetvdbMapper::Mapping::StringList.
|
24
|
+
def list_mapping_object(data)
|
25
|
+
ThetvdbMapper::Mapping::StringList.new(data)
|
16
26
|
end
|
17
27
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
class ThetvdbMapper::Mapping::Episode < ThetvdbMapper::Mapping::Base
|
2
|
-
def
|
2
|
+
def rules
|
3
3
|
{
|
4
4
|
'id' => :id,
|
5
5
|
'Combined_episodenumber' => :combined_episode_number,
|
@@ -34,7 +34,7 @@ class ThetvdbMapper::Mapping::Episode < ThetvdbMapper::Mapping::Base
|
|
34
34
|
}
|
35
35
|
end
|
36
36
|
|
37
|
-
def
|
37
|
+
def convert
|
38
38
|
data.merge({
|
39
39
|
director: convert_to_list(data[:director]),
|
40
40
|
guest_stars: convert_to_list(data[:guest_stars]),
|
@@ -1,5 +1,5 @@
|
|
1
1
|
class ThetvdbMapper::Mapping::Series < ThetvdbMapper::Mapping::Base
|
2
|
-
def
|
2
|
+
def rules
|
3
3
|
{
|
4
4
|
'id' => :id,
|
5
5
|
'Airs_DayOfWeek' => :airs_day_of_week,
|
@@ -27,7 +27,7 @@ class ThetvdbMapper::Mapping::Series < ThetvdbMapper::Mapping::Base
|
|
27
27
|
}
|
28
28
|
end
|
29
29
|
|
30
|
-
def
|
30
|
+
def convert
|
31
31
|
data.merge({
|
32
32
|
genres: convert_to_list(data[:genres]),
|
33
33
|
last_updated_at: Time.at(data[:last_updated_at].to_i)
|
@@ -1,6 +1,10 @@
|
|
1
1
|
class ThetvdbMapper::Series < ThetvdbMapper::Base
|
2
2
|
def data
|
3
|
-
@data ||=
|
3
|
+
@data ||= mapping_object(fetcher.series(id).body).map
|
4
|
+
end
|
5
|
+
|
6
|
+
def mapping_object(data)
|
7
|
+
ThetvdbMapper::Mapping::Series.new(data)
|
4
8
|
end
|
5
9
|
|
6
10
|
def inspect
|
@@ -1,31 +1,36 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe ThetvdbMapper::Mapping::Actor do
|
4
|
-
let(:
|
4
|
+
let(:model) { ThetvdbMapper::Mapping::Actor.new({}) }
|
5
5
|
|
6
|
-
describe '
|
6
|
+
describe '.map' do
|
7
7
|
it 'should return specific keys' do
|
8
|
-
|
8
|
+
model.map.keys.sort.should == [:id, :image_path, :name, :role, :sort_order].sort
|
9
9
|
end
|
10
10
|
|
11
11
|
it 'should map id' do
|
12
|
-
|
12
|
+
model.stub(:data).and_return('id' => 1234)
|
13
|
+
model.map[:id].should == 1234
|
13
14
|
end
|
14
15
|
|
15
16
|
it 'should map Image' do
|
16
|
-
|
17
|
+
model.stub(:data).and_return('Image' => 'test')
|
18
|
+
model.map[:image_path].should == 'test'
|
17
19
|
end
|
18
20
|
|
19
21
|
it 'should map Name' do
|
20
|
-
|
22
|
+
model.stub(:data).and_return('Name' => 'test')
|
23
|
+
model.map[:name].should == 'test'
|
21
24
|
end
|
22
25
|
|
23
26
|
it 'should map Role' do
|
24
|
-
|
27
|
+
model.stub(:data).and_return('Role' => 'test')
|
28
|
+
model.map[:role].should == 'test'
|
25
29
|
end
|
26
30
|
|
27
31
|
it 'should map SortOrder' do
|
28
|
-
|
32
|
+
model.stub(:data).and_return('SortOrder' => 1)
|
33
|
+
model.map[:sort_order].should == 1
|
29
34
|
end
|
30
35
|
end
|
31
36
|
end
|
@@ -1,60 +1,72 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe ThetvdbMapper::Mapping::Banner do
|
4
|
-
let(:
|
4
|
+
let(:model) { ThetvdbMapper::Mapping::Banner.new({}) }
|
5
5
|
|
6
6
|
describe '#map' do
|
7
7
|
it 'should return specific keys' do
|
8
|
-
|
8
|
+
model.map.keys.sort.should == [:path, :thumbnail_path, :vignette_path, :type, :type2, :language, :season,
|
9
9
|
:rating, :rating_count, :series_name, :colors, :id].sort
|
10
10
|
end
|
11
11
|
|
12
12
|
it 'should map id' do
|
13
|
-
|
13
|
+
model.stub(:data).and_return('id' => '1')
|
14
|
+
model.map[:id].should == '1'
|
14
15
|
end
|
15
16
|
|
16
17
|
it 'should map BannerPath' do
|
17
|
-
|
18
|
+
model.stub(:data).and_return('BannerPath' => 'test')
|
19
|
+
model.map[:path].should == 'test'
|
18
20
|
end
|
19
21
|
|
20
22
|
it 'should map ThumbnailPath' do
|
21
|
-
|
23
|
+
model.stub(:data).and_return('ThumbnailPath' => 'test')
|
24
|
+
model.map[:thumbnail_path].should == 'test'
|
22
25
|
end
|
23
26
|
|
24
27
|
it 'should map VignettePath' do
|
25
|
-
|
28
|
+
model.stub(:data).and_return('VignettePath' => 'test')
|
29
|
+
model.map[:vignette_path].should == 'test'
|
26
30
|
end
|
27
31
|
|
28
32
|
it 'should map BannerType' do
|
29
|
-
|
33
|
+
model.stub(:data).and_return('BannerType' => 'test')
|
34
|
+
model.map[:type].should == 'test'
|
30
35
|
end
|
31
36
|
|
32
37
|
it 'should map BannerType2' do
|
33
|
-
|
38
|
+
model.stub(:data).and_return('BannerType2' => 'test')
|
39
|
+
model.map[:type2].should == 'test'
|
34
40
|
end
|
35
41
|
|
36
42
|
it 'should map Language' do
|
37
|
-
|
43
|
+
model.stub(:data).and_return('Language' => 'test')
|
44
|
+
model.map[:language].should == 'test'
|
38
45
|
end
|
39
46
|
|
40
47
|
it 'should map Season' do
|
41
|
-
|
48
|
+
model.stub(:data).and_return('Season' => 'test')
|
49
|
+
model.map[:season].should == 'test'
|
42
50
|
end
|
43
51
|
|
44
52
|
it 'should map Rating' do
|
45
|
-
|
53
|
+
model.stub(:data).and_return('Rating' => 'test')
|
54
|
+
model.map[:rating].should == 'test'
|
46
55
|
end
|
47
56
|
|
48
57
|
it 'should map RatingCount' do
|
49
|
-
|
58
|
+
model.stub(:data).and_return('RatingCount' => 'test')
|
59
|
+
model.map[:rating_count].should == 'test'
|
50
60
|
end
|
51
61
|
|
52
62
|
it 'should map SeriesName' do
|
53
|
-
|
63
|
+
model.stub(:data).and_return('SeriesName' => 'test')
|
64
|
+
model.map[:series_name].should == 'test'
|
54
65
|
end
|
55
66
|
|
56
67
|
it 'should map Colors' do
|
57
|
-
|
68
|
+
model.stub(:data).and_return('Colors' => 'test')
|
69
|
+
model.map[:colors].should == 'test'
|
58
70
|
end
|
59
71
|
end
|
60
72
|
end
|
@@ -1,11 +1,11 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe ThetvdbMapper::Mapping::Episode do
|
4
|
-
let(:
|
4
|
+
let(:model) { ThetvdbMapper::Mapping::Episode.new({}) }
|
5
5
|
|
6
6
|
describe '#map' do
|
7
7
|
it 'should return specific keys' do
|
8
|
-
|
8
|
+
model.map.keys.sort.should == [:id, :combined_episode_number, :combined_season, :dvd_episode_number,
|
9
9
|
:dvd_season, :director, :ep_img_flag, :name, :number, :first_aired, :guest_stars, :imdb_id, :language,
|
10
10
|
:overview, :production_code, :rating, :rating_count, :season, :writer, :absolute_number, :airs_after_season,
|
11
11
|
:airs_before_episode, :airs_before_season, :filename_path, :last_updated_at, :season_id, :series_id,
|
@@ -13,123 +13,153 @@ describe ThetvdbMapper::Mapping::Episode do
|
|
13
13
|
end
|
14
14
|
|
15
15
|
it 'should map id' do
|
16
|
-
|
16
|
+
model.stub(:data).and_return('id' => 1234)
|
17
|
+
model.map[:id].should == 1234
|
17
18
|
end
|
18
19
|
|
19
20
|
it 'should map Combined_episodenumber' do
|
20
|
-
|
21
|
+
model.stub(:data).and_return('Combined_episodenumber' => 1234)
|
22
|
+
model.map[:combined_episode_number].should == 1234
|
21
23
|
end
|
22
24
|
|
23
25
|
it 'should map Combined_season' do
|
24
|
-
|
26
|
+
model.stub(:data).and_return('Combined_season' => 1234)
|
27
|
+
model.map[:combined_season].should == 1234
|
25
28
|
end
|
26
29
|
|
27
30
|
it 'should map DVD_episodenumber' do
|
28
|
-
|
31
|
+
model.stub(:data).and_return('DVD_episodenumber' => 1234)
|
32
|
+
model.map[:dvd_episode_number].should == 1234
|
29
33
|
end
|
30
34
|
|
31
35
|
it 'should map DVD_season' do
|
32
|
-
|
36
|
+
model.stub(:data).and_return('DVD_season' => 1234)
|
37
|
+
model.map[:dvd_season].should == 1234
|
33
38
|
end
|
34
39
|
|
35
40
|
it 'should map Director' do
|
36
|
-
|
41
|
+
model.stub(:data).and_return('Director' => '|test|')
|
42
|
+
model.map[:director].should == ['test']
|
37
43
|
end
|
38
44
|
|
39
45
|
it 'should map EpImgFlag' do
|
40
|
-
|
46
|
+
model.stub(:data).and_return('EpImgFlag' => 1234)
|
47
|
+
model.map[:ep_img_flag].should == 1234
|
41
48
|
end
|
42
49
|
|
43
50
|
it 'should map EpisodeName' do
|
44
|
-
|
51
|
+
model.stub(:data).and_return('EpisodeName' => 'test')
|
52
|
+
model.map[:name].should == 'test'
|
45
53
|
end
|
46
54
|
|
47
55
|
it 'should map EpisodeNumber' do
|
48
|
-
|
56
|
+
model.stub(:data).and_return('EpisodeNumber' => 1234)
|
57
|
+
model.map[:number].should == 1234
|
49
58
|
end
|
50
59
|
|
51
60
|
it 'should map FirstAired' do
|
52
|
-
|
61
|
+
model.stub(:data).and_return('FirstAired' => 1234)
|
62
|
+
model.map[:first_aired].should == 1234
|
53
63
|
end
|
54
64
|
|
55
65
|
it 'should map GuestStars' do
|
56
|
-
|
66
|
+
model.stub(:data).and_return('GuestStars' => '|test|')
|
67
|
+
model.map[:guest_stars].should == ['test']
|
57
68
|
end
|
58
69
|
|
59
70
|
it 'should map IMDB_ID' do
|
60
|
-
|
71
|
+
model.stub(:data).and_return('IMDB_ID' => 'test')
|
72
|
+
model.map[:imdb_id].should == 'test'
|
61
73
|
end
|
62
74
|
|
63
75
|
it 'should map Language' do
|
64
|
-
|
76
|
+
model.stub(:data).and_return('Language' => 'test')
|
77
|
+
model.map[:language].should == 'test'
|
65
78
|
end
|
66
79
|
|
67
80
|
it 'should map Overview' do
|
68
|
-
|
81
|
+
model.stub(:data).and_return('Overview' => 'test')
|
82
|
+
model.map[:overview].should == 'test'
|
69
83
|
end
|
70
84
|
|
71
85
|
it 'should map ProductionCode' do
|
72
|
-
|
86
|
+
model.stub(:data).and_return('ProductionCode' => 'test')
|
87
|
+
model.map[:production_code].should == 'test'
|
73
88
|
end
|
74
89
|
|
75
90
|
it 'should map Rating' do
|
76
|
-
|
91
|
+
model.stub(:data).and_return('Rating' => '1.0')
|
92
|
+
model.map[:rating].should == '1.0'
|
77
93
|
end
|
78
94
|
|
79
95
|
it 'should map RatingCount' do
|
80
|
-
|
96
|
+
model.stub(:data).and_return('RatingCount' => '1')
|
97
|
+
model.map[:rating_count].should == '1'
|
81
98
|
end
|
82
99
|
|
83
100
|
it 'should map SeasonNumber' do
|
84
|
-
|
101
|
+
model.stub(:data).and_return('SeasonNumber' => '1')
|
102
|
+
model.map[:season].should == '1'
|
85
103
|
end
|
86
104
|
|
87
105
|
it 'should map Writer' do
|
88
|
-
|
106
|
+
model.stub(:data).and_return('Writer' => '|test|')
|
107
|
+
model.map[:writer].should == ['test']
|
89
108
|
end
|
90
109
|
|
91
110
|
it 'should map absolute_number' do
|
92
|
-
|
111
|
+
model.stub(:data).and_return('absolute_number' => '1')
|
112
|
+
model.map[:absolute_number].should == '1'
|
93
113
|
end
|
94
114
|
|
95
115
|
it 'should map airsafter_season' do
|
96
|
-
|
116
|
+
model.stub(:data).and_return('airsafter_season' => '1')
|
117
|
+
model.map[:airs_after_season].should == '1'
|
97
118
|
end
|
98
119
|
|
99
120
|
it 'should map airsbefore_episode' do
|
100
|
-
|
121
|
+
model.stub(:data).and_return('airsbefore_episode' => '1')
|
122
|
+
model.map[:airs_before_episode].should == '1'
|
101
123
|
end
|
102
124
|
|
103
125
|
it 'should map airsbefore_season' do
|
104
|
-
|
126
|
+
model.stub(:data).and_return('airsbefore_season' => '1')
|
127
|
+
model.map[:airs_before_season].should == '1'
|
105
128
|
end
|
106
129
|
|
107
130
|
it 'should map filename' do
|
108
|
-
|
131
|
+
model.stub(:data).and_return('filename' => 'test')
|
132
|
+
model.map[:filename_path].should == 'test'
|
109
133
|
end
|
110
134
|
|
111
135
|
it 'should map lastupdated' do
|
112
|
-
|
136
|
+
model.stub(:data).and_return('lastupdated' => '1234')
|
137
|
+
model.map[:last_updated_at].should == Time.at(1234)
|
113
138
|
end
|
114
139
|
|
115
140
|
it 'should map seasonid' do
|
116
|
-
|
141
|
+
model.stub(:data).and_return('seasonid' => '1')
|
142
|
+
model.map[:season_id].should == '1'
|
117
143
|
end
|
118
144
|
|
119
145
|
it 'should map seriesid' do
|
120
|
-
|
146
|
+
model.stub(:data).and_return('seriesid' => '1')
|
147
|
+
model.map[:series_id].should == '1'
|
121
148
|
end
|
122
149
|
|
123
150
|
it 'should map thumb_added' do
|
124
|
-
|
151
|
+
model.stub(:data).and_return('thumb_added' => 'test')
|
152
|
+
model.map[:thumbnail_added_at].should == 'test'
|
125
153
|
end
|
126
154
|
|
127
155
|
it 'should map thumb_height' do
|
128
|
-
|
156
|
+
model.stub(:data).and_return('thumb_height' => 'test')
|
157
|
+
model.map[:thumbnail_height].should == 'test'
|
129
158
|
end
|
130
159
|
|
131
160
|
it 'should map thumb_width' do
|
132
|
-
|
161
|
+
model.stub(:data).and_return('thumb_width' => 'test')
|
162
|
+
model.map[:thumbnail_width].should == 'test'
|
133
163
|
end
|
134
164
|
end
|
135
165
|
end
|