subtitle_it 0.7.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. data/.autotest +19 -0
  2. data/History.txt +53 -0
  3. data/License.txt +20 -0
  4. data/Manifest.txt +68 -0
  5. data/README.markdown +41 -0
  6. data/README.txt +102 -0
  7. data/Rakefile +4 -0
  8. data/bin/subtitle_it +66 -0
  9. data/config/hoe.rb +73 -0
  10. data/config/requirements.rb +15 -0
  11. data/lib/subtitle_it/bin.rb +132 -0
  12. data/lib/subtitle_it/fixes.rb +12 -0
  13. data/lib/subtitle_it/formats/ass.rb +13 -0
  14. data/lib/subtitle_it/formats/mpl.rb +29 -0
  15. data/lib/subtitle_it/formats/rsb.rb +37 -0
  16. data/lib/subtitle_it/formats/srt.rb +45 -0
  17. data/lib/subtitle_it/formats/sub.rb +49 -0
  18. data/lib/subtitle_it/formats/xml.rb +65 -0
  19. data/lib/subtitle_it/formats/yml.rb +18 -0
  20. data/lib/subtitle_it/generator.rb +15 -0
  21. data/lib/subtitle_it/languages.rb +60 -0
  22. data/lib/subtitle_it/movie.rb +24 -0
  23. data/lib/subtitle_it/movie_hasher.rb +30 -0
  24. data/lib/subtitle_it/platform_endl.rb +9 -0
  25. data/lib/subtitle_it/subdown.rb +107 -0
  26. data/lib/subtitle_it/subline.rb +25 -0
  27. data/lib/subtitle_it/substyle.rb +11 -0
  28. data/lib/subtitle_it/subtime.rb +41 -0
  29. data/lib/subtitle_it/subtitle.rb +76 -0
  30. data/lib/subtitle_it/version.rb +9 -0
  31. data/lib/subtitle_it.rb +22 -0
  32. data/script/console +10 -0
  33. data/script/destroy +14 -0
  34. data/script/generate +14 -0
  35. data/script/txt2html +82 -0
  36. data/setup.rb +1585 -0
  37. data/spec/fixtures/godfather.srt +2487 -0
  38. data/spec/fixtures/huge.ass +22 -0
  39. data/spec/fixtures/movie.xml +28 -0
  40. data/spec/fixtures/movie.yml +163 -0
  41. data/spec/fixtures/pseudo.rsb +6 -0
  42. data/spec/fixtures/pulpfiction.sub +2025 -0
  43. data/spec/fixtures/puplfiction.mpl +12 -0
  44. data/spec/fixtures/sincity.yml +12 -0
  45. data/spec/spec.opts +1 -0
  46. data/spec/spec_helper.rb +71 -0
  47. data/spec/subtitle_it/bin_spec.rb +142 -0
  48. data/spec/subtitle_it/fixes_spec.rb +0 -0
  49. data/spec/subtitle_it/formats/ass_spec.rb +5 -0
  50. data/spec/subtitle_it/formats/mpl_spec.rb +45 -0
  51. data/spec/subtitle_it/formats/rsb_spec.rb +42 -0
  52. data/spec/subtitle_it/formats/srt_spec.rb +57 -0
  53. data/spec/subtitle_it/formats/sub_spec.rb +49 -0
  54. data/spec/subtitle_it/formats/xml_spec.rb +60 -0
  55. data/spec/subtitle_it/formats/yml_spec.rb +20 -0
  56. data/spec/subtitle_it/generator_spec.rb +0 -0
  57. data/spec/subtitle_it/movie_hasher_spec.rb +13 -0
  58. data/spec/subtitle_it/movie_spec.rb +25 -0
  59. data/spec/subtitle_it/subdown_spec.rb +94 -0
  60. data/spec/subtitle_it/subline_spec.rb +30 -0
  61. data/spec/subtitle_it/substyle_spec.rb +1 -0
  62. data/spec/subtitle_it/subtime_spec.rb +73 -0
  63. data/spec/subtitle_it/subtitle_spec.rb +40 -0
  64. data/spec/subtitle_it_spec.rb +11 -0
  65. data/subtitle_it.gemspec +41 -0
  66. data/tasks/deployment.rake +34 -0
  67. data/tasks/environment.rake +7 -0
  68. data/tasks/rspec.rake +21 -0
  69. metadata +152 -0
