nofxx-subtitle_it 0.6.1

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.
Files changed (50) hide show
  1. data/.autotest +19 -0
  2. data/History.txt +30 -0
  3. data/License.txt +20 -0
  4. data/Manifest.txt +49 -0
  5. data/README.markdown +41 -0
  6. data/README.txt +84 -0
  7. data/Rakefile +4 -0
  8. data/bin/subtitle_it +115 -0
  9. data/config/hoe.rb +73 -0
  10. data/config/requirements.rb +15 -0
  11. data/lib/subtitle_it.rb +46 -0
  12. data/lib/subtitle_it/formats/ass.rb +14 -0
  13. data/lib/subtitle_it/formats/rsb.rb +33 -0
  14. data/lib/subtitle_it/formats/srt.rb +34 -0
  15. data/lib/subtitle_it/formats/sub.rb +31 -0
  16. data/lib/subtitle_it/formats/xml.rb +64 -0
  17. data/lib/subtitle_it/formats/yml.rb +20 -0
  18. data/lib/subtitle_it/subline.rb +25 -0
  19. data/lib/subtitle_it/subtime.rb +58 -0
  20. data/lib/subtitle_it/subtitle.rb +32 -0
  21. data/lib/subtitle_it/version.rb +9 -0
  22. data/script/console +10 -0
  23. data/script/destroy +14 -0
  24. data/script/generate +14 -0
  25. data/script/txt2html +82 -0
  26. data/setup.rb +1585 -0
  27. data/spec/fixtures/godfather.srt +2487 -0
  28. data/spec/fixtures/huge.ass +22 -0
  29. data/spec/fixtures/movie.xml +28 -0
  30. data/spec/fixtures/movie.yml +163 -0
  31. data/spec/fixtures/pseudo.rsb +6 -0
  32. data/spec/fixtures/pulpfiction.sub +2025 -0
  33. data/spec/fixtures/sincity.yml +12 -0
  34. data/spec/spec.opts +1 -0
  35. data/spec/spec_helper.rb +33 -0
  36. data/spec/subtitle_it/formats/ass_spec.rb +5 -0
  37. data/spec/subtitle_it/formats/rsb_spec.rb +42 -0
  38. data/spec/subtitle_it/formats/srt_spec.rb +42 -0
  39. data/spec/subtitle_it/formats/sub_spec.rb +46 -0
  40. data/spec/subtitle_it/formats/xml_spec.rb +46 -0
  41. data/spec/subtitle_it/formats/yml_spec.rb +20 -0
  42. data/spec/subtitle_it/subline_spec.rb +30 -0
  43. data/spec/subtitle_it/subtime_spec.rb +76 -0
  44. data/spec/subtitle_it/subtitle_spec.rb +1 -0
  45. data/spec/subtitle_it_spec.rb +11 -0
  46. data/subtitle_it.gemspec +41 -0
  47. data/tasks/deployment.rake +34 -0
  48. data/tasks/environment.rake +7 -0
  49. data/tasks/rspec.rake +21 -0
  50. metadata +128 -0
