encoder-tools 0.0.2 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +12 -23
  3. data/.rspec +3 -0
  4. data/.travis.yml +5 -0
  5. data/CODE_OF_CONDUCT.md +74 -0
  6. data/Gemfile +4 -10
  7. data/Gemfile.lock +37 -83
  8. data/LICENSE +1 -1
  9. data/README.md +14 -0
  10. data/Rakefile +3 -43
  11. data/bin/console +14 -0
  12. data/bin/setup +8 -0
  13. data/encoder-tools.gemspec +28 -0
  14. data/lib/encoder-tools.rb +1 -0
  15. data/lib/encoder-tools/cli.rb +23 -12
  16. data/lib/encoder-tools/cli/subtitles.rb +1 -0
  17. data/lib/encoder-tools/cli/subtitles/base.rb +26 -3
  18. data/lib/encoder-tools/cli/subtitles/fix_lengths.rb +35 -21
  19. data/lib/encoder-tools/cli/subtitles/offset.rb +33 -12
  20. data/lib/encoder-tools/cli/subtitles/renumber.rb +3 -1
  21. data/lib/encoder-tools/cli/subtitles/spell_check.rb +73 -0
  22. data/lib/encoder-tools/subtitles/list.rb +5 -0
  23. data/lib/encoder-tools/subtitles/parser.rb +1 -1
  24. data/lib/encoder-tools/subtitles/subtitle.rb +9 -2
  25. data/lib/encoder-tools/util.rb +5 -0
  26. data/lib/encoder-tools/util/text_reader.rb +26 -0
  27. data/lib/encoder-tools/version.rb +3 -0
  28. metadata +95 -96
  29. data/README.rdoc +0 -17
  30. data/VERSION +0 -1
  31. data/spec/cli/subtitles/fix_lengths_spec.rb +0 -51
  32. data/spec/cli/subtitles/offset_spec.rb +0 -40
  33. data/spec/cli/subtitles/renumber_spec.rb +0 -23
  34. data/spec/fixtures/subtitles/adjusted-long-subtitles.srt +0 -16
  35. data/spec/fixtures/subtitles/bad-numbering-corrected.srt +0 -16
  36. data/spec/fixtures/subtitles/bad-numbering.srt +0 -16
  37. data/spec/fixtures/subtitles/kill-bill-vol-2.srt +0 -345
  38. data/spec/fixtures/subtitles/no-long-subtitles.srt +0 -16
  39. data/spec/fixtures/subtitles/short-example-offset-2.srt +0 -16
  40. data/spec/fixtures/subtitles/short-example-offset-minus-2.srt +0 -16
  41. data/spec/fixtures/subtitles/short-example-offset-plus-2.srt +0 -16
  42. data/spec/fixtures/subtitles/short-example.srt +0 -16
  43. data/spec/fixtures/subtitles/some-long-subtitles.srt +0 -16
  44. data/spec/options/title_spec.rb +0 -41
  45. data/spec/spec.opts +0 -2
  46. data/spec/spec_helper.rb +0 -31
  47. data/spec/strategies/movie_spec.rb +0 -23
  48. data/spec/subtitles/list_spec.rb +0 -57
  49. data/spec/subtitles/subtitle_spec.rb +0 -31
@@ -1,16 +0,0 @@
1
- 1
2
- 00:45:16,000 --> 00:45:17,145
3
- Master...
4
-
5
- 2
6
- 00:45:18,815 --> 00:45:20,440
7
- Your Mandarin is lousy.
8
-
9
- 3
10
- 00:45:21,373 --> 00:45:22,681
11
- It causes my ears discomfort.
12
-
13
- 4
14
- 00:45:22,748 --> 00:45:24,274
15
- You bray like an ass!
16
-
@@ -1,16 +0,0 @@
1
- 1
2
- 00:00:02,000 --> 00:00:03,145
3
- Master...
4
-
5
- 2
6
- 00:00:04,815 --> 00:00:06,440
7
- Your Mandarin is lousy.
8
-
9
- 3
10
- 00:00:07,373 --> 00:00:08,681
11
- It causes my ears discomfort.
12
-
13
- 4
14
- 00:00:08,748 --> 00:00:10,274
15
- You bray like an ass!
16
-
@@ -1,16 +0,0 @@
1
- 1
2
- 00:45:14,000 --> 00:45:15,145
3
- Master...
4
-
5
- 2
6
- 00:45:16,815 --> 00:45:18,440
7
- Your Mandarin is lousy.
8
-
9
- 3
10
- 00:45:19,373 --> 00:45:20,681
11
- It causes my ears discomfort.
12
-
13
- 4
14
- 00:45:20,748 --> 00:45:22,274
15
- You bray like an ass!
16
-
@@ -1,16 +0,0 @@
1
- 1
2
- 00:45:18,000 --> 00:45:19,145
3
- Master...
4
-
5
- 2
6
- 00:45:20,815 --> 00:45:22,440
7
- Your Mandarin is lousy.
8
-
9
- 3
10
- 00:45:23,373 --> 00:45:24,681
11
- It causes my ears discomfort.
12
-
13
- 4
14
- 00:45:24,748 --> 00:45:26,274
15
- You bray like an ass!
16
-
@@ -1,16 +0,0 @@
1
- 1
2
- 00:45:16,000 --> 00:45:17,145
3
- Master...
4
-
5
- 2
6
- 00:45:18,815 --> 00:45:20,440
7
- Your Mandarin is lousy.
8
-
9
- 3
10
- 00:45:21,373 --> 00:45:22,681
11
- It causes my ears discomfort.
12
-
13
- 4
14
- 00:45:22,748 --> 00:45:24,274
15
- You bray like an ass!
16
-
@@ -1,16 +0,0 @@
1
- 1
2
- 00:45:16,000 --> 00:45:17,145
3
- Master...
4
-
5
- 2
6
- 00:45:18,815 --> 00:45:20,440
7
- Your Mandarin is lousy.
8
-
9
- 3
10
- 00:45:21,373 --> 01:45:22,681
11
- It causes my ears discomfort.
12
-
13
- 4
14
- 01:45:22,748 --> 02:45:24,274
15
- You bray like an ass!
16
-
@@ -1,41 +0,0 @@
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 DELETED
@@ -1,2 +0,0 @@
1
- --color
2
- --format=specdoc
data/spec/spec_helper.rb DELETED
@@ -1,31 +0,0 @@
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
@@ -1,23 +0,0 @@
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
@@ -1,57 +0,0 @@
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
@@ -1,31 +0,0 @@
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