ehbrs-tools 0.16.1 → 0.16.2

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 +4 -4
  2. data/lib/ehbrs/runner/videos/probe.rb +3 -3
  3. data/lib/ehbrs/tools/version.rb +1 -1
  4. data/lib/ehbrs/videos/file.rb +4 -8
  5. data/lib/ehbrs/videos/track.rb +20 -10
  6. data/lib/ehbrs/videos/unsupported/checks/codec_extra_unlisted.rb +2 -0
  7. data/lib/ehbrs/videos/unsupported/checks/codec_extra_unsupported.rb +2 -0
  8. data/lib/ehbrs/videos/unsupported/checks/codec_unlisted.rb +2 -0
  9. data/lib/ehbrs/videos/unsupported/checks/codec_unsupported.rb +2 -0
  10. data/lib/ehbrs/videos/unsupported/checks/invalid_extension.rb +2 -0
  11. data/lib/ehbrs/videos/unsupported/fixes/supported_codec.rb +1 -1
  12. data/lib/ehbrs/videos/unsupported/profiles/base.rb +17 -3
  13. data/lib/ehbrs/videos/unsupported/profiles/philco.rb +5 -4
  14. data/vendor/aranha-parsers/lib/aranha/parsers/spec/source_target_fixtures_example.rb +10 -2
  15. data/vendor/aranha-parsers/lib/aranha/parsers/version.rb +1 -1
  16. data/vendor/eac_cli/lib/eac_cli/definition.rb +34 -39
  17. data/vendor/eac_cli/lib/eac_cli/definition/alternative.rb +83 -0
  18. data/vendor/eac_cli/lib/eac_cli/docopt/doc_builder.rb +18 -40
  19. data/vendor/eac_cli/lib/eac_cli/docopt/doc_builder/alternative.rb +50 -0
  20. data/vendor/eac_cli/lib/eac_cli/parser.rb +21 -3
  21. data/vendor/eac_cli/lib/eac_cli/parser/alternative.rb +88 -0
  22. data/vendor/eac_cli/lib/eac_cli/parser/alternative/argv.rb +17 -0
  23. data/vendor/eac_cli/lib/eac_cli/parser/alternative/double_dash.rb +24 -0
  24. data/vendor/eac_cli/lib/eac_cli/parser/alternative/options.rb +58 -0
  25. data/vendor/eac_cli/lib/eac_cli/parser/alternative/positionals.rb +30 -0
  26. data/vendor/eac_cli/lib/eac_cli/runner.rb +2 -2
  27. data/vendor/eac_cli/lib/eac_cli/runner_with/help.rb +1 -1
  28. data/vendor/eac_cli/lib/eac_cli/runner_with/output_file.rb +5 -1
  29. data/vendor/eac_cli/lib/eac_cli/version.rb +1 -1
  30. data/vendor/eac_cli/spec/lib/eac_cli/definition/alternative_spec.rb +14 -0
  31. data/vendor/eac_cli/spec/lib/eac_cli/docopt/runner_extension_spec.rb +10 -0
  32. data/vendor/eac_cli/spec/lib/eac_cli/parser/alternative_spec.rb +140 -0
  33. data/vendor/eac_cli/spec/lib/eac_cli/runner_spec.rb +14 -5
  34. data/vendor/eac_cli/spec/lib/eac_cli/runner_with/output_file_spec.rb +53 -0
  35. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/abstract_methods.rb +60 -0
  36. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/module/abstract_methods.rb +10 -0
  37. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/version.rb +1 -1
  38. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/yaml.rb +3 -2
  39. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/abstract_methods_spec.rb +28 -0
  40. data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/version.rb +1 -1
  41. data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/videos/container.rb +30 -2
  42. data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/videos/convert_job.rb +91 -0
  43. data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/videos/stream.rb +51 -0
  44. metadata +17 -7
  45. data/vendor/eac_cli/lib/eac_cli/parser/options_collection.rb +0 -68
  46. data/vendor/eac_cli/lib/eac_cli/parser/parse_result.rb +0 -38
  47. data/vendor/eac_cli/lib/eac_cli/parser/positional_collection.rb +0 -77
  48. data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/videos/container/file.rb +0 -31
  49. data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/videos/container/info.rb +0 -21
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacCli
4
- VERSION = '0.11.1'
4
+ VERSION = '0.12.2'
5
5
  end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_cli/definition/alternative'