@@ -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.time_on.sec.should eql(2)
14
+ @sub.time_on.min.should eql(20)
15
+ @sub.time_on.sec.should eql(2)
16
+ end
17
+
18
+ it "should have the seconds added from the first time" do
19
+ @sub.time_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 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
@@ -0,0 +1,73 @@
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, minutes and seconds" do
9
+ @subtime.hrs.should eql(1)
10
+ @subtime.min.should eql(2)
11
+ @subtime.sec.should eql(3)
12
+ @subtime.ms.should eql(400)
13
+ end
14
+
15
+ it "should reduce the deciseconds" do
16
+ 800.reduce.should eql(8)
17
+ end
18
+
19
+ it "should print nicely as string" do
20
+ @subtime.to_s.should eql("01:02:03.400")
21
+ end
22
+
23
+ it "should become a integer" do
24
+ @subtime.to_i.should eql(3723400)
25
+ end
26
+ end
27
+
28
+ describe "and the other way around" do
29
+ it "should print nicely" do
30
+ @subtime = Subtime.new(3723400)
31
+ @subtime.to_s.should eql('01:02:03.400')
32
+ end
33
+ end
34
+
35
+ describe Subtime,"Stress Test (heh)" do
36
+ it "should convert a big time" do
37
+ @subtime = Subtime.new('11:22:33.742')
38
+ @subtime.hrs.should eql(11)
39
+ @subtime.min.should eql(22)
40
+ @subtime.sec.should eql(33)
41
+ @subtime.ms.should eql(742)
42
+ end
43
+
44
+ it "should print nicely" do
45
+ @subtime = Subtime.new('11:22:33.7')
46
+ @subtime.to_s.should eql("11:22:33.700")
47
+ end
48
+
49
+ describe ".other formats" do
50
+
51
+ it "should parse min:sec.ms" do
52
+ @subtime = Subtime.new('01:03.4')
53
+ end
54
+
55
+ it "should parse min:sec,ms" do
56
+ @subtime = Subtime.new('01:03,3')
57
+ end
58
+
59
+ it "should single as seconds hour should be nil" do
60
+ @subtime = Subtime.new('3')
61
+ @subtime.hrs.should eql(0)
62
+ end
63
+
64
+ it "should parse min:sec" do
65
+ @subtime = Subtime.new('01:03')
66
+ @subtime.min.should eql(1)
67
+ end
68
+
69
+ after(:each) do
70
+ @subtime.sec.should eql(3)
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,40 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ describe Subtitle do
4
+ def attr_valid_subtitle
5
+ { :info => {
6
+ "SubLanguageID" => 'eng',
7
+ "MovieName" => 'Resevoir Dogs',
8
+ "MovieYear" => '1992',
9
+ "SubFileName" => 'Cool sub',
10
+ "MovieImdbRating" => '10.0',
11
+ "SubDownloadsCnt" => '310',
12
+ "SubRating" => '9.5',
13
+ "SubFormat" => 'srt',
14
+ "SubSumCD" => '2',
15
+ "SubAuthorComment" => 'Nice nice...'
16
+ }}
17
+ end
18
+
19
+ it "should instantiate" do
20
+ @sub = Subtitle.new(attr_valid_subtitle)
21
+ @sub.rating.should eql(9.5)
22
+ end
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
+
30
+ describe "Compare" do
31
+ before(:each) do
32
+ @sub = Subtitle.new(attr_valid_subtitle)
33
+ end
34
+
35
+ it "should compare to another using rating" do
36
+ @another_sub = Subtitle.new(attr_valid_subtitle.with(:info => { "SubRating" => 4.0} ))
37
+ (@sub > @another_sub).should be_true
38
+ end
39
+ end
40
+ end
@@ -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({:dump => "{12}{30}hey hey heypending", :format => "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.7.7"
4
+
5
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
6
+ s.authors = ["Marcos Piccinini", "Warlley Rezende", "Giovanni Rapagnani"]
7
+ s.date = %q{2008-09-20}
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/bin.rb", "lib/subtitle_it/fixes.rb", "lib/subtitle_it/formats/ass.rb", "lib/subtitle_it/formats/mpl.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/generator.rb", "lib/subtitle_it/languages.rb", "lib/subtitle_it/movie.rb", "lib/subtitle_it/movie_hasher.rb", "lib/subtitle_it/platform_endl.rb", "lib/subtitle_it/subdown.rb", "lib/subtitle_it/subline.rb", "lib/subtitle_it/substyle.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/puplfiction.mpl", "spec/fixtures/sincity.yml", "spec/spec.opts", "spec/spec_helper.rb", "spec/subtitle_it/bin_spec.rb", "spec/subtitle_it/fixes_spec.rb", "spec/subtitle_it/formats/ass_spec.rb", "spec/subtitle_it/formats/mpl_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/generator_spec.rb", "spec/subtitle_it/movie_hasher_spec.rb", "spec/subtitle_it/movie_spec.rb", "spec/subtitle_it/subdown_spec.rb", "spec/subtitle_it/subline_spec.rb", "spec/subtitle_it/substyle_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
@@ -0,0 +1,7 @@
1
+ task :ruby_env do
2
+ RUBY_APP = if RUBY_PLATFORM =~ /java/
3
+ "jruby"
4
+ else
5
+ "ruby"
6
+ end unless defined? RUBY_APP
7
+ end
data/tasks/rspec.rake ADDED
@@ -0,0 +1,21 @@
1
+ begin
2
+ require 'spec'
3
+ rescue LoadError
4
+ require 'rubygems'
5
+ require 'spec'
6
+ end
7
+ begin
8
+ require 'spec/rake/spectask'
9
+ rescue LoadError
10
+ puts <<-EOS
11
+ To use rspec for testing you must install rspec gem:
12
+ gem install rspec
13
+ EOS
14
+ exit(0)
15
+ end
16
+
17
+ desc "Run the specs under spec/models"
18
+ Spec::Rake::SpecTask.new do |t|
19
+ t.spec_opts = ['--options', "spec/spec.opts"]
20
+ t.spec_files = FileList['spec/**/*_spec.rb']
21
+ end
metadata ADDED
@@ -0,0 +1,152 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: subtitle_it
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.7.7
5
+ platform: ruby
6
+ authors:
7
+ - Marcos Piccinini
8
+ - Warlley Rezende
9
+ - Giovanni Rapagnani
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+
14
+ date: 2008-09-20 00:00:00 -03:00
15
+ default_executable: subtitle_it
16
+ dependencies:
17
+ - !ruby/object:Gem::Dependency
18
+ name: hpricot
19
+ type: :runtime
20
+ version_requirement:
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - ">="
24
+ - !ruby/object:Gem::Version
25
+ version: "0.6"
26
+ version:
27
+ - !ruby/object:Gem::Dependency
28
+ name: hoe
29
+ type: :development
30
+ version_requirement:
31
+ version_requirements: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - ">="
34
+ - !ruby/object:Gem::Version
35
+ version: 1.7.0
36
+ version:
37
+ description: description of gem
38
+ email:
39
+ - x@nofxx.com
40
+ executables:
41
+ - subtitle_it
42
+ extensions: []
43
+
44
+ extra_rdoc_files:
45
+ - History.txt
46
+ - License.txt
47
+ - Manifest.txt
48
+ - README.txt
49
+ - README.markdown
50
+ files:
51
+ - .autotest
52
+ - History.txt
53
+ - License.txt
54
+ - Manifest.txt
55
+ - README.markdown
56
+ - README.txt
57
+ - Rakefile
58
+ - bin/subtitle_it
59
+ - config/hoe.rb
60
+ - config/requirements.rb
61
+ - lib/subtitle_it.rb
62
+ - lib/subtitle_it/bin.rb
63
+ - lib/subtitle_it/fixes.rb
64
+ - lib/subtitle_it/formats/ass.rb
65
+ - lib/subtitle_it/formats/mpl.rb
66
+ - lib/subtitle_it/formats/rsb.rb
67
+ - lib/subtitle_it/formats/srt.rb
68
+ - lib/subtitle_it/formats/sub.rb
69
+ - lib/subtitle_it/formats/xml.rb
70
+ - lib/subtitle_it/formats/yml.rb
71
+ - lib/subtitle_it/generator.rb
72
+ - lib/subtitle_it/languages.rb
73
+ - lib/subtitle_it/movie.rb
74
+ - lib/subtitle_it/movie_hasher.rb
75
+ - lib/subtitle_it/platform_endl.rb
76
+ - lib/subtitle_it/subdown.rb
77
+ - lib/subtitle_it/subline.rb
78
+ - lib/subtitle_it/substyle.rb
79
+ - lib/subtitle_it/subtime.rb
80
+ - lib/subtitle_it/subtitle.rb
81
+ - lib/subtitle_it/version.rb
82
+ - script/console
83
+ - script/destroy
84
+ - script/generate
85
+ - script/txt2html
86
+ - setup.rb
87
+ - spec/fixtures/godfather.srt
88
+ - spec/fixtures/huge.ass
89
+ - spec/fixtures/movie.xml
90
+ - spec/fixtures/movie.yml
91
+ - spec/fixtures/pseudo.rsb
92
+ - spec/fixtures/pulpfiction.sub
93
+ - spec/fixtures/puplfiction.mpl
94
+ - spec/fixtures/sincity.yml
95
+ - spec/spec.opts
96
+ - spec/spec_helper.rb
97
+ - spec/subtitle_it/bin_spec.rb
98
+ - spec/subtitle_it/fixes_spec.rb
99
+ - spec/subtitle_it/formats/ass_spec.rb
100
+ - spec/subtitle_it/formats/mpl_spec.rb
101
+ - spec/subtitle_it/formats/rsb_spec.rb
102
+ - spec/subtitle_it/formats/srt_spec.rb
103
+ - spec/subtitle_it/formats/sub_spec.rb
104
+ - spec/subtitle_it/formats/xml_spec.rb
105
+ - spec/subtitle_it/formats/yml_spec.rb
106
+ - spec/subtitle_it/generator_spec.rb
107
+ - spec/subtitle_it/movie_hasher_spec.rb
108
+ - spec/subtitle_it/movie_spec.rb
109
+ - spec/subtitle_it/subdown_spec.rb
110
+ - spec/subtitle_it/subline_spec.rb
111
+ - spec/subtitle_it/substyle_spec.rb
112
+ - spec/subtitle_it/subtime_spec.rb
113
+ - spec/subtitle_it/subtitle_spec.rb
114
+ - spec/subtitle_it_spec.rb
115
+ - subtitle_it.gemspec
116
+ - tasks/deployment.rake
117
+ - tasks/environment.rake
118
+ - tasks/rspec.rake
119
+ has_rdoc: true
120
+ homepage: http://github.com/nofxx/subtitle_it
121
+ licenses: []
122
+
123
+ post_install_message: |+
124
+
125
+ For more information on subtitle_it, see http://github.com/nofxx/subtitle_it
126
+
127
+ rdoc_options:
128
+ - --main
129
+ - README.txt
130
+ require_paths:
131
+ - lib
132
+ required_ruby_version: !ruby/object:Gem::Requirement
133
+ requirements:
134
+ - - ">="
135
+ - !ruby/object:Gem::Version
136
+ version: "0"
137
+ version:
138
+ required_rubygems_version: !ruby/object:Gem::Requirement
139
+ requirements:
140
+ - - ">="
141
+ - !ruby/object:Gem::Version
142
+ version: "0"
143
+ version:
144
+ requirements: []
145
+
146
+ rubyforge_project: subtitle_it
147
+ rubygems_version: 1.3.5
148
+ signing_key:
149
+ specification_version: 2
150
+ summary: Ruby tool to work with subtitle files
151
+ test_files: []
152
+