rakemkv 0.2.0
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.
- checksums.yaml +7 -0
- data/.gitignore +20 -0
- data/.travis.yml +5 -0
- data/Gemfile +3 -0
- data/Guardfile +8 -0
- data/LICENSE.txt +22 -0
- data/README.md +51 -0
- data/Rakefile +5 -0
- data/lib/rakemkv/code.rb +62 -0
- data/lib/rakemkv/command.rb +35 -0
- data/lib/rakemkv/command_builder.rb +19 -0
- data/lib/rakemkv/configuration.rb +20 -0
- data/lib/rakemkv/disc.rb +64 -0
- data/lib/rakemkv/parser.rb +85 -0
- data/lib/rakemkv/title.rb +40 -0
- data/lib/rakemkv/titles.rb +22 -0
- data/lib/rakemkv/version.rb +3 -0
- data/lib/rakemkv.rb +20 -0
- data/rakemkv.gemspec +25 -0
- data/spec/fixtures/movie.iso +0 -0
- data/spec/integration/transcodes_disc_spec.rb +17 -0
- data/spec/lib/rakemkv/code_spec.rb +21 -0
- data/spec/lib/rakemkv/command_builder_spec.rb +15 -0
- data/spec/lib/rakemkv/command_spec.rb +33 -0
- data/spec/lib/rakemkv/configuration_spec.rb +47 -0
- data/spec/lib/rakemkv/disc_spec.rb +63 -0
- data/spec/lib/rakemkv/parser_spec.rb +45 -0
- data/spec/lib/rakemkv/title_spec.rb +48 -0
- data/spec/lib/rakemkv/titles_spec.rb +22 -0
- data/spec/lib/rakemkv_spec.rb +10 -0
- data/spec/spec_helper.rb +20 -0
- data/spec/support/rakemkvmock.rb +579 -0
- metadata +159 -0
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe RakeMKV::Disc do
|
4
|
+
before do
|
5
|
+
allow_any_instance_of(RakeMKV::Command)
|
6
|
+
.to receive(:info) { RakeMKVMock.info }
|
7
|
+
end
|
8
|
+
|
9
|
+
describe '#path' do
|
10
|
+
it 'accepts the device path' do
|
11
|
+
RakeMKV::Disc.new('/dev/sd0').path.should eq 'dev:/dev/sd0'
|
12
|
+
end
|
13
|
+
it 'accepts the file iso path' do
|
14
|
+
RakeMKV::Disc.new('path_to.iso').path.should eq 'iso:path_to.iso'
|
15
|
+
end
|
16
|
+
it 'accepts disc parameter' do
|
17
|
+
RakeMKV::Disc.new('disc:0').path.should eq 'disc:0'
|
18
|
+
end
|
19
|
+
it 'accepts an integer for the path' do
|
20
|
+
RakeMKV::Disc.new(0).path.should eq 'disc:0'
|
21
|
+
end
|
22
|
+
it 'raises an error when not a valid path' do
|
23
|
+
expect { RakeMKV::Disc.new('bork').path }.to raise_error
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe '#transcode!' do
|
28
|
+
subject(:disc) { RakeMKV::Disc.new('disc:0') }
|
29
|
+
let(:title) { double(RakeMKV::Title, id: 0) }
|
30
|
+
before do
|
31
|
+
File.stub(:directory?).and_return true
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'converts only a specific title' do
|
35
|
+
expect_any_instance_of(RakeMKV::Command).to receive(:mkv)
|
36
|
+
.with(1, Dir.pwd)
|
37
|
+
|
38
|
+
disc.transcode!(title_id: 1)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe '#name' do
|
43
|
+
subject(:disc) { RakeMKV::Disc.new('disc:0') }
|
44
|
+
it 'grabs the name of the disc' do
|
45
|
+
expect(disc.name).to eq 'DIME_NTSC'
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe '#titles' do
|
50
|
+
it 'builds a places to hold titles' do
|
51
|
+
disc = RakeMKV::Disc.new('disc:0')
|
52
|
+
|
53
|
+
expect(disc.titles).to be_a_kind_of(RakeMKV::Titles)
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'returns a list of titles' do
|
57
|
+
disc = RakeMKV::Disc.new('disc:0')
|
58
|
+
RakeMKV::Title.stub(:new).and_return('new_title')
|
59
|
+
|
60
|
+
expect(disc.titles).to include 'new_title'
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe RakeMKV::Parser do
|
4
|
+
let(:parse) { RakeMKV::Parser.new(RakeMKVMock.info) }
|
5
|
+
describe '#new' do
|
6
|
+
it 'sets the raw info' do
|
7
|
+
parse = RakeMKV::Parser.new('anything')
|
8
|
+
expect(parse.raw).to eq 'anything'
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe '#cinfo' do
|
13
|
+
it 'parses information for cinfo' do
|
14
|
+
expect(parse.cinfo[:name]).to eq 'DIME_NTSC'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '#tinfo' do
|
19
|
+
it 'parses title information' do
|
20
|
+
expect(parse.tinfo[0][:chapter_count]).to eq '24'
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe '#sinfo' do
|
25
|
+
it 'parses title information' do
|
26
|
+
expect(parse.sinfo[0][1][:audio_sample_rate]).to eq '48000'
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe '#messages' do
|
31
|
+
it 'parses messages information' do
|
32
|
+
expect(parse.messages[0]).to eq 'MakeMKV v1.8.3 linux(x64-release) started'
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe '#drives' do
|
37
|
+
it 'parses drives information' do
|
38
|
+
drive = { accessible: true,
|
39
|
+
drive_name: 'DVD+R-DL MATSHITA DVD-RAM UJ8C2 SB01',
|
40
|
+
disc_name: 'DIME_NTSC',
|
41
|
+
location: '/dev/sr0' }
|
42
|
+
expect(parse.drives).to include(drive)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe RakeMKV::Title do
|
4
|
+
let(:title_info) do
|
5
|
+
Hash[chapter_count: '24', duration: '1:10:22', disk_size_bytes: '4958869504']
|
6
|
+
end
|
7
|
+
describe '#initialize' do
|
8
|
+
context 'title id' do
|
9
|
+
it 'accepts title id' do
|
10
|
+
expect(RakeMKV::Title.new(0, title_info).id).to eq 0
|
11
|
+
end
|
12
|
+
end
|
13
|
+
context 'time in seconds' do
|
14
|
+
it 'converts time to seconds' do
|
15
|
+
expect(RakeMKV::Title.new(1, title_info).time).to eq 4222
|
16
|
+
end
|
17
|
+
it 'accepts integer seconds' do
|
18
|
+
title_info[:duration] = 122
|
19
|
+
expect(RakeMKV::Title.new(1, title_info).time).to eq 122
|
20
|
+
end
|
21
|
+
end
|
22
|
+
context 'chapter count' do
|
23
|
+
it 'accepts cells' do
|
24
|
+
expect(RakeMKV::Title.new(1, title_info).chapter_count).to eq 24
|
25
|
+
end
|
26
|
+
end
|
27
|
+
context 'size' do
|
28
|
+
it 'accepts disk size in bytes' do
|
29
|
+
expect(RakeMKV::Title.new(1, title_info).size).to eq 4_958_869_504
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe '#short_length?' do
|
35
|
+
it 'is true for the goldie locks zone' do
|
36
|
+
expect(RakeMKV::Title.new('1', duration: '0:16:00'))
|
37
|
+
.to be_short_length
|
38
|
+
expect(RakeMKV::Title.new('1', duration: '0:34:00'))
|
39
|
+
.to be_short_length
|
40
|
+
end
|
41
|
+
it 'is false at any other time' do
|
42
|
+
expect(RakeMKV::Title.new('1', duration: '0:15:00'))
|
43
|
+
.to_not be_short_length
|
44
|
+
expect(RakeMKV::Title.new('1', duration: '0:35:00'))
|
45
|
+
.to_not be_short_length
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe RakeMKV::Titles do
|
4
|
+
|
5
|
+
describe '#at_id' do
|
6
|
+
it 'finds titles by id but not place' do
|
7
|
+
first_title = double(RakeMKV::Title, id: 0)
|
8
|
+
last_title = double(RakeMKV::Title, id: 1)
|
9
|
+
titles = RakeMKV::Titles.new([last_title, first_title])
|
10
|
+
expect(titles.at_id(1)).to eq last_title
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe '#longest' do
|
15
|
+
it 'finds the longest time' do
|
16
|
+
short_title = double(RakeMKV::Title, time: 20)
|
17
|
+
long_title = double(RakeMKV::Title, time: 50)
|
18
|
+
titles = RakeMKV::Titles.new([short_title, long_title])
|
19
|
+
expect(titles.longest).to eq long_title
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require "rspec"
|
2
|
+
require "rakemkv"
|
3
|
+
require "support/rakemkvmock"
|
4
|
+
require "tmpdir"
|
5
|
+
|
6
|
+
RSpec.configure do |config|
|
7
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
8
|
+
config.run_all_when_everything_filtered = true
|
9
|
+
config.filter_run :focus
|
10
|
+
|
11
|
+
# Run specs in random order to surface order dependencies. If you find an
|
12
|
+
# order dependency and want to debug it, you can fix the order by providing
|
13
|
+
# the seed, which is printed after each run.
|
14
|
+
# --seed 1234
|
15
|
+
config.order = 'random'
|
16
|
+
|
17
|
+
config.after(:each) do
|
18
|
+
RakeMKV.config.reset!
|
19
|
+
end
|
20
|
+
end
|