4
+
5
+ RSpec.describe ::EacCli::Definition::Alternative do
6
+ let(:instance) { described_class.new }
7
+
8
+ it { expect { instance.arg_opt '-a', '--opt2', 'A argument option' }.not_to raise_error }
9
+ it { expect { instance.bool_opt '-b', '--opt1', 'A boolean option' }.not_to raise_error }
10
+ it { expect { instance.options_argument(true) }.not_to raise_error }
11
+ it { expect { instance.pos_arg :pos1 }.not_to raise_error }
12
+ it { expect { instance.pos_arg :pos2, optional: true, repeat: true }.not_to raise_error }
13
+ it { expect { instance.subcommands }.not_to raise_error }
14
+ end
@@ -22,4 +22,14 @@ RSpec.describe ::EacCli::Docopt::RunnerExtension do
22
22
 
23
23
  it { expect(instance.options.fetch('--opt1')).to eq('aaa') }
24
24
  it { expect(instance.options.fetch('<pos1>')).to eq('bbb') }
25
+ it { expect(instance.doc).to eq(<<~EXPECTED) }
26
+ A stub runner.
27
+
28
+ Usage:
29
+ __PROGRAM__ [options] <pos1>
30
+
31
+ Options:
32
+ -o --opt1=<value> A argument option
33
+
34
+ EXPECTED
25
35
  end
