encoder-tools 0.0.2

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 (48) hide show
  1. data/.document +5 -0
  2. data/.gitignore +23 -0
  3. data/Gemfile +12 -0
  4. data/Gemfile.lock +83 -0
  5. data/LICENSE +20 -0
  6. data/README.rdoc +17 -0
  7. data/Rakefile +46 -0
  8. data/VERSION +1 -0
  9. data/bin/encoder-tools +4 -0
  10. data/lib/encoder-tools/cli/base.rb +40 -0
  11. data/lib/encoder-tools/cli/subtitles/base.rb +15 -0
  12. data/lib/encoder-tools/cli/subtitles/fix_lengths.rb +46 -0
  13. data/lib/encoder-tools/cli/subtitles/offset.rb +30 -0
  14. data/lib/encoder-tools/cli/subtitles/renumber.rb +11 -0
  15. data/lib/encoder-tools/cli/subtitles.rb +10 -0
  16. data/lib/encoder-tools/cli.rb +30 -0
  17. data/lib/encoder-tools/options/title.rb +34 -0
  18. data/lib/encoder-tools/options.rb +5 -0
  19. data/lib/encoder-tools/strategies/base.rb +22 -0
  20. data/lib/encoder-tools/strategies/movie.rb +10 -0
  21. data/lib/encoder-tools/strategies/tv.rb +10 -0
  22. data/lib/encoder-tools/strategies.rb +7 -0
  23. data/lib/encoder-tools/subtitles/list.rb +35 -0
  24. data/lib/encoder-tools/subtitles/parser.rb +96 -0
  25. data/lib/encoder-tools/subtitles/relaxed_parser.rb +11 -0
  26. data/lib/encoder-tools/subtitles/subtitle.rb +47 -0
  27. data/lib/encoder-tools/subtitles.rb +8 -0
  28. data/lib/encoder-tools.rb +7 -0
  29. data/spec/cli/subtitles/fix_lengths_spec.rb +51 -0
  30. data/spec/cli/subtitles/offset_spec.rb +40 -0
  31. data/spec/cli/subtitles/renumber_spec.rb +23 -0
  32. data/spec/fixtures/subtitles/adjusted-long-subtitles.srt +16 -0
  33. data/spec/fixtures/subtitles/bad-numbering-corrected.srt +16 -0
  34. data/spec/fixtures/subtitles/bad-numbering.srt +16 -0
  35. data/spec/fixtures/subtitles/kill-bill-vol-2.srt +345 -0
  36. data/spec/fixtures/subtitles/no-long-subtitles.srt +16 -0
  37. data/spec/fixtures/subtitles/short-example-offset-2.srt +16 -0
  38. data/spec/fixtures/subtitles/short-example-offset-minus-2.srt +16 -0
  39. data/spec/fixtures/subtitles/short-example-offset-plus-2.srt +16 -0
  40. data/spec/fixtures/subtitles/short-example.srt +16 -0
  41. data/spec/fixtures/subtitles/some-long-subtitles.srt +16 -0
  42. data/spec/options/title_spec.rb +41 -0
  43. data/spec/spec.opts +2 -0
  44. data/spec/spec_helper.rb +31 -0
  45. data/spec/strategies/movie_spec.rb +23 -0
  46. data/spec/subtitles/list_spec.rb +57 -0
  47. data/spec/subtitles/subtitle_spec.rb +31 -0
  48. metadata +138 -0
