ehbrs-tools 0.25.0 → 0.25.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/.avm.yml +4 -0
  3. data/.rspec +1 -0
  4. data/.rubocop.yml +39 -0
  5. data/Gemfile.lock +269 -0
  6. data/lib/ehbrs/tools/version.rb +1 -1
  7. data/spec/code/rubocop_spec.rb +3 -0
  8. data/spec/lib/ehbrs/cooking_book/recipe/measure_spec.rb +21 -0
  9. data/spec/lib/ehbrs/observers/base_spec.rb +93 -0
  10. data/spec/lib/ehbrs/tools/runner/fs/used_space_spec.rb +61 -0
  11. data/spec/lib/ehbrs/tools/runner/vg/ips_spec.rb +31 -0
  12. data/spec/lib/ehbrs/tools/runner/vg/ips_spec_files/expected.rom +0 -0
  13. data/spec/lib/ehbrs/tools/runner/vg/ips_spec_files/patch_0.ips +0 -0
  14. data/spec/lib/ehbrs/tools/runner/vg/ips_spec_files/patch_1.ips +0 -0
  15. data/spec/lib/ehbrs/tools/runner/vg/ips_spec_files/source.rom +0 -0
  16. data/spec/lib/ehbrs/tools/runner/videos/probe_spec.rb +19 -0
  17. data/spec/lib/ehbrs/tools/runner/videos/probe_spec_files/fixed.target.yaml +105 -0
  18. data/spec/lib/ehbrs/tools/runner/videos/unsupported_spec.rb +75 -0
  19. data/spec/lib/ehbrs/tools/runner/videos/unsupported_spec_files/dts_audio.probe.yaml +90 -0
  20. data/spec/lib/ehbrs/tools/runner_spec.rb +16 -0
  21. data/spec/lib/ehbrs/vg/wii/game_file_spec.rb +21 -0
  22. data/spec/lib/ehbrs/vg/wii/wit/parsers/dump_spec.rb +11 -0
  23. data/spec/lib/ehbrs/vg/wii/wit/parsers/dump_spec_files/pikmin2_R92P01_wia.source.witdump +27 -0
  24. data/spec/lib/ehbrs/vg/wii/wit/parsers/dump_spec_files/pikmin2_R92P01_wia.target.yaml +22 -0
  25. data/spec/lib/ehbrs/vg/wii/wit/parsers/dump_spec_files/pikmin2_pal_iso.source.witdump +28 -0
  26. data/spec/lib/ehbrs/vg/wii/wit/parsers/dump_spec_files/pikmin2_pal_iso.target.yaml +21 -0
  27. data/spec/lib/ehbrs/vg/wii/wit/parsers/dump_spec_files/resident_evil_code_veronica_disc2_iso.source.witdump +16 -0
  28. data/spec/lib/ehbrs/vg/wii/wit/parsers/dump_spec_files/resident_evil_code_veronica_disc2_iso.target.yaml +19 -0
  29. data/spec/lib/ehbrs/vg/wii/wit/parsers/dump_spec_files/super_mario_galaxy_wbfs.source.witdump +28 -0
  30. data/spec/lib/ehbrs/vg/wii/wit/parsers/dump_spec_files/super_mario_galaxy_wbfs.target.yaml +23 -0
  31. data/spec/lib/ehbrs/vg/wii/wit/path_spec.rb +33 -0
  32. data/spec/spec_helper/videos.rb +30 -0
  33. data/spec/spec_helper/videos_files/stub_source.mp4 +0 -0
  34. data/spec/spec_helper.rb +7 -0
  35. data/vendor/ehbrs_ruby_utils/ehbrs_ruby_utils.gemspec +2 -1
  36. data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/version.rb +1 -1
  37. metadata +85 -3