@@ -0,0 +1,140 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_cli/docopt/runner_extension'
4
+
5
+ RSpec.describe ::EacCli::Parser::Alternative do
6
+ let(:instance) { described_class.new(alternative, argv) }
7
+ let(:actual_parsed) { instance.parsed.to_h.symbolize_keys }
8
+
9
+ context 'without subcommands' do
10
+ let(:alternative) do
11
+ r = ::EacCli::Definition::Alternative.new
12
+ r.bool_opt '-b', '--opt1', 'A boolean option'
13
+ r.arg_opt '-a', '--opt2', 'A argument option'
14
+ r.bool_opt '-c', '--opt3', 'A required boolean option', required: true
15
+ r.pos_arg :pos1
16
+ r.pos_arg :pos2, optional: true, repeat: true
17
+ r
18
+ end
19
+
20
+ context 'with all values' do
21
+ let(:argv) { %w[--opt1 --opt2 OPT2 --opt3 POS1 POS2_1 POS2_2] }
22
+ let(:parsed_expected) do
23
+ {
24
+ opt1: true, opt2: 'OPT2', opt3: true, pos1: 'POS1', pos2: %w[POS2_1 POS2_2]
25
+ }
26
+ end
27
+
28
+ it { expect(instance.error).to be_blank }
29
+ it { expect(actual_parsed).to eq(parsed_expected) }
30
+ end
31
+
32
+ context 'with only required values' do
33
+ let(:argv) { %w[--opt3 POS1] }
34
+ let(:parsed_expected) { { opt1: false, opt2: nil, opt3: true, pos1: 'POS1', pos2: [] } }
35
+
36
+ it { expect(instance.error).to be_blank }
37
+ it { expect(actual_parsed).to eq(parsed_expected) }
38
+ end
39
+
40
+ context 'with double dash' do
41
+ let(:argv) { %w[--opt3 POS1 -- --opt1 --] }
42
+ let(:parsed_expected) do
43
+ { opt1: false, opt2: nil, opt3: true, pos1: 'POS1', pos2: %w[--opt1 --] }
44
+ end
45
+
46
+ it { expect(instance.error).to be_blank }
47
+ it { expect(actual_parsed).to eq(parsed_expected) }
48
+ end
49
+
50
+ context 'without required positional' do
51
+ let(:argv) { %w[--opt1 --opt3] }
52
+ let(:parsed_expected) { { opt1: true, opt2: nil, opt3: true, pos1: nil, pos2: [] } }
53
+
54
+ it { expect(instance.error).to be_present }
55
+ it { expect(actual_parsed).to eq(parsed_expected) }
56
+ end
57
+
58
+ context 'without required option' do
59
+ let(:argv) { %w[--opt1 POS1] }
60
+ let(:parsed_expected) { { opt1: true, opt2: nil, opt3: false, pos1: 'POS1', pos2: [] } }
61
+
62
+ it { expect(instance.error).to be_present }
63
+ it { expect(actual_parsed).to eq(parsed_expected) }
64
+ end
65
+
66
+ context 'without any required option or positional' do
67
+ let(:argv) { %w[] }
68
+ let(:parsed_expected) { { opt1: false, opt2: nil, opt3: false, pos1: nil, pos2: [] } }
69
+
70
+ it { expect(instance.error).to be_present }
71
+ it { expect(actual_parsed).to eq(parsed_expected) }
72
+ end
73
+
74
+ context 'with excedent positional' do
75
+ let(:alternative) do
76
+ r = ::EacCli::Definition::Alternative.new
77
+ r.pos_arg :pos1
78
+ r
79
+ end
80
+
81
+ let(:argv) { %w[POS1 POS2] }
82
+ let(:parsed_expected) { { pos1: 'POS1' } }
83
+
84
+ it { expect(instance.error).to be_present }
85
+ it { expect(actual_parsed).to eq(parsed_expected) }
86
+ end
87
+ end
88
+
89
+ context 'with subcommands' do
90
+ let(:alternative) do
91
+ r = ::EacCli::Definition::Alternative.new
92
+ r.bool_opt '-b', '--opt1', 'A boolean option'
93
+ r.arg_opt '-a', '--opt2', 'A argument option'
94
+ r.subcommands
95
+ r
96
+ end
97
+
98
+ context 'with all values' do
99
+ let(:argv) { %w[--opt1 --opt2 OPT2 CMD CMD_ARG_1 --CMD_ARG_2] }
100
+ let(:parsed_expected) do
101
+ {
102
+ opt1: true, opt2: 'OPT2',
103
+ ::EacCli::Definition::Alternative::SUBCOMMAND_NAME_ARG => 'CMD',
104
+ ::EacCli::Definition::Alternative::SUBCOMMAND_ARGS_ARG => %w[CMD_ARG_1 --CMD_ARG_2]
105
+ }
106
+ end
107
+
108
+ it { expect(instance.error).to be_blank }
109
+ it { expect(actual_parsed).to eq(parsed_expected) }
110
+ end
111
+
112
+ context 'with only required values' do
113
+ let(:argv) { %w[CMD] }
114
+ let(:parsed_expected) do
115
+ {
116
+ opt1: false, opt2: nil,
117
+ ::EacCli::Definition::Alternative::SUBCOMMAND_NAME_ARG => 'CMD',
118
+ ::EacCli::Definition::Alternative::SUBCOMMAND_ARGS_ARG => []
119
+ }
120
+ end
121
+
122
+ it { expect(instance.error).to be_blank }
123
+ it { expect(actual_parsed).to eq(parsed_expected) }
124
+ end
125
+
126
+ context 'without required values' do
127
+ let(:argv) { %w[--opt1] }
128
+ let(:parsed_expected) do
129
+ {
130
+ opt1: true, opt2: nil,
131
+ ::EacCli::Definition::Alternative::SUBCOMMAND_NAME_ARG => nil,
132
+ ::EacCli::Definition::Alternative::SUBCOMMAND_ARGS_ARG => []
133
+ }
134
+ end
135
+
136
+ it { expect(instance.error).to be_present }
137
+ it { expect(actual_parsed).to eq(parsed_expected) }
138
+ end
139
+ end
140
+ end
@@ -23,9 +23,14 @@ RSpec.describe ::EacCli::Runner do
23
23
  end
24
24
  end
25
25
 
26
+ let(:instance) { runner_class.create(argv) }
27
+ let(:parsed_actual) { instance.parsed.to_h.symbolize_keys }
28
+
26
29
  context 'when all args are supplied' do
27
- let(:instance) { runner_class.create(%w[--opt1 aaa --opt2 bbb ccc ddd]) }
30
+ let(:argv) { %w[--opt1 aaa --opt2 bbb ccc ddd] }
31
+ let(:parsed_expected) { { opt1: 'aaa', opt2: true, pos1: 'bbb', pos2: %w[ccc ddd] } }
28
32
 
33
+ it { expect(parsed_actual).to eq(parsed_expected) }
29
34
  it { expect(instance.parsed.opt1).to eq('aaa') }
30
35
  it { expect(instance.parsed.opt2?).to eq(true) }
31
36
  it { expect(instance.parsed.pos1).to eq('bbb') }
@@ -33,8 +38,10 @@ RSpec.describe ::EacCli::Runner do
33
38
  end
34
39
 
35
40
  context 'when only required args are supplied' do