@@ -0,0 +1,12 @@
1
+ header:
2
+ title: sincity
3
+ authors: warlley, nofxx
4
+ version: 1.1
5
+
6
+ lines:
7
+ - ['00:05:26.5', '00:05:28.5', 'worth killing for...']
8
+ - ['00:06:00.4', '00:06:03.4', 'worth dying for...']
9
+ - ['00:07:00.3', '00:07:03.3', 'worth going to the hell for...']
10
+ - ['00:07:00.3', '00:07:03.3', 'worth going a | line...']
11
+
12
+
@@ -0,0 +1 @@
1
+ --colour
@@ -0,0 +1,33 @@
1
+ begin
2
+ require 'spec'
3
+ rescue LoadError
4
+ require 'rubygems'
5
+ gem 'rspec'
6
+ require 'spec'
7
+ end
8
+
9
+ $:.unshift(File.dirname(__FILE__) + '/../lib')
10
+ require 'subtitle_it'
11
+ include SubtitleIt
12
+
13
+ module SubFixtures
14
+ def sub_fixture
15
+ File.open(File.expand_path(File.dirname(__FILE__) + '/fixtures/pulpfiction.sub'))
16
+ end
17
+
18
+ def srt_fixture
19
+ File.open(File.expand_path(File.dirname(__FILE__) + '/fixtures/godfather.srt'))
20
+ end
21
+
22
+ def yml_fixture
23
+ File.open(File.expand_path(File.dirname(__FILE__) + '/fixtures/sincity.yml'))
24
+ end
25
+
26
+ def rsb_fixture
27
+ File.open(File.expand_path(File.dirname(__FILE__) + '/fixtures/pseudo.rsb'))
28
+ end
29
+
30
+ def xml_fixture
31
+ File.open(File.expand_path(File.dirname(__FILE__) + '/fixtures/movie.xml'))
32
+ end
33
+ end
@@ -0,0 +1,5 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
+
3
+ describe Formats, ".ass" do
4
+
5
+ end
@@ -0,0 +1,42 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
+
3
+ describe Formats, ".rsb" do
4
+ include SubFixtures
5
+ describe "In" do
6
+
7
+ before(:each) do
8
+ @rsb = Subtitle.new(rsb_fixture,'rsb')
9
+ end
10
+
11
+ it "should parse the sub to an array" do
12
+ @rsb.lines.should be_instance_of(Array)
13
+ end
14
+
15
+ it "should have N lines" do
16
+ @rsb.should have(3).lines
17
+ end
18
+
19
+ it "should parse time of" do
20
+ @rsb.lines[0].text_on.to_s.should eql("00:05:26.500")
21
+ end
22
+
23
+ it "should parse time of" do
24
+ @rsb.lines[0].text_off.to_s.should eql("00:05:28.500")
25
+ end
26
+
27
+ it "should parse text" do
28
+ @rsb.lines[0].text.should eql("worth killing for...")
29
+ end
30
+ end
31
+
32
+ describe "Out" do
33
+ include SubFixtures
34
+ before(:each) do
35
+ @sub = Subtitle.new(yml_fixture,'yml')
36
+ end
37
+
38
+ it "should dump the object to rsb" do
39
+ @sub.to_rsb.should 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...")
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,42 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
+
3
+ describe Formats, ".srt" do
4
+ include SubFixtures
5
+ describe "In" do
6
+
7
+ before(:each) do
8
+ @srt = Subtitle.new(srt_fixture,'srt')
9
+ end
10
+
11
+ it "should parse the sub to an array" do
12
+ @srt.lines.should be_instance_of(Array)
13
+ end
14
+
15
+ it "should have N lines" do
16
+ @srt.should have(543).lines
17
+ end
18
+
19
+ it "should parse time of" do
20
+ @srt.lines[0].text_on.to_s.should eql("00:01:43.680")
21
+ end
22
+
23
+ it "should parse time of" do
24
+ @srt.lines[0].text_off.to_s.should eql("00:01:45.557")
25
+ end
26
+
27
+ it "should parse text" do
28
+ @srt.lines[0].text.should eql("My dear children,")
29
+ end
30
+ end
31
+
32
+ describe "Out!" do
33
+
34
+ before(:each) do
35
+ @sub = Subtitle.new(yml_fixture,'yml')
36
+ end
37
+
38
+ it "should dump the object as a SRT" do
39
+ @sub.to_srt.should eql("0\n00:05:26.500 --> 00:05:28.500\nworth killing for...\n1\n00:06:00.400 --> 00:06:03.400\nworth dying for...\n2\n00:07:00.300 --> 00:07:03.300\nworth going to the hell for...\n3\n00:07:00.300 --> 00:07:03.300\nworth going a \n line...")
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,46 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
+
3
+ describe Formats, ".sub" do
4
+ include SubFixtures
5
+ describe "Parse" do
6
+
7
+ before(:each) do
8
+ @sub = Subtitle.new(sub_fixture,'sub')
9
+ end
10
+
11
+ it "should parse the sub to an array" do
12
+ @sub.lines.should be_instance_of(Array)
13
+ end
14
+
15
+ it "should have N lines" do
16
+ @sub.should have(2025).lines
17
+ end
18
+
19
+ it "should have a nic text on" do
20
+ @sub.lines[110].text_on.to_s.should eql('00:10:44.936')
21
+ end
22
+
23
+ it "should have a nice text out" do
24
+ @sub.lines[110].text_off.to_s.should eql('00:10:49.941')
25
+ end
26
+
27
+ it "should parse the sentece correctly" do
28
+ @sub.lines[0].text.should eql("You always say that.|The same thing every time.")
29
+ end
30
+
31
+ it "should parse the sentece correctly" do
32
+ @sub.lines[2020].text.should eql("I'm tryin' real hard...")
33
+ end
34
+ end
35
+
36
+ describe "Out" do
37
+
38
+ before(:each) do
39
+ @sub = Subtitle.new(yml_fixture,'yml')
40
+ end
41
+
42
+ it "should dump the object as a SUB" do
43
+ @sub.to_sub.should eql("{13}{13}worth killing for...\r\n{15}{15}worth dying for...\r\n{17}{17}worth going to the hell for...\r\n{17}{17}worth going a | line...")
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,46 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
+
3
+ describe Formats, ".xml" do
4
+ include SubFixtures
5
+ describe "In" do
6
+ before(:each) do
7
+ @xml = Subtitle.new(xml_fixture,'xml')
8
+ end
9
+
10
+ it "should parse the sub to an array" do
11
+ @xml.lines.should be_instance_of(Array)
12
+ end
13
+
14
+ it "should have N lines" do
15
+ @xml.should have(13).lines
16
+ end
17
+
18
+ it "should parse time of" do
19
+ @xml.lines[0].text_on.to_s.should eql("00:00:00.000")
20
+ @xml.lines[10].text_on.to_s.should eql("00:00:25.520")
21
+ end
22
+
23
+ it "should parse time of" do
24
+ @xml.lines[0].text_off.to_s.should eql("00:00:03.700")
25
+ @xml.lines[10].text_off.to_s.should eql("00:00:27.520")
26
+ end
27
+
28
+ it "should parse text" do
29
+ @xml.lines[0].text.should eql("I had just joined <span tts:fontSize=\"+2\" tts:fontFamily=\"monospaceSansSerif,proportionalSerif,TheOther\">Macromedia</span> in 1996,")
30
+ end
31
+ end
32
+
33
+ describe "Out" do
34
+ before(:each) do
35
+ @sub = Subtitle.new(yml_fixture,'yml')
36
+ end
37
+
38
+ it "should parse the sub to an array" do
39
+ @sub.to_xml.should be_instance_of(String)
40
+ end
41
+
42
+ it "should equal..." do
43
+ @sub.to_xml.should eql("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<tt xml:lang=\"en\" xmlns=\"http://www.w3.org/2006/04/ttaf1\" xmlns:tts=\"http://www.w3.org/2006/04/ttaf1#styling\">\n <head>\n <styling>\n \n </styling>\n </head>\n <body>\n <div xml:lang=\"en\">\n <p begin=\"00:05:26.500\" dur=\"00:00:02.000\">worth killing for...</p><p begin=\"00:06:00.400\" dur=\"00:00:03.000\">worth dying for...</p><p begin=\"00:07:00.300\" dur=\"00:00:03.000\">worth going to the hell for...</p><p begin=\"00:07:00.300\" dur=\"00:00:03.000\">worth going a | line...</p> \n </div>\n </body>\n</tt>\n")
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,20 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
+
3
+ describe Formats, ".yml" do
4
+ describe "Out" do
5
+ include SubFixtures
6
+
7
+ before(:each) do
8
+ @sub = Subtitle.new(yml_fixture,'yml')
9
+ end
10
+
11
+ it "should have author" do
12
+ @sub.to_yml.should match(/author: warlley, nofxx/)
13
+ end
14
+
15
+ it "should have version" do
16
+ @sub.to_yml.should match(/version: 1.1/)
17
+ end
18
+
19
+ end
20
+ end
@@ -0,0 +1,30 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ describe Subline do
4
+ before(:each) do
5
+ @sub = Subline.new('02:20:02','4',"Astalavista, baby...")
6
+ end
7
+
8
+ it "should initialize #{name}" do
9
+ @sub.text.should eql("Astalavista, baby...")
10
+ end
11
+
12
+ it "should have a nice date on" do
13
+ @sub.text_on.sec.should eql(2)
14
+ @sub.text_on.min.should eql(20)
15
+ @sub.text_on.sec.should eql(2)
16
+ end
17
+
18
+ it "should have the seconds added from the first time" do
19
+ @sub.text_off.sec.should eql(6)
20
+ end
21
+ end
22
+
23
+ describe Subline, ".failures" do
24
+
25
+ it "should correct a timeline beforehe on time" do
26
+ lambda do
27
+ Subline.new('00:03:01','00:02:03',"Astalavista, baby...")
28
+ end.should_not raise_error
29
+ end
30
+ end
@@ -0,0 +1,76 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ describe Subtime do
4
+ before(:each) do
5
+ @subtime = Subtime.new('01:02:03.400')
6
+ end
7
+
8
+ it "should convert the hour" do
9
+ @subtime.hrs.should eql(1)
10
+ end
11
+
12
+ it "should convert in minutes" do
13
+ @subtime.min.should eql(2)
14
+ end
15
+
16
+ it "should convert in hours" do
17
+ @subtime.sec.should eql(3)
18
+ end
19
+
20
+ it "should reduce the deciseconds" do
21
+ 800.reduce.should eql(8)
22
+ end
23
+
24
+ it "should have ms" do
25
+ @subtime.ms.should eql(400)
26
+ end
27
+
28
+ it "should print nicely" do
29
+ @subtime.to_s.should eql("01:02:03.400")
30
+ end
31
+
32
+ it "should print nicely" do
33
+ @subtime.to_i.should eql(3723400)
34
+ end
35
+ end
36
+
37
+ describe Subtime,"22" do
38
+ it "should convert a big time" do
39
+ @subtime = Subtime.new('11:22:33.742')
40
+ @subtime.hrs.should eql(11)
41
+ @subtime.min.should eql(22)
42
+ @subtime.sec.should eql(33)
43
+ @subtime.ms.should eql(742)
44
+ end
45
+
46
+ it "should print nicely" do
47
+ @subtime = Subtime.new('11:22:33.7')
48
+ @subtime.to_s.should eql("11:22:33.700")
49
+ end
50
+ end
51
+
52
+ describe Subtime, ".other formats" do
53
+
54
+ it "should parse comma" do
55
+ @subtime = Subtime.new('01:03.4')
56
+ end
57
+
58
+ it "should parse dot" do
59
+ @subtime = Subtime.new('01:03,3')
60
+ end
61
+
62
+ it "should parse dot" do
63
+ @subtime = Subtime.new('3')
64
+ @subtime.hrs.should eql(0)
65
+ end
66
+
67
+ it "should parse dot" do
68
+ @subtime = Subtime.new('01:03')
69
+ @subtime.min.should eql(1)
70
+ end
71
+
72
+ after(:each) do
73
+ @subtime.sec.should eql(3)
74
+ end
75
+
76
+ end
@@ -0,0 +1 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
@@ -0,0 +1,11 @@
1
+ require File.dirname(__FILE__) + '/spec_helper.rb'
2
+
3
+ # Time to add your specs!
4
+ # http://rspec.info/
5
+ describe SubtitleIt do
6
+
7
+ it "should instantiate " do
8
+ @sub = Subtitle.new("{12}{30}hey hey heypending", "sub")
9
+ @sub.should be_instance_of(Subtitle)
10
+ end
11
+ end
@@ -0,0 +1,41 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = %q{subtitle_it}
3
+ s.version = "0.6.1"
4
+
5
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
6
+ s.authors = ["Marcos Piccinini", "Warlley Rezende"]
7
+ s.date = %q{2008-09-08}
8
+ s.default_executable = %q{subtitle_it}
9
+ s.description = %q{description of gem}
10
+ s.email = ["x@nofxx.com"]
11
+ s.executables = ["subtitle_it"]
12
+ s.extra_rdoc_files = ["History.txt", "License.txt", "Manifest.txt", "README.txt", "README.markdown"]
13
+ s.files = [".autotest", "History.txt", "License.txt", "Manifest.txt", "README.markdown", "README.txt", "Rakefile", "bin/subtitle_it", "config/hoe.rb", "config/requirements.rb", "lib/subtitle_it.rb", "lib/subtitle_it/formats/ass.rb", "lib/subtitle_it/formats/rsb.rb", "lib/subtitle_it/formats/srt.rb", "lib/subtitle_it/formats/sub.rb", "lib/subtitle_it/formats/xml.rb", "lib/subtitle_it/formats/yml.rb", "lib/subtitle_it/subline.rb", "lib/subtitle_it/subtime.rb", "lib/subtitle_it/subtitle.rb", "lib/subtitle_it/version.rb", "script/console", "script/destroy", "script/generate", "script/txt2html", "setup.rb", "spec/fixtures/godfather.srt", "spec/fixtures/huge.ass", "spec/fixtures/movie.xml", "spec/fixtures/movie.yml", "spec/fixtures/pseudo.rsb", "spec/fixtures/pulpfiction.sub", "spec/fixtures/sincity.yml", "spec/spec.opts", "spec/spec_helper.rb", "spec/subtitle_it/formats/ass_spec.rb", "spec/subtitle_it/formats/rsb_spec.rb", "spec/subtitle_it/formats/srt_spec.rb", "spec/subtitle_it/formats/sub_spec.rb", "spec/subtitle_it/formats/xml_spec.rb", "spec/subtitle_it/formats/yml_spec.rb", "spec/subtitle_it/subline_spec.rb", "spec/subtitle_it/subtime_spec.rb", "spec/subtitle_it/subtitle_spec.rb", "spec/subtitle_it_spec.rb", "subtitle_it.gemspec", "tasks/deployment.rake", "tasks/environment.rake", "tasks/rspec.rake"]
14
+ s.has_rdoc = true
15
+ s.homepage = %q{http://github.com/nofxx/subtitle_it}
16
+ s.post_install_message = %q{
17
+ For more information on subtitle_it, see http://github.com/nofxx/subtitle_it
18
+
19
+ }
20
+ s.rdoc_options = ["--main", "README.txt"]
21
+ s.require_paths = ["lib"]
22
+ s.rubyforge_project = %q{subtitle_it}
23
+ s.rubygems_version = %q{1.2.0}
24
+
25
+ s.summary = %q{Ruby tool to work with subtitle files}
26
+
27
+ s.add_dependency(%q<hpricot>, [">= 0.6"])
28
+
29
+ if s.respond_to? :specification_version then
30
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
31
+ s.specification_version = 2
32
+
33
+ if current_version >= 3 then
34
+ s.add_development_dependency(%q<hoe>, [">= 1.7.0"])
35
+ else
36
+ s.add_dependency(%q<hoe>, [">= 1.7.0"])
37
+ end
38
+ else
39
+ s.add_dependency(%q<hoe>, [">= 1.7.0"])
40
+ end
41
+ end
@@ -0,0 +1,34 @@
1
+ desc 'Release the website and new gem version'
2
+ task :deploy => [:check_version, :website, :release] do
3
+ puts "Remember to create SVN tag:"
4
+ puts "svn copy svn+ssh://#{rubyforge_username}@rubyforge.org/var/svn/#{PATH}/trunk " +
5
+ "svn+ssh://#{rubyforge_username}@rubyforge.org/var/svn/#{PATH}/tags/REL-#{VERS} "
6
+ puts "Suggested comment:"
7
+ puts "Tagging release #{CHANGES}"
8
+ end
9
+
10
+ desc 'Runs tasks website_generate and install_gem as a local deployment of the gem'
11
+ task :local_deploy => [:website_generate, :install_gem]
12
+
13
+ task :check_version do
14
+ unless ENV['VERSION']
15
+ puts 'Must pass a VERSION=x.y.z release version'
16
+ exit
17
+ end
18
+ unless ENV['VERSION'] == VERS
19
+ puts "Please update your version.rb to match the release version, currently #{VERS}"
20
+ exit
21
+ end
22
+ end
23
+
24
+ desc 'Install the package as a gem, without generating documentation(ri/rdoc)'
25
+ task :install_gem_no_doc => [:clean, :package] do
26
+ sh "#{'sudo ' unless Hoe::WINDOZE }gem install pkg/*.gem --no-rdoc --no-ri"
27
+ end
28
+
29
+ namespace :manifest do
30
+ desc 'Recreate Manifest.txt to include ALL files'
31
+ task :refresh do
32
+ `rake check_manifest | patch -p0 > Manifest.txt`
33
+ end
34
+ end