@@ -0,0 +1,61 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/fs/temp'
4
+ require 'ehbrs/tools/runner'
5
+ require 'ehbrs/tools/runner/fs/used_space'
6
+ require 'ehbrs/observers/with_persistence'
7
+
8
+ RSpec.describe ::Ehbrs::Tools::Runner::Fs::UsedSpace do
9
+ let(:target) { ::EacRubyUtils::Fs::Temp.directory }
10
+ let(:user_dir) { ::EacRubyUtils::Fs::Temp.directory }
11
+ let(:cached_user_dir) { ::EacRubyUtils::FilesystemCache.new(user_dir) }
12
+ let(:observers_user_dir) { cached_user_dir.child('observers') }
13
+ let(:observer_path) do
14
+ observers_user_dir.child(target.to_s.parameterize).content_path.to_pathname
15
+ end
16
+
17
+ before do
18
+ allow(::Ehbrs::UserDirs).to receive(:data).and_return(cached_user_dir)
19
+ end
20
+
21
+ after { [target, user_dir].each(&:remove!) }
22
+
23
+ it { expect(observer_path).not_to exist }
24
+ it { expect(cached_user_dir.path.to_pathname).to exist }
25
+
26
+ %w[--check --verbose].bool_array_combs.each do |comb|
27
+ it "run with options #{comb}" do
28
+ expect { runner_run(*comb, target.to_path) }.not_to raise_error
29
+ end
30
+ end
31
+
32
+ context 'when is firstly checked' do
33
+ before { runner_run('--check', target.to_path) }
34
+
35
+ it { expect(observer_path).to exist }
36
+ it { expect(observer.records.count).to eq(1) }
37
+
38
+ context 'when target does not change' do
39
+ before { runner_run('--check', target.to_path) }
40
+
41
+ it { expect(observer.records.count).to eq(1) }
42
+ end
43
+
44
+ context 'when target changes' do
45
+ before do
46
+ target.join('a_file').write('A' * 1024)
47
+ runner_run('--check', target.to_path)
48
+ end
49
+
50
+ it { expect(observer.records.count).to eq(2) }
51
+ end
52
+ end
53
+
54
+ def observer
55
+ ::Ehbrs::Observers::WithPersistence.new(observer_path)
56
+ end
57
+
58
+ def runner_run(*args)
59
+ ::Ehbrs::Tools::Runner.run(argv: %w[fs used-space] + args)
60
+ end
61
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/fs/temp'
4
+ require 'ehbrs/tools/runner'
5
+ require 'ehbrs/tools/runner/vg/ips'
6
+
7
+ RSpec.describe ::Ehbrs::Tools::Runner::Vg::Ips do
8
+ let(:source_dir) { ::Pathname.new('ips_spec_files').expand_path __dir__ }
9
+ let(:source_file) { source_dir / 'source.rom' }
10
+ let(:patches) { 2.times.map { |i| source_dir / "patch_#{i}.ips" } }
11
+
12
+ describe '#run' do
13
+ let(:output_file) { ::EacRubyUtils::Fs::Temp.file }
14
+ let(:expected_file) { source_dir / 'expected.rom' }
15
+ let(:run_argv) do
16
+ ['vg', 'ips', '--output-file', output_file.to_path, source_file.to_path] +
17
+ patches.map(&:to_path)
18
+ end
19
+
20
+ before do
21
+ ::Ehbrs::Tools::Runner.run(argv: run_argv)
22
+ end
23
+
24
+ after do
25
+ output_file.unlink if output_file.exist?
26
+ end
27
+
28
+ it { expect(output_file).to exist }
29
+ it { expect(::FileUtils.compare_file(output_file.to_path, expected_file.to_path)).to be_truthy }
30
+ end
31
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'ehbrs/tools/runner'
4
+
5
+ RSpec.describe ::Ehbrs::Tools::Runner::Videos::Probe do
6
+ let(:source_file) { stub_video_source_file }
7
+ let(:target_dir) { ::Pathname.new(__dir__).expand_path / 'probe_spec_files' }
8
+ let(:target_file) { target_dir / 'fixed.target.yaml' }
9
+ let(:target_content) { target_file.read.gsub('%%PATH%%', source_file.to_path) }
10
+
11
+ let(:argv) { %w[videos probe] + [source_file.to_path] }
12
+ let(:runner) { ::Ehbrs::Tools::Runner.create(argv: argv) }
13
+
14
+ describe '#run' do
15
+ it do
16
+ expect { runner.run }.to(output(target_content).to_stdout_from_any_process)
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,105 @@
1
+ ---
2
+ :streams:
3
+ - :index: 0
4
+ :codec_name: h264
5
+ :codec_long_name: H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10
6
+ :profile: Constrained Baseline
7
+ :codec_type: video
8
+ :codec_time_base: 1/50
9
+ :codec_tag_string: avc1
10
+ :codec_tag: '0x31637661'
11
+ :width: 352
12
+ :height: 288
13
+ :coded_width: 352
14
+ :coded_height: 288
15
+ :has_b_frames: 0
16
+ :sample_aspect_ratio: '1:1'
17
+ :display_aspect_ratio: '11:9'
18
+ :pix_fmt: yuv420p
19
+ :level: 13
20
+ :chroma_location: left
21
+ :refs: 1
22
+ :is_avc: 'true'
23
+ :nal_length_size: '4'
24
+ :r_frame_rate: 25/1
25
+ :avg_frame_rate: 25/1
26
+ :time_base: 1/25
27
+ :start_pts: 0
28
+ :start_time: '0.000000'
29
+ :duration_ts: 168
30
+ :duration: '6.720000'
31
+ :bit_rate: '112583'
32
+ :bits_per_raw_sample: '8'
33
+ :nb_frames: '168'
34
+ :disposition:
35
+ :default: 1
36
+ :dub: 0
37
+ :original: 0
38
+ :comment: 0
39
+ :lyrics: 0
40
+ :karaoke: 0
41
+ :forced: 0
42
+ :hearing_impaired: 0
43
+ :visual_impaired: 0
44
+ :clean_effects: 0
45
+ :attached_pic: 0
46
+ :timed_thumbnails: 0
47
+ :tags:
48
+ :language: und
49
+ :handler_name: VideoHandler
50
+ - :index: 1
51
+ :codec_name: aac
52
+ :codec_long_name: AAC (Advanced Audio Coding)
53
+ :profile: LC
54
+ :codec_type: audio
55
+ :codec_time_base: 1/44100
56
+ :codec_tag_string: mp4a
57
+ :codec_tag: '0x6134706d'
58
+ :sample_fmt: fltp
59
+ :sample_rate: '44100'
60
+ :channels: 2
61
+ :channel_layout: stereo
62
+ :bits_per_sample: 0
63
+ :r_frame_rate: 0/0
64
+ :avg_frame_rate: 0/0
65
+ :time_base: 1/44100
66
+ :start_pts: 0
67
+ :start_time: '0.000000'
68
+ :duration_ts: 299008
69
+ :duration: '6.780227'
70
+ :bit_rate: '95999'
71
+ :max_bit_rate: '100304'
72
+ :nb_frames: '292'
73
+ :disposition:
74
+ :default: 1
75
+ :dub: 0
76
+ :original: 0
77
+ :comment: 0
78
+ :lyrics: 0
79
+ :karaoke: 0
80
+ :forced: 0
81
+ :hearing_impaired: 0
82
+ :visual_impaired: 0
83
+ :clean_effects: 0
84
+ :attached_pic: 0
85
+ :timed_thumbnails: 0
86
+ :tags:
87
+ :creation_time: '2015-05-17T06:08:17.000000Z'
88
+ :language: und
89
+ :handler_name: IsoMedia File Produced by Google, 5-11-2011
90
+ :format:
91
+ :filename: "%%PATH%%"
92
+ :nb_streams: 2
93
+ :nb_programs: 0
94
+ :format_name: mov,mp4,m4a,3gp,3g2,mj2
95
+ :format_long_name: QuickTime / MOV
96
+ :start_time: '0.000000'
97
+ :duration: '6.780000'
98
+ :size: '179200'
99
+ :bit_rate: '211445'
100
+ :probe_score: 100
101
+ :tags:
102
+ :major_brand: mp42
103
+ :minor_version: '0'
104
+ :compatible_brands: isommp42
105
+ :creation_time: '2015-05-17T06:08:17.000000Z'
@@ -0,0 +1,75 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'ehbrs/tools/runner'
4
+ require 'eac_ruby_utils/fs/temp'
5
+ require 'ehbrs/tools/runner/videos/unsupported'
6
+ require 'ehbrs_ruby_utils/videos/container'
7
+
8
+ RSpec.describe ::Ehbrs::Tools::Runner::Videos::Unsupported do
9
+ let(:source_dir) { ::Pathname.new(__dir__).expand_path / 'unsupported_spec_files' }
10
+ let(:temp_dir) { ::EacRubyUtils::Fs::Temp.directory }
11
+ let(:dts_audio) do
12
+ stub_video(['-c:v', 'copy', '-c:a', 'dts', '-strict', '-2'], temp_dir / 'to_fix_file.mp4')
13
+ end
14
+
15
+ ['dts_audio'].each do |video_var|
16
+ context "when source file is #{video_var}" do
17
+ let(:to_fix_file) { send(video_var) }
18
+
19
+ before do
20
+ to_fix_file
21
+ end
22
+
23
+ after do
24
+ temp_dir.remove
25
+ end
26
+
27
+ it { expect(to_fix_file.file?).to eq(true) }
28
+ it { expect(to_fix_file.dirname).to eq(temp_dir) }
29
+
30
+ describe '#run' do
31
+ let(:run_argv) { ['videos', 'unsupported', '-f', temp_dir.to_s] }
32
+ let(:converted_file) { to_fix_file.basename_sub { |b| "#{b}.converted" } }
33
+ let(:fixed_file) { to_fix_file.basename_sub { |b| "#{b.basename('.*')}.mkv" } }
34
+ let(:fixed_file_actual_probe_data) do
35
+ sanitize_probe_data(::EhbrsRubyUtils::Videos::Container.new(fixed_file).probe_data)
36
+ end
37
+
38
+ let(:fixed_file_expect_probe_file) { source_dir.join("#{video_var}.probe.yaml") }
39
+ let(:fixed_file_expect_probe_data) do
40
+ ::EacRubyUtils::Yaml.load_file(fixed_file_expect_probe_file)
41
+ end
42
+
43
+ before do
44
+ ::Ehbrs::Tools::Runner.run(argv: run_argv)
45
+ end
46
+
47
+ it { expect(converted_file).to be_a_file }
48
+ it { expect(fixed_file).to be_a_file }
49
+
50
+ it 'has expected probe data' do
51
+ expect(fixed_file_actual_probe_data).to eq(fixed_file_expect_probe_data)
52
+ end
53
+ end
54
+
55
+ def sanitize_probe_data(data)
56
+ sanitize_format_data(data.fetch(:format))
57
+ data.fetch(:streams).each { |stream_data| sanitize_stream_data(stream_data) }
58
+ data
59
+ end
60
+
61
+ def sanitize_stream_data(data)
62
+ data[:tags].if_present do |v|
63
+ %i[HANDLER_NAME ENCODER].each { |field| v.delete(field) }
64
+ end
65
+ end
66
+
67
+ def sanitize_format_data(data)
68
+ data.if_present do |v|
69
+ %i[filename size bit_rate].each { |field| v.delete(field) }
70
+ v[:tags].if_present { |vv| vv.delete(:ENCODER) }
71
+ end
72
+ end
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,90 @@
1
+ ---
2
+ :streams:
3
+ - :index: 0
4
+ :codec_name: h264
5
+ :codec_long_name: H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10
6
+ :profile: Constrained Baseline
7
+ :codec_type: video
8
+ :codec_time_base: 1/50
9
+ :codec_tag_string: "[0][0][0][0]"
10
+ :codec_tag: '0x0000'
11
+ :width: 352
12
+ :height: 288
13
+ :coded_width: 352
14
+ :coded_height: 288
15
+ :has_b_frames: 0
16
+ :sample_aspect_ratio: '1:1'
17
+ :display_aspect_ratio: '11:9'
18
+ :pix_fmt: yuv420p
19
+ :level: 13
20
+ :chroma_location: left
21
+ :field_order: progressive
22
+ :refs: 1
23
+ :is_avc: 'true'
24
+ :nal_length_size: '4'
25
+ :r_frame_rate: 25/1
26
+ :avg_frame_rate: 25/1
27
+ :time_base: 1/1000
28
+ :start_pts: 23
29
+ :start_time: '0.023000'
30
+ :bits_per_raw_sample: '8'
31
+ :disposition:
32
+ :default: 1
33
+ :dub: 0
34
+ :original: 0
35
+ :comment: 0
36
+ :lyrics: 0
37
+ :karaoke: 0
38
+ :forced: 0
39
+ :hearing_impaired: 0
40
+ :visual_impaired: 0
41
+ :clean_effects: 0
42
+ :attached_pic: 0
43
+ :timed_thumbnails: 0
44
+ :tags:
45
+ :DURATION: '00:00:06.743000000'
46
+ - :index: 1
47
+ :codec_name: aac
48
+ :codec_long_name: AAC (Advanced Audio Coding)
49
+ :profile: LC
50
+ :codec_type: audio
51
+ :codec_time_base: 1/44100
52
+ :codec_tag_string: "[0][0][0][0]"
53
+ :codec_tag: '0x0000'
54
+ :sample_fmt: fltp
55
+ :sample_rate: '44100'
56
+ :channels: 2
57
+ :channel_layout: stereo
58
+ :bits_per_sample: 0
59
+ :r_frame_rate: 0/0
60
+ :avg_frame_rate: 0/0
61
+ :time_base: 1/1000
62
+ :start_pts: 0
63
+ :start_time: '0.000000'
64
+ :disposition:
65
+ :default: 1
66
+ :dub: 0
67
+ :original: 0
68
+ :comment: 0
69
+ :lyrics: 0
70
+ :karaoke: 0
71
+ :forced: 0
72
+ :hearing_impaired: 0
73
+ :visual_impaired: 0
74
+ :clean_effects: 0
75
+ :attached_pic: 0
76
+ :timed_thumbnails: 0
77
+ :tags:
78
+ :DURATION: '00:00:06.803000000'
79
+ :format:
80
+ :nb_streams: 2
81
+ :nb_programs: 0
82
+ :format_name: matroska,webm
83
+ :format_long_name: Matroska / WebM
84
+ :start_time: '0.000000'
85
+ :duration: '6.803000'
86
+ :probe_score: 100
87
+ :tags:
88
+ :COMPATIBLE_BRANDS: isomiso2avc1mp41
89
+ :MAJOR_BRAND: isom
90
+ :MINOR_VERSION: '512'
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'ehbrs/tools/runner'
4
+ require 'ehbrs/tools/version'
5
+
6
+ RSpec.describe ::Ehbrs::Tools::Runner do
7
+ let(:runner) { described_class.create(argv: argv) }
8
+
9
+ describe '--version option' do
10
+ let(:argv) { %w[--version] }
11
+
12
+ it do
13
+ expect { runner.run }.to(output("#{::Ehbrs::Tools::VERSION}\n").to_stdout_from_any_process)
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'ehbrs/vg/wii/game_file'
4
+
5
+ RSpec.describe ::Ehbrs::Vg::Wii::GameFile do
6
+ [['game.iso', 1, 'game'], ['disc1.iso', 1, 'game'], ['disc2.iso', 2, 'disc2'],
7
+ ['Resident Evil - Code - Veronica X (USA) (Disc 1)', 1, 'game'],
8
+ ['Resident Evil - Code - Veronica X (USA) (Disc 2)', 2, 'disc2']].each do |s|
9
+ context "when game file is #{s[0]}" do
10
+ let(:game_file) { described_class.new(s[0]) }
11
+
12
+ it "disc_number should be #{s[1]}" do
13
+ expect(game_file.disc_number).to eq(s[1])
14
+ end
15
+
16
+ it "nintendont_basename should be #{s[2]}" do
17
+ expect(game_file.nintendont_basename).to eq(s[2])
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'ehbrs/vg/wii/wit/parsers/dump'
4
+
5
+ RSpec.describe ::Ehbrs::Vg::Wii::Wit::Parsers::Dump do
6
+ include_examples 'source_target_fixtures', __FILE__
7
+
8
+ def source_data(source_file)
9
+ described_class.new(::File.read(source_file)).properties
10
+ end
11
+ end