36
- let(:instance) { runner_class.create(%w[bbb]) }
41
+ let(:argv) { %w[bbb] }
42
+ let(:parsed_expected) { { opt1: nil, opt2: false, pos1: 'bbb', pos2: [] } }
37
43
 
44
+ it { expect(parsed_actual).to eq(parsed_expected) }
38
45
  it { expect(instance.parsed.opt1).to be_nil }
39
46
  it { expect(instance.parsed.opt2?).to eq(false) }
40
47
  it { expect(instance.parsed.pos1).to eq('bbb') }
@@ -42,7 +49,7 @@ RSpec.describe ::EacCli::Runner do
42
49
  end
43
50
 
44
51
  context 'when required args are not supplied' do
45
- let(:instance) { runner_class.create(%w[]) }
52
+ let(:argv) { %w[] }
46
53
 
47
54
  it do
48
55
  expect { instance.parsed }.to raise_error(::EacCli::Parser::Error)
@@ -50,8 +57,10 @@ RSpec.describe ::EacCli::Runner do
50
57
  end
51
58
 
52
59
  context 'when alternative args are supplied' do
53
- let(:instance) { runner_class.create(%w[--opt3]) }
60
+ let(:argv) { %w[--opt3] }
61
+ let(:parsed_expected) { { opt3: true } }
54
62
 
63
+ it { expect(parsed_actual).to eq(parsed_expected) }
55
64
  it { expect(instance.parsed.opt3?).to eq(true) }
56
65
  end
57
66
 
@@ -69,7 +78,7 @@ RSpec.describe ::EacCli::Runner do
69
78
  end
70
79
  end
71
80
 
72
- let(:instance) { runner_class.create(%w[aaa bbb]) }
81
+ let(:argv) { %w[aaa bbb] }
73
82
 
74
83
  it do
75
84
  expect { instance.parsed }.to raise_error(::EacCli::Parser::Error)
@@ -0,0 +1,53 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_cli/runner_with/output_file'
4
+ require 'eac_ruby_utils/fs/temp'
5
+
6
+ RSpec.describe ::EacCli::RunnerWith::OutputFile do
7
+ let(:runner) do
8
+ the_module = described_class
9
+ Class.new do
10
+ include the_module
11
+
12
+ runner_definition do
13
+ desc 'A stub root runner.'
14
+ pos_arg :input_text
15
+ end
16
+
17
+ def run
18
+ run_output
19
+ end
20
+
21
+ def output_content
22
+ parsed.input_text
23
+ end
24
+ end
25
+ end
26
+
27
+ let(:stub_text) { 'STUB_TEXT' }
28
+ let(:instance) { runner.create(argv: runner_argv) }
29
+
30
+ context 'without --output-file option' do
31
+ let(:runner_argv) { [stub_text] }
32
+
33
+ it do
34
+ expect { instance.run }.to output(stub_text).to_stdout_from_any_process
35
+ end
36
+ end
37
+
38
+ context 'with --output-file option' do
39
+ let(:output_file) { ::EacRubyUtils::Fs::Temp.file }
40
+ let(:runner_argv) { ['--output-file', output_file.to_path, stub_text] }
41
+
42
+ before do
43
+ instance.run
44
+ end
45
+
46
+ after do
47
+ output_file.remove
48
+ end
49
+
50
+ it { expect(output_file).to exist }
51
+ it { expect(output_file.read).to eq(stub_text) }
52
+ end
53
+ end
@@ -0,0 +1,60 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/patches/module/common_concern'
4
+
5
+ module EacRubyUtils
6
+ # Support to abstract methods.
7
+ #
8
+ # Usage:
9
+ #
10
+ # require 'eac_ruby_utils/abstract_methods'
11
+ #
12
+ # class BaseClass
13
+ # include EacRubyUtils::AbstractMethods
14
+ #
15
+ # abstract_methods :mymethod
16
+ # end
17
+ #
18
+ # BaseClass.new.mymethod # raise "Abstract method: mymethod"
19
+ #
20
+ # class SubClass
21
+ # def mymethod
22
+ # "Implemented"
23
+ # end
24
+ # end
25
+ #
26
+ # SubClass.new.mymethod # return "Implemented"
27
+ module AbstractMethods
28
+ common_concern
29
+
30
+ module ClassMethods
31
+ def abstract_methods(*methods_names)
32
+ methods_names.each do |method_name|
33
+ define_method method_name do
34
+ raise_abstract_method(method_name)
35
+ end
36
+ end
37
+ end
38
+ end
39
+
40
+ module InstanceMethods
41
+ def respond_to_missing?(method_name, include_private = false)
42
+ super || abstract_method?(method_name)
43
+ end
44
+
45
+ def method_missing(method_name, *arguments, &block)
46
+ raise_abstract_method(method_name) if abstract_method?(method_name)
47
+
48
+ super
49
+ end
50
+
51
+ def abstract_method?(method_name)
52
+ self.class.abstract_methods.include?(method_name.to_sym)
53
+ end
54
+
55
+ def raise_abstract_method(method_name)
56
+ raise ::NoMethodError, "Abstract method \"#{method_name}\" hit in \"#{self}\""
57
+ end
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/abstract_methods'
4
+
5
+ class Module
6
+ def enable_abstract_methods(*methods)
7
+ include ::EacRubyUtils::AbstractMethods
8
+ abstract_methods(*methods)
9
+ end
10
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacRubyUtils
4
- VERSION = '0.51.1'
4
+ VERSION = '0.53.0'
5
5
  end
