addic7ed 0.3.2 → 0.3.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/lib/addic7ed/filename.rb +1 -1
- data/lib/addic7ed/version.rb +1 -1
- data/spec/addic7ed-common_spec.rb +9 -11
- data/spec/addic7ed-episode_spec.rb +47 -71
- data/spec/addic7ed-filename_spec.rb +206 -244
- data/spec/addic7ed-subtitle_spec.rb +57 -84
- data/spec/spec_helper.rb +3 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2a4ad6c04c80ef152956ca8fce65e52870f667b3
|
4
|
+
data.tar.gz: 32ba88504a9133fa6571e4f08531f8373555837f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 40604453835fcd8cf137d8960ee6068528b588de0b7a1ce878823b28eb0904cb411fa555afe674acadb0dbd28b9a4313ad434a2d37235500432f324e8084cc0f
|
7
|
+
data.tar.gz: 17e682fd98b9dc14aa45d68ac54667ec4240826fa7b0419971fdaaa2b8019c039567e7efb3246900835f90b26b791b02ed7c80f9c2168fe1b3713eb64d3320cf
|
data/lib/addic7ed/filename.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Addic7ed
|
2
2
|
class Filename
|
3
3
|
|
4
|
-
TVSHOW_REGEX = /\A(?<showname>.*\w)[\[\. ]+S?(?<season>\d{1,2})[-\. ]?[EX]?(?<episode>\d{2})[\]\. ]+(?<tags>.*)-(?<group>\w*)(\.\w{3})?\z/i
|
4
|
+
TVSHOW_REGEX = /\A(?<showname>.*\w)[\[\. ]+S?(?<season>\d{1,2})[-\. ]?[EX]?(?<episode>\d{2})([-\. ]?[EX]?\d{2})*[\]\. ]+(?<tags>.*)-(?<group>\w*)(\.\w{3})?\z/i
|
5
5
|
|
6
6
|
attr_reader :filename, :showname, :season, :episode, :tags, :group
|
7
7
|
|
data/lib/addic7ed/version.rb
CHANGED
@@ -2,22 +2,20 @@ require 'spec_helper'
|
|
2
2
|
require './lib/addic7ed'
|
3
3
|
|
4
4
|
describe Addic7ed do
|
5
|
-
|
6
|
-
|
7
|
-
Addic7ed::SHOWS_URL.should_not be_nil
|
5
|
+
it 'defines SHOWS_URL' do
|
6
|
+
expect(Addic7ed::SHOWS_URL).to_not be_nil
|
8
7
|
end
|
9
8
|
|
10
|
-
it '
|
11
|
-
Addic7ed::EPISODES_URL.
|
9
|
+
it 'defines EPISODES_URL' do
|
10
|
+
expect(Addic7ed::EPISODES_URL).to_not be_nil
|
12
11
|
end
|
13
12
|
|
14
|
-
it '
|
15
|
-
Addic7ed::EPISODE_REDIRECT_URL.
|
13
|
+
it 'defines EPISODE_REDIRECT_URL' do
|
14
|
+
expect(Addic7ed::EPISODE_REDIRECT_URL).to_not be_nil
|
16
15
|
end
|
17
16
|
|
18
|
-
it '
|
19
|
-
Addic7ed::LANGUAGES.
|
20
|
-
Addic7ed::LANGUAGES
|
17
|
+
it 'defines LANGUAGES' do
|
18
|
+
expect(Addic7ed::LANGUAGES).to_not be_nil
|
19
|
+
expect(Addic7ed::LANGUAGES).to include 'fr' => {name: 'French', id: 8}
|
21
20
|
end
|
22
|
-
|
23
21
|
end
|
@@ -2,7 +2,6 @@ require 'spec_helper'
|
|
2
2
|
require './lib/addic7ed'
|
3
3
|
|
4
4
|
describe Addic7ed::Episode do
|
5
|
-
|
6
5
|
before :all do
|
7
6
|
@filename = 'The.Walking.Dead.S03E02.720p.HDTV.x264-EVOLVE.mkv'
|
8
7
|
@filename_show_not_found = 'Show.Not.Found.S03E02.720p.HDTV.x264-EVOLVE.mkv'
|
@@ -12,110 +11,89 @@ describe Addic7ed::Episode do
|
|
12
11
|
end
|
13
12
|
|
14
13
|
it 'should create valid instance given valid argument' do
|
15
|
-
expect{
|
16
|
-
@episode = Addic7ed::Episode.new(@filename)
|
17
|
-
}.to_not raise_error
|
14
|
+
expect{ Addic7ed::Episode.new(@filename) }.to_not raise_error
|
18
15
|
end
|
19
16
|
|
20
17
|
describe '#url' do
|
21
|
-
|
22
|
-
|
23
|
-
@episode.url('
|
24
|
-
@episode.url('es').should == 'http://www.addic7ed.com/serie/The_Walking_Dead/3/2/4'
|
18
|
+
it 'returns a show localized URL given existing episode' do
|
19
|
+
expect(@episode.url('fr')).to eq 'http://www.addic7ed.com/serie/The_Walking_Dead/3/2/8'
|
20
|
+
expect(@episode.url('es')).to eq 'http://www.addic7ed.com/serie/The_Walking_Dead/3/2/4'
|
25
21
|
end
|
26
22
|
|
27
|
-
it '
|
28
|
-
@episode.url.
|
23
|
+
it 'uses French as default language' do
|
24
|
+
expect(@episode.url).to eq @episode.url('fr')
|
29
25
|
end
|
30
26
|
|
31
|
-
it '
|
32
|
-
expect{
|
33
|
-
@episode.url('aa')
|
34
|
-
}.to raise_error(Addic7ed::LanguageNotSupported)
|
27
|
+
it 'raises LanguageNotSupported given an unsupported language code' do
|
28
|
+
expect{ @episode.url('aa') }.to raise_error Addic7ed::LanguageNotSupported
|
35
29
|
end
|
36
|
-
|
37
30
|
end
|
38
31
|
|
39
32
|
describe '#subtitles' do
|
40
|
-
|
41
33
|
it 'should return an array of Addic7ed::Subtitle given valid episode and language' do
|
42
|
-
|
34
|
+
%w{fr en it}.each do |lang|
|
43
35
|
lang_id = Addic7ed::LANGUAGES[lang][:id]
|
44
36
|
stub_request(:get, "http://www.addic7ed.com/serie/The_Walking_Dead/3/2/#{lang_id}")
|
45
37
|
.to_return File.new("spec/responses/walking-dead-3-2-#{lang_id}.http")
|
46
38
|
end
|
47
|
-
@episode.subtitles('fr').size.
|
48
|
-
@episode.subtitles('en').size.
|
49
|
-
@episode.subtitles('it').size.
|
39
|
+
expect(@episode.subtitles('fr').size).to eq 4
|
40
|
+
expect(@episode.subtitles('en').size).to eq 3
|
41
|
+
expect(@episode.subtitles('it').size).to eq 1
|
50
42
|
end
|
51
43
|
|
52
|
-
it '
|
53
|
-
@episode.subtitles.
|
44
|
+
it 'uses French as default language' do
|
45
|
+
expect(@episode.subtitles).to eq @episode.subtitles('fr')
|
54
46
|
end
|
55
47
|
|
56
|
-
it '
|
57
|
-
expect{
|
58
|
-
@episode.subtitles('aa')
|
59
|
-
}.to raise_error(Addic7ed::LanguageNotSupported)
|
48
|
+
it 'raises LanguageNotSupported given an unsupported language code' do
|
49
|
+
expect{ @episode.subtitles('aa') }.to raise_error Addic7ed::LanguageNotSupported
|
60
50
|
end
|
61
51
|
|
62
|
-
it '
|
52
|
+
it 'raises EpisodeNotFound given not existing episode' do
|
63
53
|
stub_request(:get, 'http://www.addic7ed.com/serie/The_Walking_Dead/3/42/8')
|
64
54
|
.to_return File.new('spec/responses/walking-dead-3-42-8.http')
|
65
|
-
expect{
|
66
|
-
Addic7ed::Episode.new(@filename_episode_not_found).subtitles
|
67
|
-
}.to raise_error(Addic7ed::EpisodeNotFound)
|
55
|
+
expect{ Addic7ed::Episode.new(@filename_episode_not_found).subtitles }.to raise_error Addic7ed::EpisodeNotFound
|
68
56
|
end
|
69
57
|
|
70
|
-
it '
|
58
|
+
it 'raises NoSubtitleFound given valid episode which has no subtitle on Addic7ed' do
|
71
59
|
stub_request(:get, 'http://www.addic7ed.com/serie/The_Walking_Dead/3/2/48')
|
72
60
|
.to_return File.new('spec/responses/walking-dead-3-2-48.http')
|
73
|
-
expect{
|
74
|
-
@episode.subtitles('az')
|
75
|
-
}.to raise_error(Addic7ed::NoSubtitleFound)
|
61
|
+
expect{ @episode.subtitles('az') }.to raise_error Addic7ed::NoSubtitleFound
|
76
62
|
end
|
77
63
|
|
78
|
-
it 'may raise a ParsingError, but I
|
79
|
-
|
64
|
+
it 'may raise a ParsingError, but I\'m not sure how...'
|
80
65
|
end
|
81
66
|
|
82
67
|
describe '#best_subtitle' do
|
83
|
-
|
84
|
-
it 'should find the subtitle with status completed and same group name' do
|
68
|
+
it 'finds the subtitle with status completed and same group name' do
|
85
69
|
stub_request(:get, 'http://www.addic7ed.com/serie/The_Walking_Dead/3/2/8')
|
86
70
|
.to_return File.new('spec/responses/walking-dead-3-2-8.http')
|
87
|
-
@episode.best_subtitle('fr').url.
|
71
|
+
expect(@episode.best_subtitle('fr').url).to eq 'http://www.addic7ed.com/original/68018/4'
|
88
72
|
end
|
89
73
|
|
90
|
-
it '
|
74
|
+
it 'finds the subtitle with status completed, compatible group name and as many downloads as possible' do
|
91
75
|
stub_request(:get, 'http://www.addic7ed.com/serie/The_Walking_Dead/3/4/8')
|
92
76
|
.to_return File.new('spec/responses/walking-dead-3-4-8.http')
|
93
77
|
compatible_episode = Addic7ed::Episode.new(@filename_compatible_group)
|
94
|
-
compatible_episode.best_subtitle('fr').url.
|
78
|
+
expect(compatible_episode.best_subtitle('fr').url).to eq 'http://www.addic7ed.com/updated/8/68508/3'
|
95
79
|
end
|
96
80
|
|
97
|
-
it '
|
98
|
-
@episode.best_subtitle.
|
81
|
+
it 'uses French as default language' do
|
82
|
+
expect(@episode.best_subtitle).to eq @episode.best_subtitle('fr')
|
99
83
|
end
|
100
84
|
|
101
|
-
it '
|
102
|
-
expect{
|
103
|
-
@episode.best_subtitle('aa')
|
104
|
-
}.to raise_error(Addic7ed::LanguageNotSupported)
|
85
|
+
it 'raises LanguageNotSupported given an unsupported language code' do
|
86
|
+
expect{ @episode.best_subtitle('aa') }.to raise_error Addic7ed::LanguageNotSupported
|
105
87
|
end
|
106
88
|
|
107
|
-
it '
|
89
|
+
it 'raises NoSubtitleFound given valid episode which has no subtitle on Addic7ed' do
|
108
90
|
stub_request(:get, 'http://www.addic7ed.com/serie/The_Walking_Dead/3/2/48')
|
109
91
|
.to_return File.new('spec/responses/walking-dead-3-2-48.http')
|
110
|
-
expect{
|
111
|
-
@episode.best_subtitle('az')
|
112
|
-
}.to raise_error(Addic7ed::NoSubtitleFound)
|
92
|
+
expect{ @episode.best_subtitle('az') }.to raise_error Addic7ed::NoSubtitleFound
|
113
93
|
end
|
114
|
-
|
115
94
|
end
|
116
95
|
|
117
96
|
describe '#download_best_subtitle!' do
|
118
|
-
|
119
97
|
before :each do
|
120
98
|
WebMock.reset!
|
121
99
|
@page_stub = stub_request(:get, 'http://www.addic7ed.com/serie/The_Walking_Dead/3/2/8')
|
@@ -125,46 +103,44 @@ describe Addic7ed::Episode do
|
|
125
103
|
# The Episode object must be re-created between every test, since redirection may modify its URI
|
126
104
|
@reset_episode = Addic7ed::Episode.new(@filename)
|
127
105
|
# Prevent actual disk writing
|
128
|
-
Kernel.
|
106
|
+
allow(Kernel).to receive(:open)
|
129
107
|
end
|
130
108
|
|
131
|
-
it '
|
132
|
-
|
109
|
+
it 'gets the best subtitle candidate with a network request' do
|
110
|
+
expect(@reset_episode).to receive(:best_subtitle).once.and_call_original
|
133
111
|
@reset_episode.download_best_subtitle!('fr')
|
134
|
-
@page_stub.
|
135
|
-
@sub_stub.
|
112
|
+
expect(@page_stub).to have_been_requested
|
113
|
+
expect(@sub_stub).to have_been_requested
|
136
114
|
end
|
137
115
|
|
138
|
-
it '
|
116
|
+
it 'raises DownloadError when a network error happens' do
|
139
117
|
stub_request(:get, 'http://www.addic7ed.com/original/68018/4').to_timeout
|
140
118
|
expect{ @reset_episode.download_best_subtitle!('fr') }.to raise_error Addic7ed::DownloadError
|
141
119
|
end
|
142
120
|
|
143
|
-
it '
|
121
|
+
it 'is called recursively' do
|
144
122
|
stub_request(:get, 'http://www.addic7ed.com/original/68018/4').to_return File.new('spec/responses/basic_redirection.http')
|
145
123
|
stub_request(:get, 'http://www.addic7ed.com/original/68018/4.redirected').to_return File.new('spec/responses/walking-dead-3-2-8_best_subtitle.http')
|
146
|
-
|
124
|
+
expect(@reset_episode).to receive(:download_best_subtitle!).twice.and_call_original
|
147
125
|
@reset_episode.download_best_subtitle!('fr')
|
148
126
|
end
|
149
127
|
|
150
|
-
it '
|
128
|
+
it 'raises HTTPError when stuck in a HTTP redirections loop' do
|
151
129
|
stub_request(:get, 'http://www.addic7ed.com/original/68018/4')
|
152
130
|
.to_return File.new('spec/responses/redirection_loop.http')
|
153
|
-
expect{ @reset_episode.download_best_subtitle!('fr') }.to raise_error
|
131
|
+
expect{ @reset_episode.download_best_subtitle!('fr') }.to raise_error Addic7ed::HTTPError
|
154
132
|
end
|
155
133
|
|
156
|
-
it '
|
134
|
+
it 'creates a new file on disk' do
|
157
135
|
file = double('file')
|
158
|
-
Kernel.
|
159
|
-
file.
|
136
|
+
expect(Kernel).to receive(:open).with('The.Walking.Dead.S03E02.720p.HDTV.x264-EVOLVE.srt', 'w').and_yield(file)
|
137
|
+
expect(file).to receive(:<<)
|
160
138
|
@reset_episode.download_best_subtitle!('fr')
|
161
139
|
end
|
162
140
|
|
163
|
-
it '
|
164
|
-
Kernel.
|
141
|
+
it 'raises SubtitleCannotBeSaved when a disk error happens' do
|
142
|
+
expect(Kernel).to receive(:open).with('The.Walking.Dead.S03E02.720p.HDTV.x264-EVOLVE.srt', 'w').and_raise('Persmission denied')
|
165
143
|
expect{ @reset_episode.download_best_subtitle!('fr') }.to raise_error Addic7ed::SubtitleCannotBeSaved
|
166
144
|
end
|
167
|
-
|
168
145
|
end
|
169
|
-
|
170
|
-
end
|
146
|
+
end
|
@@ -2,7 +2,6 @@ require 'spec_helper'
|
|
2
2
|
require './lib/addic7ed'
|
3
3
|
|
4
4
|
describe Addic7ed::Filename do
|
5
|
-
|
6
5
|
before :all do
|
7
6
|
# Valid filenames
|
8
7
|
@filename = 'Californication.S06E07.720p.HDTV.x264-2HD.mkv'
|
@@ -23,6 +22,8 @@ describe Addic7ed::Filename do
|
|
23
22
|
@filename_full_path = '/data/public/Series/Californication/Saison 06/Californication.S06E07.720p.HDTV.x264-2HD.mkv'
|
24
23
|
@filename_relative_path = '../Saison 06/Californication.S06E07.720p.HDTV.x264-2HD.mkv'
|
25
24
|
@filename_no_extension = 'Californication.S06E07.720p.HDTV.x264-2HD'
|
25
|
+
@filename_double_episode = 'Revenge.S02E21E22.720p.HDTV.X264-DIMENSION.mkv'
|
26
|
+
@filename_double_episode_with_dash = 'Revenge.S02E21-22.720p.HDTV.X264-DIMENSION.mkv'
|
26
27
|
# Invalid filenames
|
27
28
|
@filename_no_showname = '.S06E07.720p.HDTV.x264-2HD.mkv'
|
28
29
|
@filename_no_season = 'Californication.E07.720p.HDTV.x264-2HD.mkv'
|
@@ -39,309 +40,270 @@ describe Addic7ed::Filename do
|
|
39
40
|
@filename_showname_year_US = 'The.Hour.2011.US.S01E03.REPACK.HDTV.XviD-FoV.avi'
|
40
41
|
end
|
41
42
|
|
42
|
-
|
43
|
-
|
44
|
-
@file = Addic7ed::Filename.new(@filename)
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
end
|
43
|
+
describe '#initialize' do
|
44
|
+
it 'succeeds given valid argument' do
|
45
|
+
expect{ @file = Addic7ed::Filename.new(@filename) }.to_not raise_error
|
46
|
+
expect(@file.showname).to eq 'Californication'
|
47
|
+
expect(@file.season ).to eq 6
|
48
|
+
expect(@file.episode ).to eq 7
|
49
|
+
expect(@file.tags ).to eq ['720P', 'HDTV', 'X264']
|
50
|
+
expect(@file.group ).to eq '2HD'
|
51
|
+
end
|
52
52
|
|
53
|
-
|
54
|
-
|
55
|
-
@file
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
@file.group.should == '2HD'
|
62
|
-
end
|
53
|
+
it 'succeeds given filename with x notation' do
|
54
|
+
expect{ @file = Addic7ed::Filename.new(@filename_x) }.to_not raise_error
|
55
|
+
expect(@file.showname).to eq 'Californication'
|
56
|
+
expect(@file.season ).to eq 6
|
57
|
+
expect(@file.episode ).to eq 7
|
58
|
+
expect(@file.tags ).to eq ['720P', 'HDTV', 'X264']
|
59
|
+
expect(@file.group ).to eq '2HD'
|
60
|
+
end
|
63
61
|
|
64
|
-
|
65
|
-
|
66
|
-
@file
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
@file.group.should == '2HD'
|
73
|
-
end
|
62
|
+
it 'succeeds given filename with 3-digits notation' do
|
63
|
+
expect{ @file = Addic7ed::Filename.new(@filename_3digits) }.to_not raise_error
|
64
|
+
expect(@file.showname).to eq 'Californication'
|
65
|
+
expect(@file.season ).to eq 6
|
66
|
+
expect(@file.episode ).to eq 7
|
67
|
+
expect(@file.tags ).to eq ['720P', 'HDTV', 'X264']
|
68
|
+
expect(@file.group ).to eq '2HD'
|
69
|
+
end
|
74
70
|
|
75
|
-
|
76
|
-
|
77
|
-
@file
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
@file.group.should == '2HD'
|
84
|
-
end
|
71
|
+
it 'succeeds given filename with brackets notation' do
|
72
|
+
expect{ @file = Addic7ed::Filename.new(@filename_brackets) }.to_not raise_error
|
73
|
+
expect(@file.showname).to eq 'Californication'
|
74
|
+
expect(@file.season ).to eq 6
|
75
|
+
expect(@file.episode ).to eq 7
|
76
|
+
expect(@file.tags ).to eq ['720P', 'HDTV', 'X264']
|
77
|
+
expect(@file.group ).to eq '2HD'
|
78
|
+
end
|
85
79
|
|
86
|
-
|
87
|
-
|
88
|
-
@file
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
@file.group.should == '2HD'
|
95
|
-
end
|
80
|
+
it 'succeeds given filename with brackets and x notation' do
|
81
|
+
expect{ @file = Addic7ed::Filename.new(@filename_x_brackets) }.to_not raise_error
|
82
|
+
expect(@file.showname).to eq 'Californication'
|
83
|
+
expect(@file.season ).to eq 6
|
84
|
+
expect(@file.episode ).to eq 7
|
85
|
+
expect(@file.tags ).to eq ['720P', 'HDTV', 'X264']
|
86
|
+
expect(@file.group ).to eq '2HD'
|
87
|
+
end
|
96
88
|
|
97
|
-
|
98
|
-
|
99
|
-
@file
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
@file.group.should == '2HD'
|
106
|
-
end
|
89
|
+
it 'succeeds given filename with brackets and 3-digits notation' do
|
90
|
+
expect{ @file = Addic7ed::Filename.new(@filename_3digits_brackets) }.to_not raise_error
|
91
|
+
expect(@file.showname).to eq 'Californication'
|
92
|
+
expect(@file.season ).to eq 6
|
93
|
+
expect(@file.episode ).to eq 7
|
94
|
+
expect(@file.tags ).to eq ['720P', 'HDTV', 'X264']
|
95
|
+
expect(@file.group ).to eq '2HD'
|
96
|
+
end
|
107
97
|
|
108
|
-
|
109
|
-
|
110
|
-
@file
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
@file.group.should == '2HD'
|
117
|
-
end
|
98
|
+
it 'succeeds given filename with brackets notation and space separator' do
|
99
|
+
expect{ @file = Addic7ed::Filename.new(@filename_brackets_spaces) }.to_not raise_error
|
100
|
+
expect(@file.showname).to eq 'Californication'
|
101
|
+
expect(@file.season ).to eq 6
|
102
|
+
expect(@file.episode ).to eq 7
|
103
|
+
expect(@file.tags ).to eq ['720P', 'HDTV', 'X264']
|
104
|
+
expect(@file.group ).to eq '2HD'
|
105
|
+
end
|
118
106
|
|
119
|
-
|
120
|
-
|
121
|
-
@file
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
@file.group.should == '2HD'
|
128
|
-
end
|
107
|
+
it 'succeeds given filename with brackets and x notation and space separator' do
|
108
|
+
expect{ @file = Addic7ed::Filename.new(@filename_x_brackets_spaces) }.to_not raise_error
|
109
|
+
expect(@file.showname).to eq 'Californication'
|
110
|
+
expect(@file.season ).to eq 6
|
111
|
+
expect(@file.episode ).to eq 7
|
112
|
+
expect(@file.tags ).to eq ['720P', 'HDTV', 'X264']
|
113
|
+
expect(@file.group ).to eq '2HD'
|
114
|
+
end
|
129
115
|
|
130
|
-
|
131
|
-
|
132
|
-
@file
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
@file.group.should == '2HD'
|
139
|
-
end
|
116
|
+
it 'succeeds given filename with brackets and 3-digits notation and space separator' do
|
117
|
+
expect{ @file = Addic7ed::Filename.new(@filename_3digits_brackets_spaces) }.to_not raise_error
|
118
|
+
expect(@file.showname).to eq 'Californication'
|
119
|
+
expect(@file.season ).to eq 6
|
120
|
+
expect(@file.episode ).to eq 7
|
121
|
+
expect(@file.tags ).to eq ['720P', 'HDTV', 'X264']
|
122
|
+
expect(@file.group ).to eq '2HD'
|
123
|
+
end
|
140
124
|
|
141
|
-
|
142
|
-
|
143
|
-
@file
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
@file.group.should == '2HD'
|
150
|
-
end
|
125
|
+
it 'succeeds given lowercase filename' do
|
126
|
+
expect{ @file = Addic7ed::Filename.new(@filename_lowercase) }.to_not raise_error
|
127
|
+
expect(@file.showname).to eq 'californication'
|
128
|
+
expect(@file.season ).to eq 6
|
129
|
+
expect(@file.episode ).to eq 7
|
130
|
+
expect(@file.tags ).to eq ['720P', 'HDTV', 'X264']
|
131
|
+
expect(@file.group ).to eq '2HD'
|
132
|
+
end
|
151
133
|
|
152
|
-
|
153
|
-
|
154
|
-
@file
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
@file.group.should == '2HD'
|
161
|
-
end
|
134
|
+
it 'succeeds given lowercase filename with x notation' do
|
135
|
+
expect{ @file = Addic7ed::Filename.new(@filename_lowercase_x) }.to_not raise_error
|
136
|
+
expect(@file.showname).to eq 'californication'
|
137
|
+
expect(@file.season ).to eq 6
|
138
|
+
expect(@file.episode ).to eq 7
|
139
|
+
expect(@file.tags ).to eq ['720P', 'HDTV', 'X264']
|
140
|
+
expect(@file.group ).to eq '2HD'
|
141
|
+
end
|
162
142
|
|
163
|
-
|
164
|
-
|
165
|
-
@file
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
@file.group.should == 'EVOLVE'
|
172
|
-
end
|
143
|
+
it 'succeeds given filename with showname containing multiple words' do
|
144
|
+
expect{ @file = Addic7ed::Filename.new(@filename_multiple_words) }.to_not raise_error
|
145
|
+
expect(@file.showname).to eq 'The Walking Dead'
|
146
|
+
expect(@file.season ).to eq 3
|
147
|
+
expect(@file.episode ).to eq 11
|
148
|
+
expect(@file.tags ).to eq ['720P', 'HDTV', 'X264']
|
149
|
+
expect(@file.group ).to eq 'EVOLVE'
|
150
|
+
end
|
173
151
|
|
174
|
-
|
175
|
-
|
176
|
-
@file
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
@file.group.should == 'EVOLVE'
|
183
|
-
end
|
152
|
+
it 'succeeds given filename with showname containing multiple words with space separator' do
|
153
|
+
expect{ @file = Addic7ed::Filename.new(@filename_multiple_words_spaces) }.to_not raise_error
|
154
|
+
expect(@file.showname).to eq 'The Walking Dead'
|
155
|
+
expect(@file.season ).to eq 3
|
156
|
+
expect(@file.episode ).to eq 11
|
157
|
+
expect(@file.tags ).to eq ['720P', 'HDTV', 'X264']
|
158
|
+
expect(@file.group ).to eq 'EVOLVE'
|
159
|
+
end
|
184
160
|
|
185
|
-
|
186
|
-
|
187
|
-
@file
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
@file.group.should == 'DIMENSION'
|
194
|
-
end
|
161
|
+
it 'succeeds given filename with showname containing only numbers' do
|
162
|
+
expect{ @file = Addic7ed::Filename.new(@filename_numbers_only) }.to_not raise_error
|
163
|
+
expect(@file.showname).to eq '90210'
|
164
|
+
expect(@file.season ).to eq 5
|
165
|
+
expect(@file.episode ).to eq 12
|
166
|
+
expect(@file.tags ).to eq ['720P', 'HDTV', 'X264']
|
167
|
+
expect(@file.group ).to eq 'DIMENSION'
|
168
|
+
end
|
195
169
|
|
196
|
-
|
197
|
-
|
198
|
-
@file
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
@file.group.should == 'DIMENSION'
|
205
|
-
end
|
170
|
+
it 'succeeds given filename with showname containing production year' do
|
171
|
+
expect{ @file = Addic7ed::Filename.new(@filename_showname_year) }.to_not raise_error
|
172
|
+
expect(@file.showname).to eq 'The Americans 2013'
|
173
|
+
expect(@file.season ).to eq 1
|
174
|
+
expect(@file.episode ).to eq 4
|
175
|
+
expect(@file.tags ).to eq ['720P', 'HDTV', 'X264']
|
176
|
+
expect(@file.group ).to eq 'DIMENSION'
|
177
|
+
end
|
206
178
|
|
207
|
-
|
208
|
-
|
209
|
-
@file
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
@file.group.should == '2HD'
|
216
|
-
end
|
179
|
+
it 'succeeds given filename containing full path' do
|
180
|
+
expect{ @file = Addic7ed::Filename.new(@filename_full_path) }.to_not raise_error
|
181
|
+
expect(@file.showname).to eq 'Californication'
|
182
|
+
expect(@file.season ).to eq 6
|
183
|
+
expect(@file.episode ).to eq 7
|
184
|
+
expect(@file.tags ).to eq ['720P', 'HDTV', 'X264']
|
185
|
+
expect(@file.group ).to eq '2HD'
|
186
|
+
end
|
217
187
|
|
218
|
-
|
219
|
-
|
220
|
-
@file
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
@file.group.should == '2HD'
|
227
|
-
end
|
188
|
+
it 'succeeds given filename containing relative path' do
|
189
|
+
expect{ @file = Addic7ed::Filename.new(@filename_relative_path) }.to_not raise_error
|
190
|
+
expect(@file.showname).to eq 'Californication'
|
191
|
+
expect(@file.season ).to eq 6
|
192
|
+
expect(@file.episode ).to eq 7
|
193
|
+
expect(@file.tags ).to eq ['720P', 'HDTV', 'X264']
|
194
|
+
expect(@file.group ).to eq '2HD'
|
195
|
+
end
|
228
196
|
|
229
|
-
|
230
|
-
|
231
|
-
@file
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
@file.group.should == '2HD'
|
238
|
-
end
|
197
|
+
it 'succeeds given filename containing no extension' do
|
198
|
+
expect{ @file = Addic7ed::Filename.new(@filename_no_extension) }.to_not raise_error
|
199
|
+
expect(@file.showname).to eq 'Californication'
|
200
|
+
expect(@file.season ).to eq 6
|
201
|
+
expect(@file.episode ).to eq 7
|
202
|
+
expect(@file.tags ).to eq ['720P', 'HDTV', 'X264']
|
203
|
+
expect(@file.group ).to eq '2HD'
|
204
|
+
end
|
239
205
|
|
240
|
-
|
241
|
-
|
242
|
-
@file
|
243
|
-
|
244
|
-
|
206
|
+
it 'succeeds given filename which is a double episode' do
|
207
|
+
expect{ @file = Addic7ed::Filename.new(@filename_double_episode) }.to_not raise_error
|
208
|
+
expect(@file.showname).to eq 'Revenge'
|
209
|
+
expect(@file.season ).to eq 2
|
210
|
+
expect(@file.episode ).to eq 21
|
211
|
+
expect(@file.tags ).to eq ['720P', 'HDTV', 'X264']
|
212
|
+
expect(@file.group ).to eq 'DIMENSION'
|
213
|
+
end
|
245
214
|
|
246
|
-
|
247
|
-
|
248
|
-
@file
|
249
|
-
|
250
|
-
|
215
|
+
it 'succeeds given filename which is a double episode (with a dash)' do
|
216
|
+
expect{ @file = Addic7ed::Filename.new(@filename_double_episode_with_dash) }.to_not raise_error
|
217
|
+
expect(@file.showname).to eq 'Revenge'
|
218
|
+
expect(@file.season ).to eq 2
|
219
|
+
expect(@file.episode ).to eq 21
|
220
|
+
expect(@file.tags ).to eq ['720P', 'HDTV', 'X264']
|
221
|
+
expect(@file.group ).to eq 'DIMENSION'
|
222
|
+
end
|
251
223
|
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
}.to raise_error(Addic7ed::InvalidFilename)
|
256
|
-
end
|
224
|
+
it 'fails given filename with no showname' do
|
225
|
+
expect{ Addic7ed::Filename.new(@filename_no_showname) }.to raise_error Addic7ed::InvalidFilename
|
226
|
+
end
|
257
227
|
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
}.to raise_error(Addic7ed::InvalidFilename)
|
262
|
-
end
|
228
|
+
it 'fails given filename with no season number' do
|
229
|
+
expect{ Addic7ed::Filename.new(@filename_no_season) }.to raise_error Addic7ed::InvalidFilename
|
230
|
+
end
|
263
231
|
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
}.to raise_error(Addic7ed::InvalidFilename)
|
268
|
-
end
|
232
|
+
it 'raises InvalidFilename given filename with no episode number' do
|
233
|
+
expect{ Addic7ed::Filename.new(@filename_no_episode) }.to raise_error Addic7ed::InvalidFilename
|
234
|
+
end
|
269
235
|
|
270
|
-
|
236
|
+
it 'raises InvalidFilename given filename with no tags' do
|
237
|
+
expect{ Addic7ed::Filename.new(@filename_no_tags) }.to raise_error Addic7ed::InvalidFilename
|
238
|
+
end
|
271
239
|
|
272
|
-
it '
|
273
|
-
Addic7ed::Filename.new(@
|
240
|
+
it 'raises InvalidFilename given filename with no group' do
|
241
|
+
expect{ Addic7ed::Filename.new(@filename_no_group) }.to raise_error Addic7ed::InvalidFilename
|
274
242
|
end
|
243
|
+
end
|
275
244
|
|
276
|
-
|
277
|
-
|
245
|
+
describe '#encoded_filename' do
|
246
|
+
it 'changes all spaces to underscores' do
|
247
|
+
expect(Addic7ed::Filename.new(@filename_multiple_words).encoded_showname).to eq 'The_Walking_Dead'
|
278
248
|
end
|
279
249
|
|
280
|
-
it '
|
281
|
-
Addic7ed::Filename.new(@
|
250
|
+
it 'wraps country code with parenthesis' do
|
251
|
+
expect(Addic7ed::Filename.new(@filename_showname_US).encoded_showname).to eq 'Shameless_(US)'
|
282
252
|
end
|
283
253
|
|
284
|
-
it '
|
285
|
-
Addic7ed::Filename.new(@
|
254
|
+
it 'detects country code even in lowercase' do
|
255
|
+
expect(Addic7ed::Filename.new(@filename_showname_US_lowercase).encoded_showname).to eq 'shameless_(us)'
|
286
256
|
end
|
287
257
|
|
288
|
-
it '
|
289
|
-
Addic7ed::Filename.new(@
|
258
|
+
it 'removes country code for the original show (usually UK)' do
|
259
|
+
expect(Addic7ed::Filename.new(@filename_showname_UK).encoded_showname).to eq 'Shameless'
|
290
260
|
end
|
291
261
|
|
292
|
-
it '
|
293
|
-
Addic7ed::Filename.new(@
|
294
|
-
Addic7ed::Filename.new(@filename_showname_year_UK).encoded_showname.should == 'The_Hour'
|
295
|
-
Addic7ed::Filename.new(@filename_showname_US_year).encoded_showname.should == 'The_Hour_(US)'
|
296
|
-
Addic7ed::Filename.new(@filename_showname_year_US).encoded_showname.should == 'The_Hour_(US)'
|
262
|
+
it 'removes production year' do
|
263
|
+
expect(Addic7ed::Filename.new(@filename_showname_year).encoded_showname).to eq 'The_Americans'
|
297
264
|
end
|
298
265
|
|
266
|
+
it 'handles when both country code and production year are present' do
|
267
|
+
expect(Addic7ed::Filename.new(@filename_showname_UK_year).encoded_showname).to eq 'The_Hour'
|
268
|
+
expect(Addic7ed::Filename.new(@filename_showname_year_UK).encoded_showname).to eq 'The_Hour'
|
269
|
+
expect(Addic7ed::Filename.new(@filename_showname_US_year).encoded_showname).to eq 'The_Hour_(US)'
|
270
|
+
expect(Addic7ed::Filename.new(@filename_showname_year_US).encoded_showname).to eq 'The_Hour_(US)'
|
271
|
+
end
|
299
272
|
end
|
300
273
|
|
301
274
|
describe '#basename' do
|
302
|
-
|
303
|
-
|
304
|
-
Addic7ed::Filename.new(@filename_full_path).basename.should == 'Californication.S06E07.720p.HDTV.x264-2HD.mkv'
|
275
|
+
it 'returns only file name given a full path' do
|
276
|
+
expect(Addic7ed::Filename.new(@filename_full_path).basename).to eq 'Californication.S06E07.720p.HDTV.x264-2HD.mkv'
|
305
277
|
end
|
306
|
-
|
307
278
|
end
|
308
279
|
|
309
280
|
describe '#dirname' do
|
310
|
-
|
311
|
-
|
312
|
-
Addic7ed::Filename.new(@filename_full_path).dirname.should == '/data/public/Series/Californication/Saison 06'
|
281
|
+
it 'returns only path given a full path' do
|
282
|
+
expect(Addic7ed::Filename.new(@filename_full_path).dirname).to eq '/data/public/Series/Californication/Saison 06'
|
313
283
|
end
|
314
|
-
|
315
284
|
end
|
316
285
|
|
317
286
|
describe '#extname' do
|
318
|
-
|
319
|
-
|
320
|
-
Addic7ed::Filename.new(@filename_full_path).extname.should == '.mkv'
|
287
|
+
it 'returns only file extension given a full path' do
|
288
|
+
expect(Addic7ed::Filename.new(@filename_full_path).extname).to eq '.mkv'
|
321
289
|
end
|
322
|
-
|
323
290
|
end
|
324
291
|
|
325
292
|
describe '#to_s' do
|
326
|
-
|
327
|
-
|
328
|
-
Addic7ed::Filename.new(@filename_full_path).to_s.should == '/data/public/Series/Californication/Saison 06/Californication.S06E07.720p.HDTV.x264-2HD.mkv'
|
293
|
+
it 'returns file name as a string' do
|
294
|
+
expect(Addic7ed::Filename.new(@filename_full_path).to_s).to eq '/data/public/Series/Californication/Saison 06/Californication.S06E07.720p.HDTV.x264-2HD.mkv'
|
329
295
|
end
|
330
|
-
|
331
296
|
end
|
332
297
|
|
333
298
|
describe '#inspect' do
|
334
|
-
|
335
|
-
|
336
|
-
Addic7ed::Filename.new(@filename).inspect.should ==
|
299
|
+
it 'prints a human-readable detailed version' do
|
300
|
+
expect(Addic7ed::Filename.new(@filename).inspect).to eq(
|
337
301
|
'Guesses for Californication.S06E07.720p.HDTV.x264-2HD.mkv:
|
338
302
|
show: Californication
|
339
303
|
season: 6
|
340
304
|
episode: 7
|
341
305
|
tags: ["720P", "HDTV", "X264"]
|
342
|
-
group: 2HD'
|
306
|
+
group: 2HD')
|
343
307
|
end
|
344
|
-
|
345
308
|
end
|
346
|
-
|
347
309
|
end
|
@@ -2,174 +2,147 @@ require 'spec_helper'
|
|
2
2
|
require './lib/addic7ed'
|
3
3
|
|
4
4
|
describe Addic7ed::Subtitle do
|
5
|
-
|
6
5
|
describe '#normalized_version' do
|
7
|
-
|
8
|
-
|
9
|
-
Addic7ed::Subtitle.new('DiMENSiON', '', '', '', '', '0').version.should == 'DIMENSION'
|
6
|
+
it 'upcases the version string' do
|
7
|
+
expect(Addic7ed::Subtitle.new('DiMENSiON', '', '', '', '', '0').version).to eq 'DIMENSION'
|
10
8
|
end
|
11
9
|
|
12
|
-
it '
|
13
|
-
Addic7ed::Subtitle.new('.DIMENSION', '', '', '', '', '0').version.
|
14
|
-
Addic7ed::Subtitle.new('DIMENSION.', '', '', '', '', '0').version.
|
15
|
-
Addic7ed::Subtitle.new('.DIMENSION.', '', '', '', '', '0').version.
|
10
|
+
it 'removes heading and trailing dots' do
|
11
|
+
expect(Addic7ed::Subtitle.new('.DIMENSION', '', '', '', '', '0').version).to eq 'DIMENSION'
|
12
|
+
expect(Addic7ed::Subtitle.new('DIMENSION.', '', '', '', '', '0').version).to eq 'DIMENSION'
|
13
|
+
expect(Addic7ed::Subtitle.new('.DIMENSION.', '', '', '', '', '0').version).to eq 'DIMENSION'
|
16
14
|
end
|
17
15
|
|
18
|
-
it '
|
19
|
-
Addic7ed::Subtitle.new(' DIMENSION', '', '', '', '', '0').version.
|
20
|
-
Addic7ed::Subtitle.new('DIMENSION ', '', '', '', '', '0').version.
|
21
|
-
Addic7ed::Subtitle.new(' DIMENSION ', '', '', '', '', '0').version.
|
16
|
+
it 'removes heading and trailing whitespaces' do
|
17
|
+
expect(Addic7ed::Subtitle.new(' DIMENSION', '', '', '', '', '0').version).to eq 'DIMENSION'
|
18
|
+
expect(Addic7ed::Subtitle.new('DIMENSION ', '', '', '', '', '0').version).to eq 'DIMENSION'
|
19
|
+
expect(Addic7ed::Subtitle.new(' DIMENSION ', '', '', '', '', '0').version).to eq 'DIMENSION'
|
22
20
|
end
|
23
21
|
|
24
|
-
it '
|
25
|
-
Addic7ed::Subtitle.new('-DIMENSION', '', '', '', '', '0').version.
|
26
|
-
Addic7ed::Subtitle.new('DIMENSION-', '', '', '', '', '0').version.
|
27
|
-
Addic7ed::Subtitle.new('-DIMENSION-', '', '', '', '', '0').version.
|
22
|
+
it 'removes heading and trailing dashes' do
|
23
|
+
expect(Addic7ed::Subtitle.new('-DIMENSION', '', '', '', '', '0').version).to eq 'DIMENSION'
|
24
|
+
expect(Addic7ed::Subtitle.new('DIMENSION-', '', '', '', '', '0').version).to eq 'DIMENSION'
|
25
|
+
expect(Addic7ed::Subtitle.new('-DIMENSION-', '', '', '', '', '0').version).to eq 'DIMENSION'
|
28
26
|
end
|
29
27
|
|
30
|
-
it '
|
31
|
-
Addic7ed::Subtitle.new('720p DIMENSION', '', '', '', '', '0').version.
|
32
|
-
Addic7ed::Subtitle.new('720P DIMENSION', '', '', '', '', '0').version.
|
33
|
-
Addic7ed::Subtitle.new('DIMENSION 720p', '', '', '', '', '0').version.
|
34
|
-
Addic7ed::Subtitle.new('DIMENSION 720P', '', '', '', '', '0').version.
|
28
|
+
it 'automatically removes "720p" in version string' do
|
29
|
+
expect(Addic7ed::Subtitle.new('720p DIMENSION', '', '', '', '', '0').version).to eq 'DIMENSION'
|
30
|
+
expect(Addic7ed::Subtitle.new('720P DIMENSION', '', '', '', '', '0').version).to eq 'DIMENSION'
|
31
|
+
expect(Addic7ed::Subtitle.new('DIMENSION 720p', '', '', '', '', '0').version).to eq 'DIMENSION'
|
32
|
+
expect(Addic7ed::Subtitle.new('DIMENSION 720P', '', '', '', '', '0').version).to eq 'DIMENSION'
|
35
33
|
end
|
36
34
|
|
37
|
-
it '
|
38
|
-
Addic7ed::Subtitle.new('hdtv DIMENSION', '', '', '', '', '0').version.
|
39
|
-
Addic7ed::Subtitle.new('HDTV DIMENSION', '', '', '', '', '0').version.
|
40
|
-
Addic7ed::Subtitle.new('DIMENSION hdtv', '', '', '', '', '0').version.
|
41
|
-
Addic7ed::Subtitle.new('DIMENSION HDTV', '', '', '', '', '0').version.
|
35
|
+
it 'automatically removes "HDTV" in version string' do
|
36
|
+
expect(Addic7ed::Subtitle.new('hdtv DIMENSION', '', '', '', '', '0').version).to eq 'DIMENSION'
|
37
|
+
expect(Addic7ed::Subtitle.new('HDTV DIMENSION', '', '', '', '', '0').version).to eq 'DIMENSION'
|
38
|
+
expect(Addic7ed::Subtitle.new('DIMENSION hdtv', '', '', '', '', '0').version).to eq 'DIMENSION'
|
39
|
+
expect(Addic7ed::Subtitle.new('DIMENSION HDTV', '', '', '', '', '0').version).to eq 'DIMENSION'
|
42
40
|
end
|
43
41
|
|
44
|
-
it '
|
45
|
-
Addic7ed::Subtitle.new('x264 DIMENSION', '', '', '', '', '0').version.
|
46
|
-
Addic7ed::Subtitle.new('X264 DIMENSION', '', '', '', '', '0').version.
|
47
|
-
Addic7ed::Subtitle.new('x.264 DIMENSION', '', '', '', '', '0').version.
|
48
|
-
Addic7ed::Subtitle.new('X.264 DIMENSION', '', '', '', '', '0').version.
|
49
|
-
Addic7ed::Subtitle.new('DIMENSION x264', '', '', '', '', '0').version.
|
50
|
-
Addic7ed::Subtitle.new('DIMENSION X264', '', '', '', '', '0').version.
|
51
|
-
Addic7ed::Subtitle.new('DIMENSION x.264', '', '', '', '', '0').version.
|
52
|
-
Addic7ed::Subtitle.new('DIMENSION X.264', '', '', '', '', '0').version.
|
42
|
+
it 'automatically removes "x264" in version string' do
|
43
|
+
expect(Addic7ed::Subtitle.new('x264 DIMENSION', '', '', '', '', '0').version).to eq 'DIMENSION'
|
44
|
+
expect(Addic7ed::Subtitle.new('X264 DIMENSION', '', '', '', '', '0').version).to eq 'DIMENSION'
|
45
|
+
expect(Addic7ed::Subtitle.new('x.264 DIMENSION', '', '', '', '', '0').version).to eq 'DIMENSION'
|
46
|
+
expect(Addic7ed::Subtitle.new('X.264 DIMENSION', '', '', '', '', '0').version).to eq 'DIMENSION'
|
47
|
+
expect(Addic7ed::Subtitle.new('DIMENSION x264', '', '', '', '', '0').version).to eq 'DIMENSION'
|
48
|
+
expect(Addic7ed::Subtitle.new('DIMENSION X264', '', '', '', '', '0').version).to eq 'DIMENSION'
|
49
|
+
expect(Addic7ed::Subtitle.new('DIMENSION x.264', '', '', '', '', '0').version).to eq 'DIMENSION'
|
50
|
+
expect(Addic7ed::Subtitle.new('DIMENSION X.264', '', '', '', '', '0').version).to eq 'DIMENSION'
|
53
51
|
end
|
54
52
|
|
55
|
-
it '
|
56
|
-
Addic7ed::Subtitle.new('PROPER DIMENSION', '', '', '', '', '0').version.
|
57
|
-
Addic7ed::Subtitle.new('Proper DIMENSION', '', '', '', '', '0').version.
|
58
|
-
Addic7ed::Subtitle.new('DIMENSION PROPER', '', '', '', '', '0').version.
|
59
|
-
Addic7ed::Subtitle.new('DIMENSION Proper', '', '', '', '', '0').version.
|
53
|
+
it 'automatically removes "PROPER" in version string' do
|
54
|
+
expect(Addic7ed::Subtitle.new('PROPER DIMENSION', '', '', '', '', '0').version).to eq 'DIMENSION'
|
55
|
+
expect(Addic7ed::Subtitle.new('Proper DIMENSION', '', '', '', '', '0').version).to eq 'DIMENSION'
|
56
|
+
expect(Addic7ed::Subtitle.new('DIMENSION PROPER', '', '', '', '', '0').version).to eq 'DIMENSION'
|
57
|
+
expect(Addic7ed::Subtitle.new('DIMENSION Proper', '', '', '', '', '0').version).to eq 'DIMENSION'
|
60
58
|
end
|
61
59
|
|
62
|
-
it '
|
63
|
-
Addic7ed::Subtitle.new('Version DIMENSION', '', '', '', '', '0').version.
|
60
|
+
it 'automatically removes "Version" prefix in version string' do
|
61
|
+
expect(Addic7ed::Subtitle.new('Version DIMENSION', '', '', '', '', '0').version).to eq 'DIMENSION'
|
64
62
|
end
|
65
|
-
|
66
63
|
end
|
67
64
|
|
68
65
|
describe '#to_s' do
|
69
|
-
|
70
|
-
it 'should print a human readable version' do
|
66
|
+
it 'prints a human readable version' do
|
71
67
|
sub = Addic7ed::Subtitle.new('DIMENSION', 'fr', 'Completed', 'http://some.fancy.url', 'http://addic7ed.com', '42')
|
72
|
-
expect(sub.to_s).to
|
68
|
+
expect(sub.to_s).to eq "http://some.fancy.url\t->\tDIMENSION (fr, Completed) [42 downloads] (via http://addic7ed.com)"
|
73
69
|
end
|
74
|
-
|
75
70
|
end
|
76
71
|
|
77
72
|
describe '#works_for?' do
|
78
|
-
|
79
73
|
context 'when incomplete' do
|
74
|
+
before(:all) { @sub = Addic7ed::Subtitle.new('', '', '80%', '', '', '10') }
|
80
75
|
|
81
|
-
|
82
|
-
@sub = Addic7ed::Subtitle.new('', '', '80%', '', '', '10')
|
83
|
-
end
|
84
|
-
|
85
|
-
it 'should return false' do
|
76
|
+
it 'returns false' do
|
86
77
|
expect(@sub.works_for?).to be false
|
87
78
|
end
|
88
|
-
|
89
79
|
end
|
90
80
|
|
91
81
|
context 'when completed' do
|
82
|
+
before(:all) { @sub = Addic7ed::Subtitle.new('DIMENSION', '', 'Completed', '', '', '10') }
|
92
83
|
|
93
|
-
|
94
|
-
@sub = Addic7ed::Subtitle.new('DIMENSION', '', 'Completed', '', '', '10')
|
95
|
-
end
|
96
|
-
|
97
|
-
it 'should return true given the exact same version' do
|
84
|
+
it 'returns true given the exact same version' do
|
98
85
|
expect(@sub.works_for? 'DIMENSION').to be true
|
99
86
|
end
|
100
87
|
|
101
|
-
it '
|
88
|
+
it 'returns true given a compatible version' do
|
102
89
|
expect(@sub.works_for? 'LOL').to be true
|
103
90
|
end
|
104
91
|
|
105
|
-
it '
|
92
|
+
it 'returns true when the subtitle is for a PROPER version' do
|
106
93
|
sub = Addic7ed::Subtitle.new('PROPER DIMENSION', '', 'Completed', '', '', '10')
|
107
94
|
expect(sub.works_for? 'DIMENSION').to be true
|
108
95
|
expect(sub.works_for? 'LOL').to be true
|
109
96
|
end
|
110
97
|
|
111
|
-
it '
|
98
|
+
it 'returns false given an incompatible version' do
|
112
99
|
expect(@sub.works_for? 'EVOLVE').to be false
|
113
100
|
end
|
114
|
-
|
115
101
|
end
|
116
|
-
|
117
102
|
end
|
118
103
|
|
119
|
-
|
120
104
|
describe '#can_replace?' do
|
121
|
-
|
122
105
|
context 'when incomplete' do
|
123
|
-
|
124
|
-
it 'should return false' do
|
106
|
+
it 'returns false' do
|
125
107
|
sub = Addic7ed::Subtitle.new('', '', '80%', '', '', '10')
|
126
108
|
any_other_sub = Addic7ed::Subtitle.new('', '', '', '', '', '0')
|
127
109
|
expect(sub.can_replace? any_other_sub).to be false
|
128
110
|
end
|
129
|
-
|
130
111
|
end
|
131
112
|
|
132
113
|
context 'when completed' do
|
114
|
+
before(:all) { @sub = Addic7ed::Subtitle.new('DIMENSION', 'fr', 'Completed', '', '', '10') }
|
133
115
|
|
134
|
-
|
135
|
-
@sub = Addic7ed::Subtitle.new('DIMENSION', 'fr', 'Completed', '', '', '10')
|
136
|
-
end
|
137
|
-
|
138
|
-
it 'should return true given no other_sub' do
|
116
|
+
it 'returns true given no other_sub' do
|
139
117
|
expect(@sub.can_replace? nil).to be true
|
140
118
|
end
|
141
119
|
|
142
|
-
it '
|
120
|
+
it 'returns false given other_sub for another language' do
|
143
121
|
other_sub = Addic7ed::Subtitle.new('DIMENSION', 'en', 'Completed', '', '', '10')
|
144
122
|
expect(@sub.can_replace? other_sub).to be false
|
145
123
|
end
|
146
124
|
|
147
|
-
it '
|
125
|
+
it 'returns false given other_sub for incompatible version' do
|
148
126
|
other_sub = Addic7ed::Subtitle.new('EVOLVE', 'fr', 'Completed', '', '', '10')
|
149
127
|
expect(@sub.can_replace? other_sub).to be false
|
150
128
|
end
|
151
129
|
|
152
130
|
context 'given other_sub language & version compatible' do
|
153
|
-
|
154
|
-
it 'should return false given other_sub featured by Addic7ed' do
|
131
|
+
it 'returns false given other_sub featured by Addic7ed' do
|
155
132
|
other_sub = Addic7ed::Subtitle.new('DIMENSION', 'fr', 'Completed', '', 'http://addic7ed.com', '10')
|
156
133
|
expect(@sub.can_replace? other_sub).to be false
|
157
134
|
end
|
158
135
|
|
159
|
-
it '
|
136
|
+
it 'returns false given other_sub with more downloads' do
|
160
137
|
other_sub = Addic7ed::Subtitle.new('DIMENSION', 'fr', 'Completed', '', '', '20')
|
161
138
|
expect(@sub.can_replace? other_sub).to be false
|
162
139
|
end
|
163
140
|
|
164
|
-
it '
|
141
|
+
it 'returns true given other_sub with less downloads' do
|
165
142
|
other_sub = Addic7ed::Subtitle.new('DIMENSION', 'fr', 'Completed', '', '', '5')
|
166
143
|
expect(@sub.can_replace? other_sub).to be true
|
167
144
|
end
|
168
|
-
|
169
145
|
end
|
170
|
-
|
171
146
|
end
|
172
|
-
|
173
147
|
end
|
174
|
-
|
175
148
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -8,11 +8,13 @@ WebMock.disable_net_connect!(allow_localhost: true)
|
|
8
8
|
|
9
9
|
RSpec.configure do |config|
|
10
10
|
# Use color in STDOUT
|
11
|
-
config.
|
11
|
+
config.color = true
|
12
12
|
|
13
13
|
# Use color not only in STDOUT but also in pagers and files
|
14
14
|
config.tty = true
|
15
15
|
|
16
16
|
# Use the specified formatter
|
17
17
|
config.formatter = :documentation # :progress, :html, :textmate
|
18
|
+
|
19
|
+
config.raise_errors_for_deprecations!
|
18
20
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: addic7ed
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Baudino
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-08-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -117,7 +117,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
117
117
|
version: '0'
|
118
118
|
requirements: []
|
119
119
|
rubyforge_project:
|
120
|
-
rubygems_version: 2.2.
|
120
|
+
rubygems_version: 2.2.2
|
121
121
|
signing_key:
|
122
122
|
specification_version: 4
|
123
123
|
summary: Addic7ed auto-downloader
|