thetvdb_mapper 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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
@@ -1,105 +1,128 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe ThetvdbMapper::Mapping::Series do
|
4
|
-
let(:
|
4
|
+
let(:model) { ThetvdbMapper::Mapping::Series.new({}) }
|
5
5
|
|
6
6
|
describe '#map' do
|
7
7
|
it 'should return specific keys' do
|
8
|
-
|
8
|
+
model.map.keys.sort.should == [:id, :airs_day_of_week, :airs_time, :content_rating, :first_aired, :genres,
|
9
9
|
:imdb_id, :language, :network, :network_id, :overview, :rating, :rating_count, :runtime, :name, :status,
|
10
10
|
:added_at, :added_by, :banner_path, :fanart_path, :last_updated_at, :poster_path, :zap2it_id].sort
|
11
11
|
end
|
12
12
|
|
13
13
|
it 'should map id' do
|
14
|
-
|
14
|
+
model.stub(:data).and_return('id' => 1234)
|
15
|
+
model.map[:id].should == 1234
|
15
16
|
end
|
16
17
|
|
17
18
|
it 'should map Airs_DayOfWeek' do
|
18
|
-
|
19
|
+
model.stub(:data).and_return('Airs_DayOfWeek' => 'Monday')
|
20
|
+
model.map[:airs_day_of_week].should == 'Monday'
|
19
21
|
end
|
20
22
|
|
21
23
|
it 'should map Airs_Time' do
|
22
|
-
|
24
|
+
model.stub(:data).and_return('Airs_Time' => '8:00 AM')
|
25
|
+
model.map[:airs_time].should == '8:00 AM'
|
23
26
|
end
|
24
27
|
|
25
28
|
it 'should map ContentRating' do
|
26
|
-
|
29
|
+
model.stub(:data).and_return('ContentRating' => 'TV-PG')
|
30
|
+
model.map[:content_rating].should == 'TV-PG'
|
27
31
|
end
|
28
32
|
|
29
33
|
it 'should map FirstAired' do
|
30
|
-
|
34
|
+
model.stub(:data).and_return('FirstAired' => '1997-07-01')
|
35
|
+
model.map[:first_aired].should == '1997-07-01'
|
31
36
|
end
|
32
37
|
|
33
38
|
it 'should map Genre' do
|
34
|
-
|
39
|
+
model.stub(:data).and_return('Genre' => '|comedy|')
|
40
|
+
model.map[:genres].should == ['comedy']
|
35
41
|
end
|
36
42
|
|
37
43
|
it 'should map IMDB_ID' do
|
38
|
-
|
44
|
+
model.stub(:data).and_return('IMDB_ID' => 'tt0118480')
|
45
|
+
model.map[:imdb_id].should == 'tt0118480'
|
39
46
|
end
|
40
47
|
|
41
48
|
it 'should map Language' do
|
42
|
-
|
49
|
+
model.stub(:data).and_return('Language' => 'en')
|
50
|
+
model.map[:language].should == 'en'
|
43
51
|
end
|
44
52
|
|
45
53
|
it 'should map Network' do
|
46
|
-
|
54
|
+
model.stub(:data).and_return('Network' => 'SciFi')
|
55
|
+
model.map[:network].should == 'SciFi'
|
47
56
|
end
|
48
57
|
|
49
58
|
it 'should map NetworkID' do
|
50
|
-
|
59
|
+
model.stub(:data).and_return('NetworkID' => '1')
|
60
|
+
model.map[:network_id].should == '1'
|
51
61
|
end
|
52
62
|
|
53
63
|
it 'should map Overview' do
|
54
|
-
|
64
|
+
model.stub(:data).and_return('Overview' => 'example overview')
|
65
|
+
model.map[:overview].should == 'example overview'
|
55
66
|
end
|
56
67
|
|
57
68
|
it 'should map Rating' do
|
58
|
-
|
69
|
+
model.stub(:data).and_return('Rating' => '1.0')
|
70
|
+
model.map[:rating].should == '1.0'
|
59
71
|
end
|
60
72
|
|
61
73
|
it 'should map RatingCount' do
|
62
|
-
|
74
|
+
model.stub(:data).and_return('RatingCount' => '1')
|
75
|
+
model.map[:rating_count].should == '1'
|
63
76
|
end
|
64
77
|
|
65
78
|
it 'should map Runtime' do
|
66
|
-
|
79
|
+
model.stub(:data).and_return('Runtime' => '45')
|
80
|
+
model.map[:runtime].should == '45'
|
67
81
|
end
|
68
82
|
|
69
83
|
it 'should map SeriesName' do
|
70
|
-
|
84
|
+
model.stub(:data).and_return('SeriesName' => 'Stargate SG-1')
|
85
|
+
model.map[:name].should == 'Stargate SG-1'
|
71
86
|
end
|
72
87
|
|
73
88
|
it 'should map Status' do
|
74
|
-
|
89
|
+
model.stub(:data).and_return('Status' => 'Ended')
|
90
|
+
model.map[:status].should == 'Ended'
|
75
91
|
end
|
76
92
|
|
77
93
|
it 'should map added' do
|
78
|
-
|
94
|
+
model.stub(:data).and_return('added' => '1')
|
95
|
+
model.map[:added_at].should == '1'
|
79
96
|
end
|
80
97
|
|
81
98
|
it 'should map addedBy' do
|
82
|
-
|
99
|
+
model.stub(:data).and_return('addedBy' => '1')
|
100
|
+
model.map[:added_by].should == '1'
|
83
101
|
end
|
84
102
|
|
85
103
|
it 'should map banner' do
|
86
|
-
|
104
|
+
model.stub(:data).and_return('banner' => 'PATH')
|
105
|
+
model.map[:banner_path].should == 'PATH'
|
87
106
|
end
|
88
107
|
|
89
108
|
it 'should map fanart' do
|
90
|
-
|
109
|
+
model.stub(:data).and_return('fanart' => 'PATH')
|
110
|
+
model.map[:fanart_path].should == 'PATH'
|
91
111
|
end
|
92
112
|
|
93
113
|
it 'should map lastupdated' do
|
94
|
-
|
114
|
+
model.stub(:data).and_return('lastupdated' => '1234')
|
115
|
+
model.map[:last_updated_at].should == Time.at(1234)
|
95
116
|
end
|
96
117
|
|
97
118
|
it 'should map poster' do
|
98
|
-
|
119
|
+
model.stub(:data).and_return('poster' => 'PATH')
|
120
|
+
model.map[:poster_path].should == 'PATH'
|
99
121
|
end
|
100
122
|
|
101
123
|
it 'should map zap2it_id' do
|
102
|
-
|
124
|
+
model.stub(:data).and_return('zap2it_id' => '1234')
|
125
|
+
model.map[:zap2it_id].should == '1234'
|
103
126
|
end
|
104
127
|
end
|
105
128
|
end
|
data/spec/units/actors_spec.rb
CHANGED
@@ -16,7 +16,8 @@ describe ThetvdbMapper::Actors do
|
|
16
16
|
|
17
17
|
describe '.map' do
|
18
18
|
it 'should call map on mapping class' do
|
19
|
-
|
19
|
+
model.stub(:mapping_object).with(sample: true).and_return(double(map: true))
|
20
|
+
model.mapping_object(sample: true).should_receive(:map)
|
20
21
|
model.map(sample: true)
|
21
22
|
end
|
22
23
|
end
|
@@ -30,4 +31,10 @@ describe ThetvdbMapper::Actors do
|
|
30
31
|
model.inspect.should == '<ThetvdbMapper::Actors data=DATA >'
|
31
32
|
end
|
32
33
|
end
|
34
|
+
|
35
|
+
describe '.mapping_object' do
|
36
|
+
it 'should return mapping actor instance' do
|
37
|
+
model.mapping_object(sample: true).class.should == ThetvdbMapper::Mapping::Actor
|
38
|
+
end
|
39
|
+
end
|
33
40
|
end
|
data/spec/units/banners_spec.rb
CHANGED
@@ -16,7 +16,8 @@ describe ThetvdbMapper::Banners do
|
|
16
16
|
|
17
17
|
describe '.map' do
|
18
18
|
it 'should call map on mapping class' do
|
19
|
-
|
19
|
+
model.stub(:mapping_object).with(sample: true).and_return(double(map: true))
|
20
|
+
model.mapping_object(sample: true).should_receive(:map)
|
20
21
|
model.map(sample: true)
|
21
22
|
end
|
22
23
|
end
|
@@ -30,4 +31,10 @@ describe ThetvdbMapper::Banners do
|
|
30
31
|
model.inspect.should == '<ThetvdbMapper::Banners data=DATA >'
|
31
32
|
end
|
32
33
|
end
|
34
|
+
|
35
|
+
describe '.mapping_object' do
|
36
|
+
it 'should return mapping banner instance' do
|
37
|
+
model.mapping_object(sample: true).class.should == ThetvdbMapper::Mapping::Banner
|
38
|
+
end
|
39
|
+
end
|
33
40
|
end
|
data/spec/units/episode_spec.rb
CHANGED
@@ -9,7 +9,8 @@ describe ThetvdbMapper::Episode do
|
|
9
9
|
end
|
10
10
|
|
11
11
|
it 'should call map on mapping class' do
|
12
|
-
|
12
|
+
model.stub(:mapping_object).and_return(double(map: true))
|
13
|
+
model.mapping_object(sample: true).should_receive(:map)
|
13
14
|
model.data
|
14
15
|
end
|
15
16
|
end
|
@@ -23,4 +24,10 @@ describe ThetvdbMapper::Episode do
|
|
23
24
|
model.inspect.should == '<ThetvdbMapper::Episode data=DATA >'
|
24
25
|
end
|
25
26
|
end
|
27
|
+
|
28
|
+
describe '.mapping_object' do
|
29
|
+
it 'should return mapping episode instance' do
|
30
|
+
model.mapping_object(sample: true).class.should == ThetvdbMapper::Mapping::Episode
|
31
|
+
end
|
32
|
+
end
|
26
33
|
end
|
@@ -38,7 +38,8 @@ describe ThetvdbMapper::FullSeries do
|
|
38
38
|
end
|
39
39
|
|
40
40
|
it 'should map series' do
|
41
|
-
|
41
|
+
model.stub(:mapping_series_object).and_return(double(map: true))
|
42
|
+
model.mapping_series_object(sample: true).should_receive(:map)
|
42
43
|
model.series
|
43
44
|
end
|
44
45
|
end
|
@@ -56,7 +57,8 @@ describe ThetvdbMapper::FullSeries do
|
|
56
57
|
|
57
58
|
describe '.map_episode' do
|
58
59
|
it 'should map episode' do
|
59
|
-
|
60
|
+
model.stub(:mapping_episode_object).and_return(double(map: true))
|
61
|
+
model.mapping_episode_object(sample: true).should_receive(:map)
|
60
62
|
model.map_episode(sample: true)
|
61
63
|
end
|
62
64
|
end
|
@@ -74,7 +76,8 @@ describe ThetvdbMapper::FullSeries do
|
|
74
76
|
|
75
77
|
describe '.map_actor' do
|
76
78
|
it 'should map actor' do
|
77
|
-
|
79
|
+
model.stub(:mapping_actor_object).and_return(double(map: true))
|
80
|
+
model.mapping_actor_object(sample: true).should_receive(:map)
|
78
81
|
model.map_actor(sample: true)
|
79
82
|
end
|
80
83
|
end
|
@@ -91,12 +94,40 @@ describe ThetvdbMapper::FullSeries do
|
|
91
94
|
end
|
92
95
|
|
93
96
|
describe '.map_banner' do
|
97
|
+
before do
|
98
|
+
model.stub(:mapping_banner_object).with(sample: true).and_return(double(map: true))
|
99
|
+
end
|
100
|
+
|
94
101
|
it 'should map banner' do
|
95
|
-
|
102
|
+
model.mapping_banner_object(sample: true).should_receive(:map)
|
96
103
|
model.map_banner(sample: true)
|
97
104
|
end
|
98
105
|
end
|
99
106
|
|
107
|
+
describe '.mapping_series_object' do
|
108
|
+
it 'should return mapping series instance' do
|
109
|
+
model.mapping_series_object(sample: true).class.should == ThetvdbMapper::Mapping::Series
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
describe '.mapping_episode_object' do
|
114
|
+
it 'should return mapping episode instance' do
|
115
|
+
model.mapping_episode_object(sample: true).class.should == ThetvdbMapper::Mapping::Episode
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
describe '.mapping_actor_object' do
|
120
|
+
it 'should return mapping actor instance' do
|
121
|
+
model.mapping_actor_object(sample: true).class.should == ThetvdbMapper::Mapping::Actor
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
describe '.mapping_banner_object' do
|
126
|
+
it 'should return mapping banner instance' do
|
127
|
+
model.mapping_banner_object(sample: true).class.should == ThetvdbMapper::Mapping::Banner
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
100
131
|
describe '.inspect' do
|
101
132
|
before do
|
102
133
|
model.stub(:data).and_return('DATA')
|
@@ -1,27 +1,27 @@
|
|
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
6
|
describe '#rules' do
|
7
7
|
it 'should map id' do
|
8
|
-
|
8
|
+
model.rules['id'].should == :id
|
9
9
|
end
|
10
10
|
|
11
11
|
it 'should map Image' do
|
12
|
-
|
12
|
+
model.rules['Image'].should == :image_path
|
13
13
|
end
|
14
14
|
|
15
15
|
it 'should map Name' do
|
16
|
-
|
16
|
+
model.rules['Name'].should == :name
|
17
17
|
end
|
18
18
|
|
19
19
|
it 'should map Role' do
|
20
|
-
|
20
|
+
model.rules['Role'].should == :role
|
21
21
|
end
|
22
22
|
|
23
23
|
it 'should map SortOrder' do
|
24
|
-
|
24
|
+
model.rules['SortOrder'].should == :sort_order
|
25
25
|
end
|
26
26
|
end
|
27
27
|
end
|
@@ -1,54 +1,54 @@
|
|
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 '#rules' do
|
7
7
|
it 'should map id' do
|
8
|
-
|
8
|
+
model.rules['id'].should == :id
|
9
9
|
end
|
10
10
|
it 'should map BannerPath' do
|
11
|
-
|
11
|
+
model.rules['BannerPath'].should == :path
|
12
12
|
end
|
13
13
|
|
14
14
|
it 'should map ThumbnailPath' do
|
15
|
-
|
15
|
+
model.rules['ThumbnailPath'].should == :thumbnail_path
|
16
16
|
end
|
17
17
|
|
18
18
|
it 'should map VignettePath' do
|
19
|
-
|
19
|
+
model.rules['VignettePath'].should == :vignette_path
|
20
20
|
end
|
21
21
|
|
22
22
|
it 'should map BannerType' do
|
23
|
-
|
23
|
+
model.rules['BannerType'].should == :type
|
24
24
|
end
|
25
25
|
|
26
26
|
it 'should map BannerType2' do
|
27
|
-
|
27
|
+
model.rules['BannerType2'].should == :type2
|
28
28
|
end
|
29
29
|
|
30
30
|
it 'should map Language' do
|
31
|
-
|
31
|
+
model.rules['Language'].should == :language
|
32
32
|
end
|
33
33
|
|
34
34
|
it 'should map Season' do
|
35
|
-
|
35
|
+
model.rules['Season'].should == :season
|
36
36
|
end
|
37
37
|
|
38
38
|
it 'should map Rating' do
|
39
|
-
|
39
|
+
model.rules['Rating'].should == :rating
|
40
40
|
end
|
41
41
|
|
42
42
|
it 'should map RatingCount' do
|
43
|
-
|
43
|
+
model.rules['RatingCount'].should == :rating_count
|
44
44
|
end
|
45
45
|
|
46
46
|
it 'should map SeriesName' do
|
47
|
-
|
47
|
+
model.rules['SeriesName'].should == :series_name
|
48
48
|
end
|
49
49
|
|
50
50
|
it 'should map Colors' do
|
51
|
-
|
51
|
+
model.rules['Colors'].should == :colors
|
52
52
|
end
|
53
53
|
end
|
54
54
|
end
|
@@ -2,28 +2,35 @@ class MappingExample < ThetvdbMapper::Mapping::Base
|
|
2
2
|
end
|
3
3
|
|
4
4
|
describe ThetvdbMapper::Mapping::Banner do
|
5
|
-
let(:
|
5
|
+
let(:model) { MappingExample.new(sample: 'test') }
|
6
6
|
|
7
|
-
describe '
|
7
|
+
describe '.map' do
|
8
8
|
before do
|
9
|
-
|
9
|
+
model.stub(:rules).and_return(sample: :example)
|
10
10
|
end
|
11
11
|
|
12
12
|
it 'should convert hash' do
|
13
|
-
|
13
|
+
model.map.should == { example: 'test' }
|
14
14
|
end
|
15
15
|
|
16
16
|
it 'should call convert method if exists' do
|
17
|
-
|
18
|
-
|
19
|
-
klass.map(sample: 'test')
|
17
|
+
model.should_receive(:convert).and_return(sample: true)
|
18
|
+
model.map
|
20
19
|
end
|
21
20
|
end
|
22
21
|
|
23
|
-
describe '
|
22
|
+
describe '.convert_to_list' do
|
24
23
|
it 'should return correct hash' do
|
25
|
-
|
26
|
-
|
24
|
+
model.stub(:list_mapping_object).with('test').and_return(double(map: true))
|
25
|
+
model.list_mapping_object('test').should_receive(:map)
|
26
|
+
model.convert_to_list('test')
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe '.list_mapping_object' do
|
31
|
+
it 'should return mapping instance' do
|
32
|
+
ThetvdbMapper::Mapping::StringList.should_receive(:new)
|
33
|
+
model.list_mapping_object('test')
|
27
34
|
end
|
28
35
|
end
|
29
36
|
end
|