@@ -1,13 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'date'
3
4
  require 'yaml'
4
5
 
5
6
  module EacRubyUtils
6
7
  # A safe YAML loader/dumper with common types included.
7
8
  class Yaml
8
9
  class << self
9
- DEFAULT_PERMITTED_CLASSES = [::Array, ::Date, ::FalseClass, ::Hash, ::NilClass, ::Numeric,
10
- ::String, ::Symbol, ::Time, ::TrueClass].freeze
10
+ DEFAULT_PERMITTED_CLASSES = [::Array, ::Date, ::DateTime, ::FalseClass, ::Hash, ::NilClass,
11
+ ::Numeric, ::String, ::Symbol, ::Time, ::TrueClass].freeze
11
12
 
12
13
  def dump(object)
13
14
  ::YAML.dump(sanitize(object))
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/abstract_methods'
4
+
5
+ RSpec.describe(::EacRubyUtils::AbstractMethods) do
6
+ let(:base_class) do
7
+ the_module = described_class
8
+ ::Class.new do
9
+ include the_module
10
+
11
+ abstract_methods :method1, :method2
12
+ end
13
+ end
14
+ let(:base_instance) { base_class.new }
15
+ let(:sub_class) do
16
+ ::Class.new(base_class) do
17
+ def method1
18
+ 'a result'
19
+ end
20
+ end
21
+ end
22
+ let(:sub_instance) { sub_class.new }
23
+
24
+ it { expect { base_instance.method1 }.to raise_error(::NoMethodError) }
25
+ it { expect { base_instance.method2 }.to raise_error(::NoMethodError) }
26
+ it { expect(sub_instance.method1).to eq('a result') }
27
+ it { expect { sub_instance.method2 }.to raise_error(::NoMethodError) }
28
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EhbrsRubyUtils
4
- VERSION = '0.3.0'
4
+ VERSION = '0.5.0'
5
5
  end
@@ -1,11 +1,39 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'eac_ruby_utils/core_ext'
4
+ require 'ehbrs_ruby_utils/executables'
5
+ require 'ehbrs_ruby_utils/videos/stream'
6
+ require 'json'
4
7
 
5
8
  module EhbrsRubyUtils
6
9
  module Videos
7
- module Container
8
- require_sub __FILE__
10
+ class Container
11
+ enable_simple_cache
12
+ common_constructor :path do
13
+ self.path = path.to_pathname
14
+ end
15
+
16
+ ::EhbrsRubyUtils::Videos::Stream.lists.codec_type.each_value do |stream_type|
17
+ define_method stream_type.to_s.pluralize do
18
+ streams.select { |stream| stream.codec_type == stream_type }
19
+ end
20
+ end
21
+
22
+ private
23
+
24
+ def probe_data_uncached
25
+ ::JSON.parse(
26
+ ::EhbrsRubyUtils::Executables.ffprobe.command(
27
+ '-hide_banner', '-print_format', 'json', '-show_format', '-show_streams', path
28
+ ).execute!
29
+ ).deep_symbolize_keys.freeze
30
+ end
31
+
32
+ def streams_uncached
33
+ probe_data.fetch(:streams).map do |stream_ffprobe_data|
34
+ ::EhbrsRubyUtils::Videos::Stream.new(stream_ffprobe_data)
35
+ end
36
+ end
9
37
  end
10
38
  end
11
39
  end