subtitle_it 1.9.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +5 -0
- data/Gemfile +3 -0
- data/{README.rdoc → README.md} +22 -18
- data/Rakefile +13 -18
- data/bin/subtitle_it +4 -8
- data/lib/subtitle_it/bin.rb +50 -58
- data/lib/subtitle_it/fixes.rb +3 -4
- data/lib/subtitle_it/formats/ass.rb +5 -6
- data/lib/subtitle_it/formats/mpl.rb +9 -9
- data/lib/subtitle_it/formats/rsb.rb +9 -9
- data/lib/subtitle_it/formats/srt.rb +17 -14
- data/lib/subtitle_it/formats/sub.rb +7 -7
- data/lib/subtitle_it/formats/xml.rb +13 -12
- data/lib/subtitle_it/formats/yml.rb +5 -5
- data/lib/subtitle_it/generator.rb +2 -2
- data/lib/subtitle_it/languages.rb +52 -53
- data/lib/subtitle_it/movie.rb +26 -6
- data/lib/subtitle_it/platform_endl.rb +7 -5
- data/lib/subtitle_it/subdown.rb +30 -33
- data/lib/subtitle_it/subline.rb +5 -5
- data/lib/subtitle_it/substyle.rb +3 -9
- data/lib/subtitle_it/subtime.rb +19 -10
- data/lib/subtitle_it/subtitle.rb +20 -28
- data/lib/subtitle_it/version.rb +1 -7
- data/lib/subtitle_it.rb +7 -7
- data/spec/fixtures/movie.xml +2 -2
- data/spec/spec_helper.rb +6 -6
- data/spec/subtitle_it/bin_spec.rb +110 -98
- data/spec/subtitle_it/formats/ass_spec.rb +2 -3
- data/spec/subtitle_it/formats/mpl_spec.rb +26 -28
- data/spec/subtitle_it/formats/rsb_spec.rb +29 -30
- data/spec/subtitle_it/formats/srt_spec.rb +27 -30
- data/spec/subtitle_it/formats/sub_spec.rb +19 -21
- data/spec/subtitle_it/formats/xml_spec.rb +21 -21
- data/spec/subtitle_it/formats/yml_spec.rb +14 -15
- data/spec/subtitle_it/movie_spec.rb +24 -15
- data/spec/subtitle_it/subdown_spec.rb +58 -65
- data/spec/subtitle_it/subline_spec.rb +17 -18
- data/spec/subtitle_it/subtime_spec.rb +43 -44
- data/spec/subtitle_it/subtitle_spec.rb +28 -29
- data/spec/subtitle_it_spec.rb +4 -5
- data/subtitle_it.gemspec +25 -98
- metadata +121 -67
- data/.rspec +0 -2
- data/config/hoe.rb +0 -73
- data/config/requirements.rb +0 -15
- data/lib/subtitle_it/movie_hasher.rb +0 -30
- data/script/console +0 -10
- data/script/destroy +0 -14
- data/script/generate +0 -14
- data/script/txt2html +0 -82
- data/spec/subtitle_it/movie_hasher_spec.rb +0 -13
- data/tasks/deployment.rake +0 -34
- data/tasks/environment.rake +0 -7
- data/tasks/rspec.rake +0 -21
@@ -1,142 +1,154 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
2
|
|
3
3
|
module BinspecHelper
|
4
|
-
def mock_xmlrpc(stubs={})
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
def mock_xmlrpc(stubs = {})
|
5
|
+
@mock_xmlrpc ||= double(XMLRPC::Client, stubs)
|
6
|
+
end
|
7
|
+
|
8
|
+
def mock_subdown
|
9
|
+
@mock_subdown = double(Subdown)
|
10
|
+
end
|
11
|
+
|
12
|
+
def mock_file
|
13
|
+
@mock_file = double(File)
|
14
|
+
end
|
15
|
+
|
8
16
|
def mock_movie
|
9
|
-
@mock_movie =
|
10
|
-
|
17
|
+
@mock_movie = double(Movie, filename: 'Beavis Butthead Do America.avi',
|
18
|
+
haxx: '09a2c497663259cb')
|
11
19
|
end
|
12
|
-
|
20
|
+
|
13
21
|
def mock_subtitle
|
14
|
-
@mock_subtitle =
|
15
|
-
:info => sub_info, :format => 'srt', :<=> => 1
|
16
|
-
})
|
22
|
+
@mock_subtitle = double(Subtitle, :info => sub_info, :format => 'srt', :<=> => 1)
|
17
23
|
end
|
18
|
-
|
24
|
+
|
19
25
|
def sub_info
|
20
|
-
{
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
26
|
+
{
|
27
|
+
'SubLanguageID' => 'eng',
|
28
|
+
'LanguageName' => 'English',
|
29
|
+
'MovieName' => 'Resevoir Dogs',
|
30
|
+
'MovieYear' => '1992',
|
31
|
+
'SubFileName' => 'Cool sub',
|
32
|
+
'MovieFPS' => '29.0',
|
33
|
+
'MovieImdbRating' => '10.0',
|
34
|
+
'SubAddDate' => '12-12-2012 00:01:01',
|
35
|
+
'SubDownloadsCnt' => '310',
|
36
|
+
'SubRating' => '9.5',
|
37
|
+
'SubFormat' => 'srt',
|
38
|
+
'SubSumCD' => '2',
|
39
|
+
'SubAuthorComment' => 'Nice nice...'
|
40
|
+
}
|
32
41
|
end
|
33
42
|
end
|
34
43
|
|
35
44
|
describe Bin do
|
36
45
|
include BinspecHelper
|
37
|
-
|
38
|
-
it
|
39
|
-
|
46
|
+
|
47
|
+
it 'should require ARGV' do
|
48
|
+
expect { Bin.run!(nil) }.to raise_error
|
40
49
|
end
|
41
|
-
|
50
|
+
|
42
51
|
# Having a hard time testing the command line tool...
|
43
52
|
# #
|
44
|
-
#
|
53
|
+
#
|
45
54
|
# it "should call for movie" do
|
46
55
|
# Subdownloader.should_receive(:new)
|
47
|
-
# File.should_receive(:
|
56
|
+
# File.should_receive(:exist?).and_return(true)
|
48
57
|
# File.should_receive(:open).and_return(mock_file)
|
49
58
|
# SubtitleIt::Bin::run!(["movie.avi"])
|
50
59
|
# end
|
51
|
-
#
|
60
|
+
#
|
52
61
|
# it "should call for subtitle" do
|
53
62
|
# @subwork_mock = mock(Subwork, :run! => true)#.should_receive(:new)
|
54
63
|
# @subwork_mock.should_receive(:new)
|
55
64
|
# @subwork_mock.should_receive(:run!)
|
56
|
-
# File.should_receive(:
|
65
|
+
# File.should_receive(:exist?).and_return(true)
|
57
66
|
# SubtitleIt::Bin::run!(["movie.srt"])
|
58
|
-
# end
|
67
|
+
# end
|
59
68
|
end
|
60
|
-
|
61
|
-
describe Subdownloader do
|
69
|
+
|
70
|
+
describe Subdownloader do
|
62
71
|
include BinspecHelper
|
63
|
-
|
64
|
-
it
|
65
|
-
STDOUT.
|
66
|
-
SubtitleIt::Bin.print_languages
|
72
|
+
|
73
|
+
it 'should print languages' do
|
74
|
+
expect(STDOUT).to receive(:puts).at_least(30).times
|
75
|
+
SubtitleIt::Bin.print_languages
|
67
76
|
end
|
68
77
|
|
69
|
-
it
|
70
|
-
Movie.
|
71
|
-
Subdown.
|
72
|
-
|
73
|
-
STDIN.
|
74
|
-
STDOUT.
|
75
|
-
STDOUT.
|
76
|
-
STDOUT.
|
77
|
-
STDOUT.
|
78
|
-
STDOUT.
|
79
|
-
STDOUT.
|
80
|
-
STDOUT.
|
81
|
-
|
82
|
-
File.
|
83
|
-
|
84
|
-
@mock_subdown.
|
85
|
-
@mock_subdown.
|
86
|
-
@mock_subdown.
|
87
|
-
@mock_subdown.
|
88
|
-
|
89
|
-
Subdownloader.new.run!
|
78
|
+
it 'should download a subtitle' do
|
79
|
+
expect(Movie).to receive(:new).and_return(mock_movie)
|
80
|
+
expect(Subdown).to receive(:new).and_return(mock_subdown)
|
81
|
+
|
82
|
+
expect(STDIN).to receive(:gets).and_return('1')
|
83
|
+
expect(STDOUT).to receive(:puts).with(/You can choose multiple ones/)
|
84
|
+
expect(STDOUT).to receive(:puts).with("Found #{'2'.yellow} results:\n")
|
85
|
+
expect(STDOUT).to receive(:print).with(/Choose/)
|
86
|
+
expect(STDOUT).to receive(:puts).with(" #{'1'.yellow}. #{'Eng'.green} | #{'SRT'.blue} | #{'Resevoir Dogs'.cyan} / #{'1992'.cyan} | #{'9.5'.yellow} | FPS 29.0 | 2 CDs | 2012-12-12")
|
87
|
+
expect(STDOUT).to receive(:puts).with(" #{'2'.yellow}. #{'Eng'.green} | #{'SRT'.blue} | #{'Resevoir Dogs'.cyan} / #{'1992'.cyan} | #{'9.5'.yellow} | FPS 29.0 | 2 CDs | 2012-12-12")
|
88
|
+
expect(STDOUT).to receive(:puts).with('Downloading 1 subtitle...')
|
89
|
+
expect(STDOUT).to receive(:puts).with('Done: Beavis Butthead Do America.eng.srt'.yellow)
|
90
|
+
|
91
|
+
expect(File).to receive(:open).with('Beavis Butthead Do America.eng.srt', 'w').and_return(true)
|
92
|
+
|
93
|
+
expect(@mock_subdown).to receive(:log_in!).and_return(true)
|
94
|
+
expect(@mock_subdown).to receive(:download_subtitle).and_return(mock_subtitle)
|
95
|
+
expect(@mock_subdown).to receive(:search_subtitles).and_return([mock_subtitle, mock_subtitle])
|
96
|
+
expect(@mock_subdown).to receive(:log_out!).and_return(true)
|
97
|
+
|
98
|
+
Subdownloader.new.run! 'file.avi'
|
90
99
|
end
|
91
|
-
|
92
|
-
it
|
93
|
-
|
94
|
-
|
100
|
+
|
101
|
+
# it 'should download and convert a subtitle' do
|
102
|
+
# expect(Subtitle).to receive(:new).and_return(mock_subtitle)
|
103
|
+
# end
|
104
|
+
|
105
|
+
it 'should get extension files' do
|
106
|
+
expect(Bin.get_extension('Lots.of.dots.happen')).to eql('happen')
|
107
|
+
expect { Bin.get_extension('Nodotstoo') }.to raise_error
|
95
108
|
end
|
96
|
-
|
97
|
-
it
|
98
|
-
Bin.swap_extension(
|
109
|
+
|
110
|
+
it 'should swap extensions' do
|
111
|
+
expect(Bin.swap_extension('foo.txt', 'srt')).to eql('foo.srt')
|
99
112
|
end
|
100
|
-
|
101
|
-
it
|
113
|
+
|
114
|
+
it 'should parse user input' do
|
102
115
|
@subd = Subdownloader.new
|
103
|
-
@subd.parse_input(
|
116
|
+
expect(@subd.parse_input('1 2-5 7 8-10 15')).to eql([1, 2, 3, 4, 5, 7, 8, 9, 10, 15])
|
104
117
|
end
|
105
118
|
|
106
|
-
it
|
107
|
-
@sub =
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
Comments: Nice nice... \n\n")
|
119
|
+
it 'should print choice' do
|
120
|
+
@sub = double(Subtitle, info: sub_info)
|
121
|
+
@subd = Subdownloader.new
|
122
|
+
expect(@subd.print_option(@sub.info, 1)).
|
123
|
+
to eql(" #{'2'.yellow}. #{'Eng'.green} | #{'SRT'.blue} | #{'Resevoir Dogs'.cyan} / #{'1992'.cyan} | #{'9.5'.yellow} | FPS 29.0 | 2 CDs | 2012-12-12")
|
112
124
|
end
|
113
125
|
end
|
114
126
|
|
115
127
|
describe Subwork do
|
116
128
|
include BinspecHelper
|
117
|
-
|
118
|
-
it
|
119
|
-
File.
|
120
|
-
File.
|
121
|
-
|
122
|
-
STDOUT.
|
123
|
-
STDOUT.
|
124
|
-
|
125
|
-
Subtitle.
|
126
|
-
@mock_subtitle.
|
127
|
-
|
128
|
-
Subwork.new.run!(
|
129
|
+
|
130
|
+
it 'should call a new subtitle' do
|
131
|
+
expect(File).to receive(:open).with('file.srt', 'r').and_return(mock_file)
|
132
|
+
expect(File).to receive(:open).with('file.sub', 'w').and_return(true)
|
133
|
+
|
134
|
+
expect(STDOUT).to receive(:puts).with('Working on file file.srt...')
|
135
|
+
expect(STDOUT).to receive(:puts).with('Done: file.sub'.yellow)
|
136
|
+
|
137
|
+
expect(Subtitle).to receive(:new).and_return(mock_subtitle)
|
138
|
+
expect(@mock_subtitle).to receive(:to_sub).and_return('subbb')
|
139
|
+
|
140
|
+
Subwork.new.run!('file.srt', 'sub')
|
129
141
|
end
|
130
|
-
|
131
|
-
it
|
132
|
-
File.
|
133
|
-
File.
|
134
|
-
|
135
|
-
STDOUT.
|
136
|
-
STDOUT.
|
137
|
-
|
138
|
-
Subtitle.
|
139
|
-
@mock_subtitle.
|
140
|
-
Subwork.new.run!(
|
142
|
+
|
143
|
+
it 'should not write if file exist' do
|
144
|
+
expect(File).to receive(:open).with('file.srt', 'r').and_return(mock_file)
|
145
|
+
expect(File).to receive(:exist?).and_return(true)
|
146
|
+
|
147
|
+
expect(STDOUT).to receive(:puts).with('Working on file file.srt...')
|
148
|
+
expect(STDOUT).to receive(:puts).with('File exist: file.sub'.red)
|
149
|
+
|
150
|
+
expect(Subtitle).to receive(:new).and_return(mock_subtitle)
|
151
|
+
expect(@mock_subtitle).to receive(:to_sub).and_return('subbb')
|
152
|
+
Subwork.new.run!('file.srt', 'sub')
|
141
153
|
end
|
142
154
|
end
|
@@ -1,45 +1,43 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
2
2
|
|
3
|
-
describe Formats,
|
3
|
+
describe Formats, '.mpl' do
|
4
4
|
include SubFixtures
|
5
|
-
describe
|
6
|
-
|
5
|
+
describe 'In' do
|
7
6
|
before(:each) do
|
8
|
-
@mpl = Subtitle.new(
|
9
|
-
end
|
7
|
+
@mpl = Subtitle.new(dump: mpl_fixture, format: 'mpl')
|
8
|
+
end
|
10
9
|
|
11
|
-
it
|
12
|
-
@mpl.lines.
|
10
|
+
it 'should parse the sub to an array' do
|
11
|
+
expect(@mpl.lines).to be_instance_of(Array)
|
13
12
|
end
|
14
|
-
|
15
|
-
it
|
16
|
-
@mpl.
|
13
|
+
|
14
|
+
it 'should have N lines' do
|
15
|
+
expect(@mpl.lines.length).to eq(12)
|
17
16
|
end
|
18
|
-
|
19
|
-
it
|
20
|
-
@mpl.lines[0].time_on.to_s.
|
17
|
+
|
18
|
+
it 'should parse time of' do
|
19
|
+
expect(@mpl.lines[0].time_on.to_s).to eql('00:17:05.000')
|
21
20
|
end
|
22
|
-
|
23
|
-
it
|
24
|
-
@mpl.lines[0].time_off.to_s.
|
21
|
+
|
22
|
+
it 'should parse time of' do
|
23
|
+
expect(@mpl.lines[0].time_off.to_s).to eql('00:18:35.000')
|
25
24
|
end
|
26
|
-
|
27
|
-
it
|
28
|
-
@mpl.lines[0].text.
|
25
|
+
|
26
|
+
it 'should parse text' do
|
27
|
+
expect(@mpl.lines[0].text).to eql('You always say that.|The same thing every time.')
|
29
28
|
end
|
30
29
|
end
|
31
|
-
|
32
|
-
describe
|
33
|
-
|
30
|
+
|
31
|
+
describe 'Out!' do
|
34
32
|
before(:each) do
|
35
|
-
@sub = Subtitle.new(
|
36
|
-
end
|
37
|
-
|
38
|
-
it
|
39
|
-
@sub.to_mpl.
|
33
|
+
@sub = Subtitle.new(dump: yml_fixture, format: 'yml')
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'should dump the object as a SRT' do
|
37
|
+
expect(@sub.to_mpl).to eql("[3265][3285]worth killing for...
|
40
38
|
[3604][3634]worth dying for...
|
41
39
|
[4203][4233]worth going to the hell for...
|
42
40
|
[4203][4233]worth going a | line...\n")
|
43
41
|
end
|
44
42
|
end
|
45
|
-
end
|
43
|
+
end
|
@@ -1,42 +1,41 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
2
2
|
|
3
|
-
describe Formats,
|
3
|
+
describe Formats, '.rsb' do
|
4
4
|
include SubFixtures
|
5
|
-
describe
|
6
|
-
|
5
|
+
describe 'In' do
|
7
6
|
before(:each) do
|
8
|
-
@rsb = Subtitle.new(
|
9
|
-
end
|
7
|
+
@rsb = Subtitle.new(dump: rsb_fixture, format: 'rsb')
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'should parse the sub to an array' do
|
11
|
+
expect(@rsb.lines).to be_instance_of(Array)
|
12
|
+
end
|
10
13
|
|
11
|
-
it
|
12
|
-
@rsb.lines.
|
14
|
+
it 'should have N lines' do
|
15
|
+
expect(@rsb.lines.length).to eq(3)
|
13
16
|
end
|
14
|
-
|
15
|
-
it
|
16
|
-
@rsb.
|
17
|
+
|
18
|
+
it 'should parse time of' do
|
19
|
+
expect(@rsb.lines[0].time_on.to_s).to eql('00:05:26.500')
|
17
20
|
end
|
18
21
|
|
19
|
-
it
|
20
|
-
@rsb.lines[0].
|
22
|
+
it 'should parse time of' do
|
23
|
+
expect(@rsb.lines[0].time_off.to_s).to eql('00:05:28.500')
|
21
24
|
end
|
22
|
-
|
23
|
-
it
|
24
|
-
@rsb.lines[0].
|
25
|
+
|
26
|
+
it 'should parse text' do
|
27
|
+
expect(@rsb.lines[0].text).to eql('worth killing for...')
|
25
28
|
end
|
26
|
-
|
27
|
-
it "should parse text" do
|
28
|
-
@rsb.lines[0].text.should eql("worth killing for...")
|
29
|
-
end
|
30
29
|
end
|
31
|
-
|
32
|
-
describe
|
30
|
+
|
31
|
+
describe 'Out' do
|
33
32
|
include SubFixtures
|
34
|
-
before(:each) do
|
35
|
-
@sub = Subtitle.new(
|
36
|
-
end
|
37
|
-
|
38
|
-
it
|
39
|
-
@sub.to_rsb.
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
33
|
+
before(:each) do
|
34
|
+
@sub = Subtitle.new(dump: yml_fixture, format: 'yml')
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'should dump the object to rsb' do
|
38
|
+
expect(@sub.to_rsb).to eql("- title: sincity\n- authors: \n- version: 1.1\n00:05:26.500 => 00:05:28.500 == worth killing for...\n00:06:00.400 => 00:06:03.400 == worth dying for...\n00:07:00.300 => 00:07:03.300 == worth going to the hell for...\n00:07:00.300 => 00:07:03.300 == worth going a | line...\n")
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -1,42 +1,40 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
2
2
|
|
3
|
-
describe Formats,
|
3
|
+
describe Formats, '.srt' do
|
4
4
|
include SubFixtures
|
5
|
-
describe
|
6
|
-
|
5
|
+
describe 'In' do
|
7
6
|
before(:each) do
|
8
|
-
@srt = Subtitle.new(
|
9
|
-
end
|
7
|
+
@srt = Subtitle.new(dump: srt_fixture, format: 'srt')
|
8
|
+
end
|
10
9
|
|
11
|
-
it
|
12
|
-
@srt.lines.
|
10
|
+
it 'should parse the sub to an array' do
|
11
|
+
expect(@srt.lines).to be_instance_of(Array)
|
13
12
|
end
|
14
|
-
|
15
|
-
it
|
16
|
-
@srt.
|
13
|
+
|
14
|
+
it 'should have N lines' do
|
15
|
+
expect(@srt.lines.length).to eq(543)
|
17
16
|
end
|
18
|
-
|
19
|
-
it
|
20
|
-
@srt.lines[0].time_on.to_s.
|
17
|
+
|
18
|
+
it 'should parse time of' do
|
19
|
+
expect(@srt.lines[0].time_on.to_s).to eql('00:01:43.680')
|
21
20
|
end
|
22
|
-
|
23
|
-
it
|
24
|
-
@srt.lines[0].time_off.to_s.
|
21
|
+
|
22
|
+
it 'should parse time of' do
|
23
|
+
expect(@srt.lines[0].time_off.to_s).to eql('00:01:45.557')
|
25
24
|
end
|
26
|
-
|
27
|
-
it
|
28
|
-
@srt.lines[0].text.
|
25
|
+
|
26
|
+
it 'should parse text' do
|
27
|
+
expect(@srt.lines[0].text).to eql('My dear children,')
|
29
28
|
end
|
30
29
|
end
|
31
|
-
|
32
|
-
describe
|
33
|
-
|
30
|
+
|
31
|
+
describe 'Out!' do
|
34
32
|
before(:each) do
|
35
|
-
@sub = Subtitle.new(
|
36
|
-
end
|
37
|
-
|
38
|
-
it
|
39
|
-
@sub.to_srt.
|
33
|
+
@sub = Subtitle.new(dump: yml_fixture, format: 'yml')
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'should dump the object as a SRT' do
|
37
|
+
expect(@sub.to_srt).to eql("1
|
40
38
|
00:05:26,500 --> 00:05:28,500
|
41
39
|
worth killing for...
|
42
40
|
|
@@ -50,8 +48,7 @@ worth going to the hell for...
|
|
50
48
|
|
51
49
|
4
|
52
50
|
00:07:00,300 --> 00:07:03,300
|
53
|
-
worth going a
|
54
|
-
line...\n")
|
51
|
+
worth going a \n line...\n")
|
55
52
|
end
|
56
53
|
end
|
57
|
-
end
|
54
|
+
end
|
@@ -1,46 +1,44 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
2
2
|
|
3
|
-
describe Formats,
|
3
|
+
describe Formats, '.sub' do
|
4
4
|
include SubFixtures
|
5
|
-
describe
|
6
|
-
|
5
|
+
describe 'Parse' do
|
7
6
|
before(:each) do
|
8
|
-
@sub = Subtitle.new(
|
7
|
+
@sub = Subtitle.new(dump: sub_fixture, format: 'sub')
|
9
8
|
end
|
10
9
|
|
11
|
-
it
|
12
|
-
@sub.lines.
|
10
|
+
it 'should parse the sub to an array' do
|
11
|
+
expect(@sub.lines).to be_instance_of(Array)
|
13
12
|
end
|
14
13
|
|
15
|
-
it
|
16
|
-
@sub.
|
14
|
+
it 'should have N lines' do
|
15
|
+
expect(@sub.lines.length).to eq(2025)
|
17
16
|
end
|
18
17
|
|
19
|
-
it
|
20
|
-
@sub.lines[110].time_on.to_s.
|
18
|
+
it 'should have a nic text on' do
|
19
|
+
expect(@sub.lines[110].time_on.to_s).to eql('00:10:44.936')
|
21
20
|
end
|
22
21
|
|
23
|
-
it
|
24
|
-
@sub.lines[110].time_off.to_s.
|
22
|
+
it 'should have a nice text out' do
|
23
|
+
expect(@sub.lines[110].time_off.to_s).to eql('00:10:49.941')
|
25
24
|
end
|
26
25
|
|
27
|
-
it
|
28
|
-
@sub.lines[0].text.
|
26
|
+
it 'should parse the sentece correctly' do
|
27
|
+
expect(@sub.lines[0].text).to eql('You always say that.|The same thing every time.')
|
29
28
|
end
|
30
29
|
|
31
|
-
it
|
32
|
-
@sub.lines[2020].text.
|
30
|
+
it 'should parse the sentece correctly' do
|
31
|
+
expect(@sub.lines[2020].text).to eql("I'm tryin' real hard...")
|
33
32
|
end
|
34
33
|
end
|
35
34
|
|
36
|
-
describe
|
37
|
-
|
35
|
+
describe 'Out' do
|
38
36
|
before(:each) do
|
39
|
-
@sub = Subtitle.new(
|
37
|
+
@sub = Subtitle.new(dump: yml_fixture, format: 'yml')
|
40
38
|
end
|
41
39
|
|
42
|
-
it
|
43
|
-
@sub.to_sub.
|
40
|
+
it 'should dump the object as a SUB' do
|
41
|
+
expect(@sub.to_sub).to eql("{7816}{7864}worth killing for...
|
44
42
|
{8631}{8703}worth dying for...
|
45
43
|
{10069}{10141}worth going to the hell for...
|
46
44
|
{10069}{10141}worth going a | line...\n")
|
@@ -1,46 +1,46 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
2
2
|
|
3
|
-
describe Formats,
|
3
|
+
describe Formats, '.xml' do
|
4
4
|
include SubFixtures
|
5
|
-
describe
|
5
|
+
describe 'In' do
|
6
6
|
before(:each) do
|
7
|
-
@xml = Subtitle.new(
|
7
|
+
@xml = Subtitle.new(dump: xml_fixture, format: 'xml')
|
8
8
|
end
|
9
9
|
|
10
|
-
it
|
11
|
-
@xml.lines.
|
10
|
+
it 'should parse the sub to an array' do
|
11
|
+
expect(@xml.lines).to be_instance_of(Array)
|
12
12
|
end
|
13
13
|
|
14
|
-
it
|
15
|
-
@xml.
|
14
|
+
it 'should have N lines' do
|
15
|
+
expect(@xml.lines.length).to eq(13)
|
16
16
|
end
|
17
17
|
|
18
|
-
it
|
19
|
-
@xml.lines[0].time_on.to_s.
|
20
|
-
@xml.lines[10].time_on.to_s.
|
18
|
+
it 'should parse time of' do
|
19
|
+
expect(@xml.lines[0].time_on.to_s).to eql('00:00:00.000')
|
20
|
+
expect(@xml.lines[10].time_on.to_s).to eql('00:00:25.520')
|
21
21
|
end
|
22
22
|
|
23
|
-
it
|
24
|
-
@xml.lines[0].time_off.to_s.
|
25
|
-
@xml.lines[10].time_off.to_s.
|
23
|
+
it 'should parse time of' do
|
24
|
+
expect(@xml.lines[0].time_off.to_s).to eql('00:00:03.700')
|
25
|
+
expect(@xml.lines[10].time_off.to_s).to eql('00:00:27.520')
|
26
26
|
end
|
27
27
|
|
28
|
-
it
|
29
|
-
@xml.lines[0].text.
|
28
|
+
it 'should parse text' do
|
29
|
+
expect(@xml.lines[0].text).to eql("I had just joined <span tts:fontFamily=\"monospaceSansSerif,proportionalSerif,TheOther\" tts:fontSize=\"+2\">Macromedia</span> in 1996,")
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
-
describe
|
33
|
+
describe 'Out' do
|
34
34
|
before(:each) do
|
35
|
-
@sub = Subtitle.new(
|
35
|
+
@sub = Subtitle.new(dump: yml_fixture, format: 'yml')
|
36
36
|
end
|
37
37
|
|
38
|
-
it
|
39
|
-
@sub.to_xml.
|
38
|
+
it 'should parse the sub to an array' do
|
39
|
+
expect(@sub.to_xml).to be_instance_of(String)
|
40
40
|
end
|
41
41
|
|
42
|
-
it
|
43
|
-
@sub.to_xml.
|
42
|
+
it 'should equal...' do
|
43
|
+
expect(@sub.to_xml).to eql("<?xml version=\"1.0\" encoding=\"UTF-8\"?>
|
44
44
|
<tt xml:lang=\"en\" xmlns=\"http://www.w3.org/2006/10/ttaf1\" xmlns:tts=\"http://www.w3.org/2006/10/ttaf1#styling\">
|
45
45
|
<head>
|
46
46
|
<styling>
|