warlley-subtitle_it 0.7.4 → 0.7.5
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +7 -1
- data/README.txt +7 -2
- data/lib/subtitle_it/bin.rb +27 -25
- data/lib/subtitle_it/subdown.rb +1 -1
- data/lib/subtitle_it/subtitle.rb +21 -16
- data/lib/subtitle_it/version.rb +1 -1
- data/spec/subtitle_it/bin_spec.rb +55 -67
- data/spec/subtitle_it/formats/mpl_spec.rb +2 -2
- data/spec/subtitle_it/formats/rsb_spec.rb +2 -2
- data/spec/subtitle_it/formats/srt_spec.rb +2 -2
- data/spec/subtitle_it/formats/sub_spec.rb +2 -2
- data/spec/subtitle_it/formats/xml_spec.rb +2 -2
- data/spec/subtitle_it/formats/yml_spec.rb +1 -1
- data/spec/subtitle_it/subtitle_spec.rb +9 -3
- data/spec/subtitle_it_spec.rb +1 -1
- data/subtitle_it.gemspec +2 -2
- metadata +2 -2
data/History.txt
CHANGED
@@ -34,4 +34,10 @@
|
|
34
34
|
* 4 major enhancements:
|
35
35
|
* Adds download opensubtitles support
|
36
36
|
* Fixes various bugs (and adds another ones)
|
37
|
-
* Adds MPL2 support
|
37
|
+
* Adds MPL2 support
|
38
|
+
|
39
|
+
== 0.7.5 2008-09-13
|
40
|
+
|
41
|
+
* 2 major enhancement
|
42
|
+
* Support multiple file downloads
|
43
|
+
* subtitle_it worker code rewritten
|
data/README.txt
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
= Subtitle It
|
2
2
|
|
3
|
-
Ruby tool to
|
3
|
+
Ruby tool to download, create, convert and fix subtitles.
|
4
4
|
|
5
5
|
|
6
6
|
== FEATURES:
|
@@ -9,8 +9,10 @@ Ruby tool to work with subtitle files.
|
|
9
9
|
* Download from opensubtitles.org
|
10
10
|
* Fixes delays. (SrtResync)
|
11
11
|
|
12
|
+
|
12
13
|
== TODO:
|
13
14
|
|
15
|
+
* Support styles
|
14
16
|
* Compatibility with "sube" (http://github.com/vic/sube)
|
15
17
|
* Fix delays
|
16
18
|
* Convert 1 to 2 CD`s and versa-vice
|
@@ -28,6 +30,8 @@ Bash tool:
|
|
28
30
|
|
29
31
|
Convert a srt to sub:
|
30
32
|
subtitle_it in.srt out.sub
|
33
|
+
or
|
34
|
+
subtitle_it -c sub in.srt
|
31
35
|
|
32
36
|
Add a delay of 1 minute:
|
33
37
|
subtitle_it -d 60 in.srt
|
@@ -38,7 +42,8 @@ Create a template
|
|
38
42
|
|
39
43
|
== INSTALL:
|
40
44
|
|
41
|
-
|
45
|
+
gem sources add http://gems.github.com
|
46
|
+
sudo gem install nofxx-subtitle_it
|
42
47
|
|
43
48
|
|
44
49
|
== THE "Ruby Subtitle" Format - RSB
|
data/lib/subtitle_it/bin.rb
CHANGED
@@ -6,8 +6,8 @@ module SubtitleIt
|
|
6
6
|
def run!(file, format)
|
7
7
|
raise unless format
|
8
8
|
content = File.open(file, 'r')
|
9
|
-
puts "Working on file #{file}..."
|
10
|
-
sub = Subtitle.new(
|
9
|
+
STDOUT.puts "Working on file #{file}..."
|
10
|
+
sub = Subtitle.new({ :dump => content, :format => Bin.get_extension(file) })
|
11
11
|
dump = sub.send :"to_#{format}"
|
12
12
|
Bin::write_out(Bin.swap_extension(file, format), dump)
|
13
13
|
end
|
@@ -19,13 +19,13 @@ module SubtitleIt
|
|
19
19
|
@down = Subdown.new
|
20
20
|
@down.log_in!
|
21
21
|
res = @down.search_subtitles(@movie)
|
22
|
-
puts "Found #{res.length} result#{"s" if res.length > 1}. Choose one:\n"
|
23
|
-
res.sort.each_with_index { |r,i| puts print_option(r,i) }
|
24
|
-
puts "You can choose multiple ones, separated with spaces or a range separated with hifen."
|
25
|
-
printf "Choose: "
|
22
|
+
STDOUT.puts "Found #{res.length} result#{"s" if res.length > 1}. Choose one:\n"
|
23
|
+
res.sort.each_with_index { |r,i| STDOUT.puts print_option(r,i) }
|
24
|
+
STDOUT.puts "You can choose multiple ones, separated with spaces or a range separated with hifen."
|
25
|
+
STDOUT.printf "Choose: "
|
26
26
|
choose = parse_input(STDIN.gets.chomp)
|
27
27
|
choose = choose.map { |c| res[c.to_i-1] }
|
28
|
-
puts "Downloading #{choose.length} subtitles..."
|
28
|
+
STDOUT.puts "Downloading #{choose.length} subtitles..."
|
29
29
|
choose.each do |sub|
|
30
30
|
down_a_sub(sub, sub.format)
|
31
31
|
end
|
@@ -64,24 +64,26 @@ module SubtitleIt
|
|
64
64
|
@force = force
|
65
65
|
@format = format
|
66
66
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
67
|
+
unless File.exists?(argv[0])
|
68
|
+
# generate_rsb
|
69
|
+
return
|
70
|
+
end
|
71
|
+
|
72
|
+
@file_in = argv[0]
|
73
|
+
@file_in_ext = Bin.get_extension(@file_in)
|
74
|
+
if argv[1]
|
75
|
+
@file_out = argv[1]
|
76
|
+
@file_out_ext = Bin.get_extension(@file_out)
|
77
|
+
@format = @file_out_ext
|
78
|
+
end
|
79
|
+
if MOVIE_EXTS.include? @file_in_ext
|
80
|
+
Subdownloader.new.run!(argv[0])
|
81
|
+
elsif SUB_EXTS.include? @file_in_ext
|
82
|
+
Subwork.new.run!(@file_in, @format)
|
82
83
|
else
|
83
|
-
|
84
|
+
raise "Unknown file."
|
84
85
|
end
|
86
|
+
|
85
87
|
rescue Exception => e
|
86
88
|
puts e.message
|
87
89
|
exit 1
|
@@ -100,10 +102,10 @@ module SubtitleIt
|
|
100
102
|
|
101
103
|
def Bin.write_out(filename,dump)
|
102
104
|
if File.exists?(filename) && !@force
|
103
|
-
puts "File exists. #{filename}"
|
105
|
+
STDOUT.puts "File exists. #{filename}"
|
104
106
|
else
|
105
107
|
File.open(filename, 'w') {|f| f.write(dump) }
|
106
|
-
puts "Done. Wrote: #{filename}."
|
108
|
+
STDOUT.puts "Done. Wrote: #{filename}."
|
107
109
|
end
|
108
110
|
end
|
109
111
|
end
|
data/lib/subtitle_it/subdown.rb
CHANGED
@@ -48,7 +48,7 @@ module SubtitleIt
|
|
48
48
|
result = call('SearchSubtitles', [args])
|
49
49
|
return [] unless result['data'] # if no results result['data'] == false
|
50
50
|
result['data'].inject([]) do |subs, sub_info|
|
51
|
-
subs << Subtitle.new(sub_info)
|
51
|
+
subs << Subtitle.new({:info => sub_info})
|
52
52
|
subs
|
53
53
|
end
|
54
54
|
end
|
data/lib/subtitle_it/subtitle.rb
CHANGED
@@ -10,28 +10,26 @@ module SubtitleIt
|
|
10
10
|
|
11
11
|
MOVIE_EXTS = %w(3g2 3gp 3gp2 3gpp 60d ajp asf asx avchd avi bik bix box cam dat divx dmf dv dvr-ms evo flc fli flic flv flx gvi gvp h264 m1v m2p m2ts m2v m4e m4v mjp mjpeg mjpg mkv moov mov movhd movie movx mp4 mpe mpeg mpg mpv mpv2 mxf nsv nut ogg ogm omf ps qt ram rm rmvb swf ts vfw vid video viv vivo vob vro wm wmv wmx wrap wvx wx x264 xvid)
|
12
12
|
SUB_EXTS = %w(srt sub smi txt ssa ass mpl xml yml rsb)
|
13
|
+
#TODO: create a lang class?
|
14
|
+
LANGS = {
|
15
|
+
:pb => 'Brazilian Portuguese',
|
16
|
+
:en => 'English'
|
17
|
+
}
|
13
18
|
|
14
19
|
class Subtitle
|
15
20
|
attr_reader :id, :raw, :format, :lines, :style, :info, :filename, :rating
|
16
21
|
|
17
|
-
def initialize(
|
18
|
-
if @info = info
|
19
|
-
@id = info['IDSubtitleFile'].to_i
|
20
|
-
@filename = info['SubFileName'].to_s
|
21
|
-
@format = info['SubFormat'].to_s
|
22
|
-
@rating = info['SubRating'].to_f
|
22
|
+
def initialize(args = {})
|
23
|
+
if @info = args[:info]
|
24
|
+
@id = @info['IDSubtitleFile'].to_i
|
25
|
+
@filename = @info['SubFileName'].to_s
|
26
|
+
@format = @info['SubFormat'].to_s
|
27
|
+
@rating = @info['SubRating'].to_f
|
23
28
|
end
|
24
|
-
@fps=23.976
|
25
|
-
parse_dump(dump,format) if dump
|
29
|
+
@fps = args[:fps] || 23.976
|
30
|
+
parse_dump(args[:dump], args[:format]) if args[:dump]
|
26
31
|
end
|
27
32
|
|
28
|
-
def parse_dump(dump,format)
|
29
|
-
raise unless format =~ /^srt$|sub|yml|txt|rsb|xml|ass|mpl/
|
30
|
-
@raw = dump.kind_of?(String) ? dump : dump.read
|
31
|
-
@format = format
|
32
|
-
parse!
|
33
|
-
end
|
34
|
-
|
35
33
|
def style=(s)
|
36
34
|
@style = s
|
37
35
|
end
|
@@ -51,7 +49,14 @@ module SubtitleIt
|
|
51
49
|
|
52
50
|
private
|
53
51
|
|
54
|
-
def
|
52
|
+
def parse_dump(dump,format)
|
53
|
+
raise unless SUB_EXTS.include?(format)
|
54
|
+
@raw = dump.kind_of?(String) ? dump : dump.read
|
55
|
+
@format = format
|
56
|
+
parse_lines!
|
57
|
+
end
|
58
|
+
|
59
|
+
def parse_lines!
|
55
60
|
self.lines = send :"parse_#{@format}"
|
56
61
|
end
|
57
62
|
|
data/lib/subtitle_it/version.rb
CHANGED
@@ -1,21 +1,34 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
2
|
|
3
3
|
module BinspecHelper
|
4
|
-
def mock_xmlrpc(stubs={})
|
5
|
-
|
6
|
-
end
|
4
|
+
def mock_xmlrpc(stubs={}); @mock_xmlrpc ||= mock(XMLRPC::Client, stubs); end
|
5
|
+
def mock_subdown; @mock_subdown = mock(Subdown); end
|
6
|
+
def mock_file; @mock_file = mock(File); end
|
7
|
+
|
7
8
|
def mock_movie
|
8
|
-
@mock_movie = mock(Movie, {:filename => "Beavis Butthead Do America",
|
9
|
+
@mock_movie = mock(Movie, {:filename => "Beavis Butthead Do America.avi",
|
9
10
|
:haxx => '09a2c497663259cb' })
|
10
11
|
end
|
11
|
-
|
12
|
-
@mock_subdown = mock(Subdown)
|
13
|
-
end
|
12
|
+
|
14
13
|
def mock_subtitle
|
15
|
-
@mock_subtitle = mock(Subtitle
|
16
|
-
|
17
|
-
|
18
|
-
|
14
|
+
@mock_subtitle = mock(Subtitle, {
|
15
|
+
:info => sub_info, :format => 'srt'
|
16
|
+
})
|
17
|
+
end
|
18
|
+
|
19
|
+
def sub_info
|
20
|
+
{
|
21
|
+
"SubLanguageID" => 'eng',
|
22
|
+
"MovieName" => 'Resevoir Dogs',
|
23
|
+
"MovieYear" => '1992',
|
24
|
+
"SubFileName" => 'Cool sub',
|
25
|
+
"MovieImdbRating" => '10.0',
|
26
|
+
"SubDownloadsCnt" => '310',
|
27
|
+
"SubRating" => '9.5',
|
28
|
+
"SubFormat" => 'srt',
|
29
|
+
"SubSumCD" => '2',
|
30
|
+
"SubAuthorComment" => 'Nice nice...'
|
31
|
+
}
|
19
32
|
end
|
20
33
|
end
|
21
34
|
|
@@ -27,6 +40,8 @@ describe Bin do
|
|
27
40
|
end
|
28
41
|
|
29
42
|
# Having a hard time testing the command line tool...
|
43
|
+
# #
|
44
|
+
#
|
30
45
|
# it "should call for movie" do
|
31
46
|
# Subdownloader.should_receive(:new)
|
32
47
|
# File.should_receive(:exists?).and_return(true)
|
@@ -45,51 +60,28 @@ end
|
|
45
60
|
|
46
61
|
describe Subdownloader do
|
47
62
|
include BinspecHelper
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
# #@mock_movie.should_receive(:filename).and_return("Beavis and Butthead do America")
|
68
|
-
# @mock_subtitle.should_receive(:info).and_return({
|
69
|
-
# "SubLanguageID" => 'eng',
|
70
|
-
# "MovieName" => 'Resevoir Dogs',
|
71
|
-
# "MovieYear" => '1992',
|
72
|
-
# "SubFileName" => 'Cool sub',
|
73
|
-
# "MovieImdbRating" => '10.0',
|
74
|
-
# "SubDownloadsCnt" => '310',
|
75
|
-
# "SubRating" => '9.5',
|
76
|
-
# "SubFormat" => 'srt',
|
77
|
-
# "SubSumCD" => '2',
|
78
|
-
# "SubAuthorComment" => 'Nice nice...'
|
79
|
-
# })
|
80
|
-
# @mock_subdown.should_receive(:log_in!)
|
81
|
-
# @mock_subdown.should_receive(:log_out!)
|
82
|
-
# @mock_subdown.should_receive(:search_subtitles).and_return([mock_subtitle])
|
83
|
-
# @mock_subdown.should_receive(:download_subtitle).and_return(mock_subtitle)#.with(@mock_subtitle)
|
84
|
-
# @mock_subtitle.should_receive(:format).and_return('sub')
|
85
|
-
# @mock_subdown.stub!(:format).and_return('srt')
|
86
|
-
#
|
87
|
-
# @subd = Subdownloader.new
|
88
|
-
# @subd.run!('teste.avi')
|
89
|
-
#
|
90
|
-
# @subd.down_a_sub(mock_subtitle, "xxx")
|
63
|
+
|
64
|
+
it "should download a subtitle" do
|
65
|
+
Movie.should_receive(:new).and_return(mock_movie)
|
66
|
+
Subdown.should_receive(:new).and_return(mock_subdown)#mock(Subdown))
|
67
|
+
|
68
|
+
STDIN.should_receive(:gets).and_return("1")
|
69
|
+
STDOUT.should_receive(:puts).with("Found 1 result. Choose one:\n")
|
70
|
+
STDOUT.should_receive(:printf).with("Choose: ")
|
71
|
+
STDOUT.should_receive(:puts).with("You can choose multiple ones, separated with spaces or a range separated with hifen.")
|
72
|
+
STDOUT.should_receive(:puts).with("Downloading 1 subtitles...")
|
73
|
+
STDOUT.should_receive(:puts).with("1) Resevoir Dogs / 1992 | Cool sub | Movie score: 10.0\n Lang: Eng | Format: SRT | Downloads: 310 | Rating: 9.5 | CDs: 2\n Comments: Nice nice... \n\n")
|
74
|
+
STDOUT.should_receive(:puts).with("Done. Wrote: Beavis Butthead Do America.srt.")
|
75
|
+
|
76
|
+
File.should_receive(:open).with("Beavis Butthead Do America.srt", "w").and_return(true)
|
77
|
+
|
78
|
+
@mock_subdown.should_receive(:log_in!).and_return(true)
|
79
|
+
@mock_subdown.should_receive(:download_subtitle).and_return(mock_subtitle)
|
80
|
+
@mock_subdown.should_receive(:search_subtitles).and_return([mock_subtitle])
|
81
|
+
@mock_subdown.should_receive(:log_out!).and_return(true)
|
91
82
|
|
92
|
-
|
83
|
+
Subdownloader.new.run! "file.avi"
|
84
|
+
end
|
93
85
|
|
94
86
|
it "should get extension files" do
|
95
87
|
Bin.get_extension("Lots.of.dots.happen").should eql("happen")
|
@@ -106,18 +98,7 @@ describe Subdownloader do
|
|
106
98
|
end
|
107
99
|
|
108
100
|
it "should print choice" do
|
109
|
-
@sub = mock(Subtitle, :info =>
|
110
|
-
"SubLanguageID" => 'eng',
|
111
|
-
"MovieName" => 'Resevoir Dogs',
|
112
|
-
"MovieYear" => '1992',
|
113
|
-
"SubFileName" => 'Cool sub',
|
114
|
-
"MovieImdbRating" => '10.0',
|
115
|
-
"SubDownloadsCnt" => '310',
|
116
|
-
"SubRating" => '9.5',
|
117
|
-
"SubFormat" => 'srt',
|
118
|
-
"SubSumCD" => '2',
|
119
|
-
"SubAuthorComment" => 'Nice nice...'
|
120
|
-
})
|
101
|
+
@sub = mock(Subtitle, :info => sub_info)
|
121
102
|
@subd = Subdownloader.new
|
122
103
|
@subd.print_option(@sub, 1).should eql("2) Resevoir Dogs / 1992 | Cool sub | Movie score: 10.0
|
123
104
|
Lang: Eng | Format: SRT | Downloads: 310 | Rating: 9.5 | CDs: 2
|
@@ -132,6 +113,9 @@ describe Subwork do
|
|
132
113
|
File.should_receive(:open).with("file.srt", "r").and_return(mock_file)
|
133
114
|
File.should_receive(:open).with("file.sub", "w").and_return(true)
|
134
115
|
|
116
|
+
STDOUT.should_receive(:puts).with("Working on file file.srt...")
|
117
|
+
STDOUT.should_receive(:puts).with('Done. Wrote: file.sub.')
|
118
|
+
|
135
119
|
Subtitle.should_receive(:new).and_return(mock_subtitle)
|
136
120
|
@mock_subtitle.should_receive(:to_sub).and_return('subbb')
|
137
121
|
|
@@ -141,6 +125,10 @@ describe Subwork do
|
|
141
125
|
it "should not write if file exists" do
|
142
126
|
File.should_receive(:open).with("file.srt", "r").and_return(mock_file)
|
143
127
|
File.should_receive(:exists?).and_return(true)
|
128
|
+
|
129
|
+
STDOUT.should_receive(:puts).with("Working on file file.srt...")
|
130
|
+
STDOUT.should_receive(:puts).with("File exists. file.sub")
|
131
|
+
|
144
132
|
Subtitle.should_receive(:new).and_return(mock_subtitle)
|
145
133
|
@mock_subtitle.should_receive(:to_sub).and_return('subbb')
|
146
134
|
Subwork.new.run!("file.srt", "sub")
|
@@ -5,7 +5,7 @@ describe Formats, ".mpl" do
|
|
5
5
|
describe "In" do
|
6
6
|
|
7
7
|
before(:each) do
|
8
|
-
@mpl = Subtitle.new(
|
8
|
+
@mpl = Subtitle.new({:dump => mpl_fixture, :format => 'mpl'})
|
9
9
|
end
|
10
10
|
|
11
11
|
it "should parse the sub to an array" do
|
@@ -32,7 +32,7 @@ describe Formats, ".mpl" do
|
|
32
32
|
describe "Out!" do
|
33
33
|
|
34
34
|
before(:each) do
|
35
|
-
@sub = Subtitle.new(
|
35
|
+
@sub = Subtitle.new({:dump => yml_fixture, :format => 'yml'})
|
36
36
|
end
|
37
37
|
|
38
38
|
it "should dump the object as a SRT" do
|
@@ -5,7 +5,7 @@ describe Formats, ".rsb" do
|
|
5
5
|
describe "In" do
|
6
6
|
|
7
7
|
before(:each) do
|
8
|
-
@rsb = Subtitle.new(
|
8
|
+
@rsb = Subtitle.new({:dump => rsb_fixture, :format => 'rsb'})
|
9
9
|
end
|
10
10
|
|
11
11
|
it "should parse the sub to an array" do
|
@@ -32,7 +32,7 @@ describe Formats, ".rsb" do
|
|
32
32
|
describe "Out" do
|
33
33
|
include SubFixtures
|
34
34
|
before(:each) do
|
35
|
-
@sub = Subtitle.new(
|
35
|
+
@sub = Subtitle.new({:dump => yml_fixture, :format => 'yml'})
|
36
36
|
end
|
37
37
|
|
38
38
|
it "should dump the object to rsb" do
|
@@ -5,7 +5,7 @@ describe Formats, ".srt" do
|
|
5
5
|
describe "In" do
|
6
6
|
|
7
7
|
before(:each) do
|
8
|
-
@srt = Subtitle.new(
|
8
|
+
@srt = Subtitle.new({:dump => srt_fixture, :format => 'srt'})
|
9
9
|
end
|
10
10
|
|
11
11
|
it "should parse the sub to an array" do
|
@@ -32,7 +32,7 @@ describe Formats, ".srt" do
|
|
32
32
|
describe "Out!" do
|
33
33
|
|
34
34
|
before(:each) do
|
35
|
-
@sub = Subtitle.new(
|
35
|
+
@sub = Subtitle.new({:dump => yml_fixture, :format => 'yml'})
|
36
36
|
end
|
37
37
|
|
38
38
|
it "should dump the object as a SRT" do
|
@@ -5,7 +5,7 @@ describe Formats, ".sub" do
|
|
5
5
|
describe "Parse" do
|
6
6
|
|
7
7
|
before(:each) do
|
8
|
-
@sub = Subtitle.new(
|
8
|
+
@sub = Subtitle.new({:dump => sub_fixture, :format => 'sub'})
|
9
9
|
end
|
10
10
|
|
11
11
|
it "should parse the sub to an array" do
|
@@ -36,7 +36,7 @@ describe Formats, ".sub" do
|
|
36
36
|
describe "Out" do
|
37
37
|
|
38
38
|
before(:each) do
|
39
|
-
@sub = Subtitle.new(
|
39
|
+
@sub = Subtitle.new({:dump => yml_fixture, :format => 'yml'})
|
40
40
|
end
|
41
41
|
|
42
42
|
it "should dump the object as a SUB" do
|
@@ -4,7 +4,7 @@ describe Formats, ".xml" do
|
|
4
4
|
include SubFixtures
|
5
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
10
|
it "should parse the sub to an array" do
|
@@ -32,7 +32,7 @@ describe Formats, ".xml" do
|
|
32
32
|
|
33
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
38
|
it "should parse the sub to an array" do
|
@@ -2,7 +2,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
|
2
2
|
|
3
3
|
describe Subtitle do
|
4
4
|
def attr_valid_subtitle
|
5
|
-
{
|
5
|
+
{ :info => {
|
6
6
|
"SubLanguageID" => 'eng',
|
7
7
|
"MovieName" => 'Resevoir Dogs',
|
8
8
|
"MovieYear" => '1992',
|
@@ -13,7 +13,7 @@ describe Subtitle do
|
|
13
13
|
"SubFormat" => 'srt',
|
14
14
|
"SubSumCD" => '2',
|
15
15
|
"SubAuthorComment" => 'Nice nice...'
|
16
|
-
}
|
16
|
+
}}
|
17
17
|
end
|
18
18
|
|
19
19
|
it "should instantiate" do
|
@@ -21,13 +21,19 @@ describe Subtitle do
|
|
21
21
|
@sub.rating.should eql(9.5)
|
22
22
|
end
|
23
23
|
|
24
|
+
it "should fill lines" do
|
25
|
+
@sub = Subtitle.new(attr_valid_subtitle.with({:dump => "{10}{20} Hello", :format => "sub"}))
|
26
|
+
@sub.lines[0].text.should eql(' Hello')
|
27
|
+
end
|
28
|
+
|
29
|
+
|
24
30
|
describe "Compare" do
|
25
31
|
before(:each) do
|
26
32
|
@sub = Subtitle.new(attr_valid_subtitle)
|
27
33
|
end
|
28
34
|
|
29
35
|
it "should compare to another using rating" do
|
30
|
-
@another_sub = Subtitle.new(attr_valid_subtitle.with("SubRating" => 4.0))
|
36
|
+
@another_sub = Subtitle.new(attr_valid_subtitle.with(:info => { "SubRating" => 4.0} ))
|
31
37
|
(@sub > @another_sub).should be_true
|
32
38
|
end
|
33
39
|
|
data/spec/subtitle_it_spec.rb
CHANGED
@@ -5,7 +5,7 @@ require File.dirname(__FILE__) + '/spec_helper.rb'
|
|
5
5
|
describe SubtitleIt do
|
6
6
|
|
7
7
|
it "should instantiate " do
|
8
|
-
@sub = Subtitle.new(
|
8
|
+
@sub = Subtitle.new({:dump => "{12}{30}hey hey heypending", :format => "sub"})
|
9
9
|
@sub.should be_instance_of(Subtitle)
|
10
10
|
end
|
11
11
|
end
|
data/subtitle_it.gemspec
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = %q{subtitle_it}
|
3
|
-
s.version = "0.7.
|
3
|
+
s.version = "0.7.5"
|
4
4
|
|
5
5
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
6
6
|
s.authors = ["Marcos Piccinini", "Warlley Rezende"]
|
7
|
-
s.date = %q{2008-09-
|
7
|
+
s.date = %q{2008-09-13}
|
8
8
|
s.default_executable = %q{subtitle_it}
|
9
9
|
s.description = %q{description of gem}
|
10
10
|
s.email = ["x@nofxx.com"]
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: warlley-subtitle_it
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marcos Piccinini
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2008-09-
|
13
|
+
date: 2008-09-13 00:00:00 -07:00
|
14
14
|
default_executable: subtitle_it
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|