@@ -0,0 +1,41 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ describe EncoderTools::Options::Title do
4
+ subject { described_class.new(1) }
5
+
6
+ it "initializes with an integer as the title number" do
7
+ subject.number.should == 1
8
+ end
9
+
10
+ it "converts to Handbrake arguments" do
11
+ subject.to_args.should == %w[--title 1]
12
+ end
13
+
14
+ it "equals another Title with the same number" do
15
+ subject.should == described_class.new(1)
16
+ end
17
+
18
+ it "does not equal another Title with a different number" do
19
+ subject.should_not == described_class.new(2)
20
+ end
21
+
22
+ describe EncoderTools::Options::Title::LONGEST do
23
+ subject { EncoderTools::Options::Title::LONGEST }
24
+
25
+ it "is a Title" do
26
+ subject.should be_a(EncoderTools::Options::Title)
27
+ end
28
+
29
+ it "has no title number" do
30
+ subject.number.should == nil
31
+ end
32
+
33
+ it "converts to Handbrake arguments" do
34
+ subject.to_args.should == %w[--longest]
35
+ end
36
+
37
+ it "does not equal a Title with a specific number" do
38
+ subject.should_not == described_class.new(1)
39
+ end
40
+ end
41
+ end
data/spec/spec.opts ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format=specdoc
@@ -0,0 +1,31 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+ require 'encoder-tools'
4
+ require 'spec'
5
+ require 'spec/autorun'
6
+
7
+ Spec::Runner.configure do |config|
8
+ def subtitle(range, text)
9
+ EncoderTools::Subtitles::Subtitle.new(range, text)
10
+ end
11
+
12
+ def subfile(name)
13
+ File.read(File.dirname(__FILE__) + "/fixtures/subtitles/#{name}.srt")
14
+ end
15
+
16
+ shared_examples_for 'a CLI command' do
17
+ attr_reader :input, :output, :options, :shell
18
+
19
+ before do
20
+ @input = StringIO.new
21
+ @output = StringIO.new
22
+ @options = {:input => @input, :output => @output}
23
+ end
24
+
25
+ def stub_shell!
26
+ @shell = stub('shell')
27
+ end
28
+
29
+ subject { described_class.new(@shell, @options) }
30
+ end
31
+ end
@@ -0,0 +1,23 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ describe EncoderTools::Strategies::Movie do
4
+ subject { described_class.new("fixtures/Batman.dvdmedia") }
5
+
6
+ it "has an input_path attribute reader" do
7
+ subject.input_path.should == "fixtures/Batman.dvdmedia"
8
+ end
9
+
10
+ it "has a title attribute accessor defaulting to longest title" do
11
+ subject.title.should == EncoderTools::Options::Title::LONGEST
12
+ end
13
+
14
+ it "accepts a number as a title and converts it to a Title option" do
15
+ subject.title = 1
16
+ subject.title.should == EncoderTools::Options::Title.new(1)
17
+ end
18
+
19
+ it "raises when setting an invalid title" do
20
+ lambda { subject.title = 'foo' }.
21
+ should raise_error(ArgumentError, %{expected an EncoderTools::Options::Title or Fixnum, got "foo"})
22
+ end
23
+ end
@@ -0,0 +1,57 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe EncoderTools::Subtitles::List do
4
+ before :all do
5
+ @kill_bill = subfile('kill-bill-vol-2')
6
+ @first_sub = subtitle(2716..2717.145, "Master...")
7
+ @last_sub = subtitle(4518..4520.300, "I - give - you - my - word...")
8
+ end
9
+
10
+ it "can load subtitles from a string" do
11
+ list = described_class.load(@kill_bill).entries
12
+ list.first.should == @first_sub
13
+ list.last.should == @last_sub
14
+ end
15
+
16
+ it "loads all the subtitles" do
17
+ described_class.load(@kill_bill).should have(81).entries
18
+ end
19
+
20
+ it "has offset equal to the offset of the first subtitle" do
21
+ described_class.load(@kill_bill).offset.should == 2716
22
+ end
23
+
24
+ context "with no subtitles" do
25
+ subject { described_class.load("") }
26
+
27
+ it "has offset 0" do
28
+ subject.offset.should == 0
29
+ end
30
+
31
+ it "ignores setting the offset" do
32
+ lambda { subject.offset += 2 }.
33
+ should_not change { subject.offset }.from(0)
34
+ end
35
+ end
36
+
37
+ it "allows adjusting the offsets of all subtitles by setting an offset" do
38
+ list = described_class.load(@kill_bill)
39
+ list.offset += 1
40
+ list.entries.first.should == subtitle(2717..2718.145, "Master...")
41
+ list.entries.last.should == subtitle(4519..4521.300, "I - give - you - my - word...")
42
+ end
43
+
44
+ it "represents itself as a string suitable for use in a subtitle file" do
45
+ subject.entries = [subtitle(0..1, "Hello World"), subtitle(1..2, "It's good to see you")]
46
+ subject.to_s.should == <<-EOS
47
+ 1
48
+ 00:00:00,000 --> 00:00:01,000
49
+ Hello World
50
+
51
+ 2
52
+ 00:00:01,000 --> 00:00:02,000
53
+ It's good to see you
54
+
55
+ EOS
56
+ end
57
+ end
@@ -0,0 +1,31 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe EncoderTools::Subtitles::Subtitle do
4
+ subject { described_class.new(1.5..2, "Hello World") }
5
+
6
+ it "has a range" do
7
+ subject.range.should == (1.5..2)
8
+ end
9
+
10
+ it "has text" do
11
+ subject.text.should == "Hello World"
12
+ end
13
+
14
+ it "has offset equal to the start of the range" do
15
+ subject.offset.should == 1.5
16
+ end
17
+
18
+ it "allows adjusting the range by setting the offset" do
19
+ subject.offset = 2
20
+ subject.range.should == (2..2.5)
21
+ end
22
+
23
+ it "represents itself as a string with the timestamp range and text" do
24
+ subject.to_s.should == %{00:00:01,500 --> 00:00:02,000\nHello World}
25
+ end
26
+
27
+ it "allows adjusting the end of the range by setting the duration" do
28
+ subject.duration = 2
29
+ subject.range.should == (1.5..3.5)
30
+ end
31
+ end
metadata ADDED
@@ -0,0 +1,138 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: encoder-tools
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Brian Donovan
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2010-02-14 00:00:00 -08:00
13
+ default_executable: encoder-tools
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: thor
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: rspec
27
+ type: :development
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 1.2.9
34
+ version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: yard
37
+ type: :development
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: "0"
44
+ version:
45
+ description: Tools for ripping, encoding, and subtitling movies and TV shows
46
+ email: brian.donovan@gmail.com
47
+ executables:
48
+ - encoder-tools
49
+ extensions: []
50
+
51
+ extra_rdoc_files:
52
+ - LICENSE
53
+ - README.rdoc
54
+ files:
55
+ - .document
56
+ - .gitignore
57
+ - Gemfile
58
+ - Gemfile.lock
59
+ - LICENSE
60
+ - README.rdoc
61
+ - Rakefile
62
+ - VERSION
63
+ - bin/encoder-tools
64
+ - lib/encoder-tools.rb
65
+ - lib/encoder-tools/cli.rb
66
+ - lib/encoder-tools/cli/base.rb
67
+ - lib/encoder-tools/cli/subtitles.rb
68
+ - lib/encoder-tools/cli/subtitles/base.rb
69
+ - lib/encoder-tools/cli/subtitles/fix_lengths.rb
70
+ - lib/encoder-tools/cli/subtitles/offset.rb
71
+ - lib/encoder-tools/cli/subtitles/renumber.rb
72
+ - lib/encoder-tools/options.rb
73
+ - lib/encoder-tools/options/title.rb
74
+ - lib/encoder-tools/strategies.rb
75
+ - lib/encoder-tools/strategies/base.rb
76
+ - lib/encoder-tools/strategies/movie.rb
77
+ - lib/encoder-tools/strategies/tv.rb
78
+ - lib/encoder-tools/subtitles.rb
79
+ - lib/encoder-tools/subtitles/list.rb
80
+ - lib/encoder-tools/subtitles/parser.rb
81
+ - lib/encoder-tools/subtitles/relaxed_parser.rb
82
+ - lib/encoder-tools/subtitles/subtitle.rb
83
+ - spec/cli/subtitles/fix_lengths_spec.rb
84
+ - spec/cli/subtitles/offset_spec.rb
85
+ - spec/cli/subtitles/renumber_spec.rb
86
+ - spec/fixtures/subtitles/adjusted-long-subtitles.srt
87
+ - spec/fixtures/subtitles/bad-numbering-corrected.srt
88
+ - spec/fixtures/subtitles/bad-numbering.srt
89
+ - spec/fixtures/subtitles/kill-bill-vol-2.srt
90
+ - spec/fixtures/subtitles/no-long-subtitles.srt
91
+ - spec/fixtures/subtitles/short-example-offset-2.srt
92
+ - spec/fixtures/subtitles/short-example-offset-minus-2.srt
93
+ - spec/fixtures/subtitles/short-example-offset-plus-2.srt
94
+ - spec/fixtures/subtitles/short-example.srt
95
+ - spec/fixtures/subtitles/some-long-subtitles.srt
96
+ - spec/options/title_spec.rb
97
+ - spec/spec.opts
98
+ - spec/spec_helper.rb
99
+ - spec/strategies/movie_spec.rb
100
+ - spec/subtitles/list_spec.rb
101
+ - spec/subtitles/subtitle_spec.rb
102
+ has_rdoc: true
103
+ homepage: http://github.com/eventualbuddha/encoder-tools
104
+ licenses: []
105
+
106
+ post_install_message:
107
+ rdoc_options:
108
+ - --charset=UTF-8
109
+ require_paths:
110
+ - lib
111
+ required_ruby_version: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - ">="
114
+ - !ruby/object:Gem::Version
115
+ version: "0"
116
+ version:
117
+ required_rubygems_version: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - ">="
120
+ - !ruby/object:Gem::Version
121
+ version: "0"
122
+ version:
123
+ requirements: []
124
+
125
+ rubyforge_project:
126
+ rubygems_version: 1.3.5
127
+ signing_key:
128
+ specification_version: 3
129
+ summary: Some tools to make encoding from DVDs easier
130
+ test_files:
131
+ - spec/cli/subtitles/fix_lengths_spec.rb
132
+ - spec/cli/subtitles/offset_spec.rb
133
+ - spec/cli/subtitles/renumber_spec.rb
134
+ - spec/options/title_spec.rb
135
+ - spec/spec_helper.rb
136
+ - spec/strategies/movie_spec.rb
137
+ - spec/subtitles/list_spec.rb
138
+ - spec/subtitles/subtitle_spec.rb