ehbrs-tools 0.13.1 → 0.14.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.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/lib/ehbrs/executables.rb +1 -1
  3. data/lib/ehbrs/runner/videos.rb +6 -11
  4. data/lib/ehbrs/runner/videos/probe.rb +35 -0
  5. data/lib/ehbrs/tools/version.rb +1 -1
  6. data/lib/ehbrs/videos/file.rb +2 -1
  7. data/vendor/eac_cli/lib/eac_cli/core_ext.rb +4 -0
  8. data/vendor/eac_cli/lib/eac_cli/default_runner.rb +6 -14
  9. data/vendor/eac_cli/lib/eac_cli/docopt/runner_extension.rb +3 -9
  10. data/vendor/eac_cli/lib/eac_cli/patches.rb +4 -0
  11. data/vendor/eac_cli/lib/eac_cli/patches/object.rb +5 -0
  12. data/vendor/eac_cli/lib/eac_cli/patches/object/runner_with.rb +24 -0
  13. data/vendor/eac_cli/lib/eac_cli/runner.rb +47 -10
  14. data/vendor/eac_cli/lib/eac_cli/runner/context.rb +1 -1
  15. data/vendor/eac_cli/lib/eac_cli/runner_with.rb +9 -0
  16. data/vendor/eac_cli/lib/eac_cli/runner_with/help.rb +19 -0
  17. data/vendor/eac_cli/lib/eac_cli/runner_with/output_file.rb +26 -0
  18. data/vendor/eac_cli/lib/eac_cli/version.rb +1 -1
  19. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_concern.rb +4 -4
  20. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/listable/value.rb +3 -2
  21. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/simple_cache.rb +6 -2
  22. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/struct.rb +6 -0
  23. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/version.rb +1 -1
  24. data/vendor/ehbrs_ruby_utils/Gemfile +16 -0
  25. data/vendor/ehbrs_ruby_utils/ehbrs_ruby_utils.gemspec +20 -0
  26. data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils.rb +7 -0
  27. data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/executables.rb +28 -0
  28. data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/version.rb +5 -0
  29. data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/videos.rb +9 -0
  30. data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/videos/container.rb +11 -0
  31. data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/videos/container/file.rb +31 -0
  32. data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/videos/container/info.rb +21 -0
  33. data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/videos/quality.rb +68 -0
  34. data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/videos/resolution.rb +68 -0
  35. data/vendor/ehbrs_ruby_utils/spec/lib/ehbrs_ruby_utils/videos/resolution_spec.rb +18 -0
  36. data/vendor/ehbrs_ruby_utils/spec/rubocop_check_spec.rb +7 -0
  37. data/vendor/ehbrs_ruby_utils/spec/spec_helper.rb +100 -0
  38. metadata +24 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9692fcad0f7b1e05f59f98e17e1d1e5042efa22f1bd1e8ada8a2b5b2d4909e66
4
- data.tar.gz: 606f3be03e5b0f54564aaa78b466e89ed498cf4a7d316e187cb6432b34cd46f6
3
+ metadata.gz: 16b46b443e469012a2f469aae7fec3f4e1a830607fe1eecf36883ad19f009cad
4
+ data.tar.gz: 413b1aa738e18cc5b00a1cd134af3e6766415ca14c1a9a3bfc26529da8679ea2
5
5
  SHA512:
6
- metadata.gz: 4fc3d4a8dc042274ca49de459c5a18d8179cd0b2f1846016c9fcff06d909b5583aa282e645205bc502698b447ae2a8aab3bf53bfc9646e71eea23a9949c5b272
7
- data.tar.gz: 48d655fe4a28192181f2e40d3f2f9041d7c3f4a41a80168446ee15ec176d54c2f5c0c4428d41fc0a5c3248f5dc3471b408c8f8d58b7ffecd5131d9040e7ef0ce
6
+ metadata.gz: 4439409eed3482b157e4d9440dba10bd8ed4cd4094392a8a04171351ceefe727a21de755d99bf548ebfc2ed6ac55b0bb41485cc59249657018c512674dc101cb
7
+ data.tar.gz: 2a7b34170b6b9434cbca44d534dcfe58c2a126e807bccdd2bda4d8ac7c1ca6661c328231cc3b8d1091f5fc9c0df01ca73cf37e932ac6e48748c75099108fc8b1
@@ -17,7 +17,7 @@ module Ehbrs
17
17
  {
18
18
  '-?' => %w[rar],
19
19
  '-h' => %w[unzip],
20
- '-version' => %w[ffmpeg ffprobe],
20
+ '-version' => %w[ffmpeg],
21
21
  '--version' => %w[flips tar wit]
22
22
  }.each do |validate_arg, commands|
23
23
  commands.each do |command|
@@ -1,23 +1,18 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'eac_ruby_utils/core_ext'
3
+ require 'eac_cli/core_ext'
4
4
  require 'eac_ruby_utils/console/docopt_runner'
5
5
 
6
6
  module Ehbrs
7
7
  class Runner < ::EacRubyUtils::Console::DocoptRunner
8
8
  class Videos < ::EacRubyUtils::Console::DocoptRunner
9
+ runner_with :output_file
9
10
  require_sub __FILE__
10
11
 
11
- DOC = <<~DOCOPT
12
- Video tools for EHB/RS.
13
-
14
- Usage:
15
- __PROGRAM__ [options] __SUBCOMMANDS__
16
- __PROGRAM__ -h | --help
17
-
18
- Options:
19
- -h --help Show this screen.
20
- DOCOPT
12
+ runner_definition do
13
+ desc 'Video tools for EHB/RS.'
14
+ subcommands
15
+ end
21
16
  end
22
17
  end
23
18
  end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_cli/core_ext'
4
+ require 'eac_ruby_utils/console/docopt_runner'
5
+ require 'ehbrs_ruby_utils/videos/container/file'
6
+ require 'eac_ruby_utils/yaml'
7
+
8
+ module Ehbrs
9
+ class Runner < ::EacRubyUtils::Console::DocoptRunner
10
+ class Videos < ::EacRubyUtils::Console::DocoptRunner
11
+ class Probe
12
+ runner_with :output_file
13
+
14
+ runner_definition do
15
+ desc 'FFProbe em um arquivo de vídeo.'
16
+ pos_arg :file_path
17
+ end
18
+
19
+ def run
20
+ run_output
21
+ end
22
+
23
+ def output_content
24
+ ::EacRubyUtils::Yaml.dump(container_file.info.to_h)
25
+ end
26
+
27
+ private
28
+
29
+ def container_file_uncached
30
+ ::EhbrsRubyUtils::Videos::Container::File.new(parsed.file_path)
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Ehbrs
4
4
  module Tools
5
- VERSION = '0.13.1'
5
+ VERSION = '0.14.0'
6
6
  end
7
7
  end
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'eac_ruby_utils/core_ext'
4
4
  require 'ehbrs/videos/track'
5
+ require 'ehbrs_ruby_utils/executables'
5
6
 
6
7
  module Ehbrs
7
8
  module Videos
@@ -52,7 +53,7 @@ module Ehbrs
52
53
  end
53
54
 
54
55
  def content_uncached
55
- EacRubyUtils::Envs.local.command('ffprobe', path).execute!(output: :stderr).scrub
56
+ ::EhbrsRubyUtils::Executables.ffprobe.command(path).execute!(output: :stderr).scrub
56
57
  end
57
58
 
58
59
  def duration_uncached
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+ require 'eac_cli/patches'
@@ -1,22 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'active_support/concern'
4
- require 'eac_cli/runner'
5
- require 'eac_ruby_utils/console/speaker'
6
- require 'eac_ruby_utils/simple_cache'
3
+ require 'eac_cli/runner_with/help'
4
+ require 'eac_ruby_utils/core_ext'
7
5
 
8
6
  module EacCli
9
7
  module DefaultRunner
10
- extend ::ActiveSupport::Concern
11
-
12
- included do
13
- include ::EacCli::Runner
14
- include ::EacRubyUtils::Console::Speaker
15
- include ::EacRubyUtils::SimpleCache
16
- runner_definition.alt do
17
- options_arg false
18
- bool_opt '-h', '--help', 'Show help.', usage: true
19
- end
8
+ common_concern do
9
+ include ::EacCli::RunnerWith::Help
10
+ enable_console_speaker
11
+ enable_simple_cache
20
12
  end
21
13
  end
22
14
  end
@@ -9,7 +9,6 @@ module EacCli
9
9
  extend ::ActiveSupport::Concern
10
10
 
11
11
  included do
12
- singleton_class.prepend ClassMethods
13
12
  prepend InstanceMethods
14
13
  end
15
14
 
@@ -17,15 +16,10 @@ module EacCli
17
16
  def check(klass)
18
17
  return unless klass < ::EacRubyUtils::Console::DocoptRunner
19
18
 
20
- klass.include(self)
21
- end
22
- end
19
+ ::EacCli::Runner.alias_runner_class_methods(klass, '', 'eac_cli')
20
+ ::EacCli::Runner.alias_runner_class_methods(klass, 'original', '')
23
21
 
24
- module ClassMethods
25
- def create(*context_args)
26
- r = new(*context_args)
27
- r.context = ::EacCli::Runner::Context.new(*context_args)
28
- r
22
+ klass.include(self)
29
23
  end
30
24
  end
31
25
 
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/require_sub'
4
+ ::EacRubyUtils.require_sub(__FILE__)
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ Dir["#{File.dirname(__FILE__)}/#{::File.basename(__FILE__, '.*')}/*.rb"].sort.each do |path|
4
+ require path
5
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+ require 'eac_cli/runner'
5
+ require 'eac_cli/runner_with'
6
+
7
+ class Object
8
+ def runner_with(*runners)
9
+ include ::EacCli::Runner
10
+ enable_simple_cache
11
+ enable_console_speaker
12
+ runners.each do |runner|
13
+ include runner_with_to_module(runner)
14
+ end
15
+ end
16
+
17
+ private
18
+
19
+ def runner_with_to_module(runner)
20
+ return runner if runner.is_a?(::Module)
21
+
22
+ "EacCli::RunnerWith::#{runner.to_s.camelize}".constantize
23
+ end
24
+ end
@@ -10,40 +10,77 @@ module EacCli
10
10
  require_sub __FILE__
11
11
  extend ::ActiveSupport::Concern
12
12
 
13
+ class << self
14
+ def alias_runner_class_methods(klass, from_suffix, to_suffix)
15
+ %i[create run].each do |method|
16
+ alias_class_method(klass, build_method_name(method, from_suffix),
17
+ build_method_name(method, to_suffix))
18
+ end
19
+ end
20
+
21
+ private
22
+
23
+ def alias_class_method(klass, from, to)
24
+ sklass = klass.singleton_class
25
+ return unless sklass.method_defined?(from)
26
+
27
+ sklass.alias_method to, from
28
+ end
29
+
30
+ def build_method_name(name, suffix)
31
+ ss = suffix.if_present('') { |s| "#{s}_" }
32
+ "#{ss}#{name}"
33
+ end
34
+ end
35
+
36
+ the_module = self
13
37
  included do
14
- extend ClassMethods
38
+ the_module.alias_runner_class_methods(self, '', 'original')
39
+
40
+ extend AfterClassMethods
15
41
  include InstanceMethods
16
42
  ::EacCli::Docopt::RunnerExtension.check(self)
17
43
  end
18
44
 
19
- module ClassMethods
20
- def create(*context_args)
45
+ module AfterClassMethods
46
+ def create(*runner_context_args)
21
47
  r = new
22
- r.context = ::EacCli::Runner::Context.new(*context_args)
48
+ r.runner_context = ::EacCli::Runner::Context.new(*runner_context_args)
49
+ r
50
+ end
51
+
52
+ def run(*runner_context_args)
53
+ r = create(*runner_context_args)
54
+ r.parsed
55
+ r.run
23
56
  r
24
57
  end
25
58
 
26
59
  def runner_definition(&block)
27
- @runner_definition ||= ::EacCli::Definition.new
60
+ @runner_definition ||= super_runner_definition
28
61
  @runner_definition.instance_eval(&block) if block
29
62
  @runner_definition
30
63
  end
64
+
65
+ def super_runner_definition
66
+ superclass.try(:runner_definition).if_present(&:dup) || ::EacCli::Definition.new
67
+ end
31
68
  end
32
69
 
33
70
  module InstanceMethods
34
- def context
35
- return @context if @context
71
+ def runner_context
72
+ return @runner_context if @runner_context
36
73
 
37
74
  raise 'Context was required, but was not set yet'
38
75
  end
39
76
 
40
- def context=(new_context)
41
- @context = new_context
77
+ def runner_context=(new_runner_context)
78
+ @runner_context = new_runner_context
42
79
  @parsed = nil
43
80
  end
44
81
 
45
82
  def parsed
46
- @parsed ||= ::EacCli::Parser.new(self.class.runner_definition).parse(context.argv)
83
+ @parsed ||= ::EacCli::Parser.new(self.class.runner_definition).parse(runner_context.argv)
47
84
  end
48
85
  end
49
86
  end
@@ -9,7 +9,7 @@ module EacCli
9
9
 
10
10
  def initialize(*context_args)
11
11
  options = context_args.extract_options!
12
- @argv = (context_args[0] || options.delete(:argv)).freeze
12
+ @argv = (context_args[0] || options.delete(:argv) || ARGV).dup.freeze
13
13
  @parent = context_args[1] || options.delete(:parent)
14
14
  @program_name = options.delete(:program_name)
15
15
  end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module EacCli
6
+ module RunnerWith
7
+ require_sub __FILE__
8
+ end
9
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_cli/runner'
4
+ require 'eac_ruby_utils/core_ext'
5
+
6
+ module EacCli
7
+ module RunnerWith
8
+ module Help
9
+ common_concern do
10
+ include ::EacCli::Runner
11
+
12
+ runner_definition.alt do
13
+ options_arg false
14
+ bool_opt '-h', '--help', 'Show help.', usage: true
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_cli/runner'
4
+ require 'eac_ruby_utils/core_ext'
5
+
6
+ module EacCli
7
+ module RunnerWith
8
+ module OutputFile
9
+ common_concern do
10
+ include ::EacCli::Runner
11
+
12
+ runner_definition do
13
+ arg_opt '-o', '--output-file', 'Output to file.'
14
+ end
15
+ end
16
+
17
+ def run_output
18
+ if parsed.output_file.present?
19
+ ::File.write(parsed.output_file, output_content)
20
+ else
21
+ out output_content
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacCli
4
- VERSION = '0.5.0'
4
+ VERSION = '0.8.0'
5
5
  end
@@ -21,10 +21,10 @@ module EacRubyUtils
21
21
 
22
22
  class Setup
23
23
  include ::EacRubyUtils::SimpleCache
24
- attr_reader :a_module, :common_constructor
24
+ attr_reader :a_module, :common_concern
25
25
 
26
- def initialize(common_constructor, a_module)
27
- @common_constructor = common_constructor
26
+ def initialize(common_concern, a_module)
27
+ @common_concern = common_concern
28
28
  @a_module = a_module
29
29
  end
30
30
 
@@ -47,7 +47,7 @@ module EacRubyUtils
47
47
  end
48
48
 
49
49
  def setup_after_callback(base)
50
- common_constructor.after_callback.if_present do |v|
50
+ common_concern.after_callback.if_present do |v|
51
51
  base.instance_eval(&v)
52
52
  end
53
53
  end
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'eac_ruby_utils/inflector'
4
+
3
5
  module EacRubyUtils
4
6
  module Listable
5
7
  class Value
@@ -16,8 +18,7 @@ module EacRubyUtils
16
18
  end
17
19
 
18
20
  def constant_name
19
- "#{@list.item}_#{@key}".gsub(/[^a-z0-9_]/, '_').gsub(/_+/, '_')
20
- .gsub(/(?:\A_|_\z)/, '').upcase
21
+ ::EacRubyUtils::Inflector.variableize("#{@list.item}_#{@key}").upcase
21
22
  end
22
23
 
23
24
  def label
@@ -21,8 +21,12 @@ module EacRubyUtils
21
21
  end
22
22
  end
23
23
 
24
- def reset_cache
25
- @cache_keys = nil
24
+ def reset_cache(*keys)
25
+ if keys.any?
26
+ keys.each { |key| cache_keys.delete(key) }
27
+ else
28
+ @cache_keys = nil
29
+ end
26
30
  end
27
31
 
28
32
  private
@@ -27,6 +27,12 @@ module EacRubyUtils
27
27
  property_method?(method_name) || super
28
28
  end
29
29
 
30
+ def to_h
31
+ data.dup
32
+ end
33
+
34
+ delegate :to_s, to: :data
35
+
30
36
  private
31
37
 
32
38
  attr_accessor :data
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacRubyUtils
4
- VERSION = '0.45.0'
4
+ VERSION = '0.46.0'
5
5
  end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ # Declare your gem's dependencies in users_support.gemspec.
6
+ # Bundler will treat runtime dependencies like base dependencies, and
7
+ # development dependencies will be added by default to the :development group.
8
+ gemspec
9
+
10
+ # Declare any dependencies that are still in development here instead of in
11
+ # your gemspec. These might include edge Rails or gems from your path or
12
+ # Git. Remember to move these dependencies to your gemspec before releasing
13
+ # your gem to rubygems.org.
14
+
15
+ # To use a debugger
16
+ # gem 'byebug', group: [:development, :test]
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ $LOAD_PATH.push File.expand_path('lib', __dir__)
4
+
5
+ # Maintain your gem's version:
6
+ require 'ehbrs_ruby_utils/version'
7
+
8
+ # Describe your gem and declare its dependencies:
9
+ Gem::Specification.new do |s|
10
+ s.name = 'ehbrs_ruby_utils'
11
+ s.version = ::EhbrsRubyUtils::VERSION
12
+ s.authors = ['Eduardo H. Bogoni']
13
+ s.summary = 'Utilities for EHB/RS\'s Ruby projects.'
14
+
15
+ s.files = Dir['{lib}/**/*']
16
+
17
+ s.add_dependency 'eac_ruby_utils', '~> 0.36'
18
+
19
+ s.add_development_dependency 'eac_ruby_gem_support', '~> 0.1', '>= 0.1.1'
20
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module EhbrsRubyUtils
6
+ require_sub __FILE__
7
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/envs'
4
+ require 'eac_ruby_utils/core_ext'
5
+
6
+ module EhbrsRubyUtils
7
+ module Executables
8
+ class << self
9
+ enable_simple_cache
10
+
11
+ def env
12
+ ::EacRubyUtils::Envs.local
13
+ end
14
+
15
+ private
16
+
17
+ {
18
+ '-version' => %w[ffprobe]
19
+ }.each do |validate_arg, commands|
20
+ commands.each do |command|
21
+ define_method("#{command}_uncached") do
22
+ env.executable(command, validate_arg)
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EhbrsRubyUtils
4
+ VERSION = '0.2.0'
5
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module EhbrsRubyUtils
6
+ module Videos
7
+ require_sub __FILE__
8
+ end
9
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module EhbrsRubyUtils
6
+ module Videos
7
+ module Container
8
+ require_sub __FILE__
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'json'
4
+ require 'eac_ruby_utils/core_ext'
5
+ require 'ehbrs_ruby_utils/executables'
6
+ require 'ehbrs_ruby_utils/videos/container/info'
7
+
8
+ module EhbrsRubyUtils
9
+ module Videos
10
+ module Container
11
+ class File
12
+ enable_simple_cache
13
+ common_constructor :path do
14
+ self.path = path.to_pathname
15
+ end
16
+
17
+ private
18
+
19
+ def info_uncached
20
+ ::EhbrsRubyUtils::Videos::Container::Info.new(
21
+ ::JSON.parse(
22
+ ::EhbrsRubyUtils::Executables.ffprobe.command(
23
+ '-hide_banner', '-print_format', 'json', '-show_format', '-show_streams', path
24
+ ).execute!
25
+ )
26
+ )
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+ require 'ehbrs_ruby_utils/videos/container/info'
5
+
6
+ module EhbrsRubyUtils
7
+ module Videos
8
+ module Container
9
+ class Info
10
+ enable_simple_cache
11
+ common_constructor :ffprobe_data do
12
+ self.ffprobe_data = ffprobe_data.with_indifferent_access.freeze
13
+ end
14
+
15
+ def to_h
16
+ ffprobe_data
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,68 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module EhbrsRubyUtils
6
+ module Videos
7
+ class Quality
8
+ enable_simple_cache
9
+ include ::Comparable
10
+
11
+ POSITIVE_MARGIN = 0.75
12
+ LIST = [240, 480, 720, 1080, 2160].freeze
13
+
14
+ class << self
15
+ enable_simple_cache
16
+
17
+ def by_height(height)
18
+ list.find { |v| v.height == height }
19
+ end
20
+
21
+ private
22
+
23
+ def list_uncached
24
+ preceding = nil
25
+ LIST.map { |height| preceding = new(height, preceding) }
26
+ end
27
+ end
28
+
29
+ attr_reader :following
30
+
31
+ common_constructor :height, :preceding do
32
+ preceding&.send('following=', self)
33
+ end
34
+
35
+ def <=>(other)
36
+ height <=> other.height
37
+ end
38
+
39
+ def to_s
40
+ height.to_s
41
+ end
42
+
43
+ def to_xs
44
+ "#{height} (Min: #{min_height}, Max: #{max_height})"
45
+ end
46
+
47
+ def resolution_match?(resolution)
48
+ (min_height.blank? || resolution.lower >= min_height) &&
49
+ (max_height.blank? || resolution.lower <= max_height)
50
+ end
51
+
52
+ private
53
+
54
+ attr_writer :following
55
+
56
+ def max_height_uncached
57
+ following.if_present do |v|
58
+ delta = v.height - height
59
+ height + (delta * POSITIVE_MARGIN).to_i
60
+ end
61
+ end
62
+
63
+ def min_height_uncached
64
+ preceding.if_present { |v| v.max_height + 1 }
65
+ end
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,68 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+ require 'ehbrs_ruby_utils/videos/quality'
5
+
6
+ module EhbrsRubyUtils
7
+ module Videos
8
+ class Resolution
9
+ enable_simple_cache
10
+ include ::Comparable
11
+
12
+ class << self
13
+ def valid_dimension?(dimension)
14
+ dimension.is_a?(::Integer) && dimension.positive?
15
+ end
16
+ end
17
+
18
+ common_constructor :width, :height
19
+
20
+ def <=>(other)
21
+ r = (lower <=> other.lower)
22
+ return r unless r.zero?
23
+
24
+ higher <=> other.higher
25
+ end
26
+
27
+ def to_xs
28
+ [quality_to_s, resolution_to_s].join(' / ')
29
+ end
30
+
31
+ def higher
32
+ width > height ? width : height
33
+ end
34
+
35
+ def lower
36
+ width < height ? width : height
37
+ end
38
+
39
+ def pixels
40
+ width * height
41
+ end
42
+
43
+ def quality_to_s
44
+ quality.if_present('?', &:to_s)
45
+ end
46
+
47
+ def resolution_to_s
48
+ "#{width}x#{height}"
49
+ end
50
+
51
+ def to_s
52
+ resolution_to_s
53
+ end
54
+
55
+ def valid?
56
+ [width, height].all? { |d| self.class.valid_dimension?(d) }
57
+ end
58
+
59
+ private
60
+
61
+ def quality_uncached
62
+ ::EhbrsRubyUtils::Videos::Quality.list
63
+ .find { |quality| quality.resolution_match?(self) } ||
64
+ raise("No quality matches resolution #{resolution}")
65
+ end
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'ehbrs_ruby_utils/videos/resolution'
4
+
5
+ RSpec.describe ::EhbrsRubyUtils::Videos::Resolution do
6
+ describe '#quality' do
7
+ { [500, 720] => 480, [1080, 720] => 720, [1, 1] => 240, [9999, 9999] => 2160,
8
+ [480, 420] => 240, [480, 421] => 480 }.each do |resolution_parts, quality_height|
9
+ context "when resolution is #{described_class.new(*resolution_parts).to_xs}" do
10
+ let(:instance) { described_class.new(*resolution_parts) }
11
+
12
+ it "quality is #{::EhbrsRubyUtils::Videos::Quality.by_height(quality_height).to_xs}" do
13
+ expect(instance.quality.height).to eq(quality_height)
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_gem_support/spec/examples/rubocop_check'
4
+
5
+ RSpec.describe ::RuboCop do
6
+ include_examples 'rubocop_check', ::File.expand_path('..', __dir__)
7
+ end
@@ -0,0 +1,100 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This file was generated by the `rspec --init` command. Conventionally, all
4
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
5
+ # The generated `.rspec` file contains `--require spec_helper` which will cause
6
+ # this file to always be loaded, without a need to explicitly require it in any
7
+ # files.
8
+ #
9
+ # Given that it is always loaded, you are encouraged to keep this file as
10
+ # light-weight as possible. Requiring heavyweight dependencies from this file
11
+ # will add to the boot time of your test suite on EVERY test run, even for an
12
+ # individual file that may not need all of that loaded. Instead, consider making
13
+ # a separate helper file that requires the additional dependencies and performs
14
+ # the additional setup, and require it from the spec files that actually need
15
+ # it.
16
+ #
17
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
18
+ RSpec.configure do |config|
19
+ # rspec-expectations config goes here. You can use an alternate
20
+ # assertion/expectation library such as wrong or the stdlib/minitest
21
+ # assertions if you prefer.
22
+ config.expect_with :rspec do |expectations|
23
+ # This option will default to `true` in RSpec 4. It makes the `description`
24
+ # and `failure_message` of custom matchers include text for helper methods
25
+ # defined using `chain`, e.g.:
26
+ # be_bigger_than(2).and_smaller_than(4).description
27
+ # # => "be bigger than 2 and smaller than 4"
28
+ # ...rather than:
29
+ # # => "be bigger than 2"
30
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
31
+ end
32
+
33
+ # rspec-mocks config goes here. You can use an alternate test double
34
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
35
+ config.mock_with :rspec do |mocks|
36
+ # Prevents you from mocking or stubbing a method that does not exist on
37
+ # a real object. This is generally recommended, and will default to
38
+ # `true` in RSpec 4.
39
+ mocks.verify_partial_doubles = true
40
+ end
41
+
42
+ # This option will default to `:apply_to_host_groups` in RSpec 4 (and will
43
+ # have no way to turn it off -- the option exists only for backwards
44
+ # compatibility in RSpec 3). It causes shared context metadata to be
45
+ # inherited by the metadata hash of host groups and examples, rather than
46
+ # triggering implicit auto-inclusion in groups with matching metadata.
47
+ config.shared_context_metadata_behavior = :apply_to_host_groups
48
+
49
+ # The settings below are suggested to provide a good initial experience
50
+ # with RSpec, but feel free to customize to your heart's content.
51
+ # # This allows you to limit a spec run to individual examples or groups
52
+ # # you care about by tagging them with `:focus` metadata. When nothing
53
+ # # is tagged with `:focus`, all examples get run. RSpec also provides
54
+ # # aliases for `it`, `describe`, and `context` that include `:focus`
55
+ # # metadata: `fit`, `fdescribe` and `fcontext`, respectively.
56
+ # config.filter_run_when_matching :focus
57
+ #
58
+ # # Allows RSpec to persist some state between runs in order to support
59
+ # # the `--only-failures` and `--next-failure` CLI options. We recommend
60
+ # # you configure your source control system to ignore this file.
61
+ # config.example_status_persistence_file_path = "spec/examples.txt"
62
+ #
63
+ # # Limits the available syntax to the non-monkey patched syntax that is
64
+ # # recommended. For more details, see:
65
+ # # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
66
+ # # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
67
+ # # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
68
+ # config.disable_monkey_patching!
69
+ #
70
+ # # This setting enables warnings. It's recommended, but in some cases may
71
+ # # be too noisy due to issues in dependencies.
72
+ # config.warnings = true
73
+ #
74
+ # # Many RSpec users commonly either run the entire suite or an individual
75
+ # # file, and it's useful to allow more verbose output when running an
76
+ # # individual spec file.
77
+ # if config.files_to_run.one?
78
+ # # Use the documentation formatter for detailed output,
79
+ # # unless a formatter has already been configured
80
+ # # (e.g. via a command-line flag).
81
+ # config.default_formatter = "doc"
82
+ # end
83
+ #
84
+ # # Print the 10 slowest examples and example groups at the
85
+ # # end of the spec run, to help surface which specs are running
86
+ # # particularly slow.
87
+ # config.profile_examples = 10
88
+ #
89
+ # # Run specs in random order to surface order dependencies. If you find an
90
+ # # order dependency and want to debug it, you can fix the order by providing
91
+ # # the seed, which is printed after each run.
92
+ # # --seed 1234
93
+ # config.order = :random
94
+ #
95
+ # # Seed global randomization in this process using the `--seed` CLI option.
96
+ # # Setting this allows you to use `--seed` to deterministically reproduce
97
+ # # test failures related to randomization by passing the same `--seed` value
98
+ # # as the one that triggered the failure.
99
+ # Kernel.srand config.seed
100
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ehbrs-tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.1
4
+ version: 0.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Esquilo Azul Company
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-09-13 00:00:00.000000000 Z
11
+ date: 2020-09-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: avm-tools
@@ -120,6 +120,7 @@ files:
120
120
  - lib/ehbrs/runner/vg/wii.rb
121
121
  - lib/ehbrs/runner/videos.rb
122
122
  - lib/ehbrs/runner/videos/extract.rb
123
+ - lib/ehbrs/runner/videos/probe.rb
123
124
  - lib/ehbrs/runner/videos/series.rb
124
125
  - lib/ehbrs/runner/videos/series/rename.rb
125
126
  - lib/ehbrs/runner/videos/unsupported.rb
@@ -192,6 +193,7 @@ files:
192
193
  - vendor/eac_cli/Gemfile
193
194
  - vendor/eac_cli/eac_cli.gemspec
194
195
  - vendor/eac_cli/lib/eac_cli.rb
196
+ - vendor/eac_cli/lib/eac_cli/core_ext.rb
195
197
  - vendor/eac_cli/lib/eac_cli/default_runner.rb
196
198
  - vendor/eac_cli/lib/eac_cli/definition.rb
197
199
  - vendor/eac_cli/lib/eac_cli/definition/argument_option.rb
@@ -206,8 +208,14 @@ files:
206
208
  - vendor/eac_cli/lib/eac_cli/parser/options_collection.rb
207
209
  - vendor/eac_cli/lib/eac_cli/parser/parse_result.rb
208
210
  - vendor/eac_cli/lib/eac_cli/parser/positional_collection.rb
211
+ - vendor/eac_cli/lib/eac_cli/patches.rb
212
+ - vendor/eac_cli/lib/eac_cli/patches/object.rb
213
+ - vendor/eac_cli/lib/eac_cli/patches/object/runner_with.rb
209
214
  - vendor/eac_cli/lib/eac_cli/runner.rb
210
215
  - vendor/eac_cli/lib/eac_cli/runner/context.rb
216
+ - vendor/eac_cli/lib/eac_cli/runner_with.rb
217
+ - vendor/eac_cli/lib/eac_cli/runner_with/help.rb
218
+ - vendor/eac_cli/lib/eac_cli/runner_with/output_file.rb
211
219
  - vendor/eac_cli/lib/eac_cli/version.rb
212
220
  - vendor/eac_cli/spec/lib/eac_cli/runner_spec.rb
213
221
  - vendor/eac_cli/spec/rubocop_spec.rb
@@ -396,6 +404,20 @@ files:
396
404
  - vendor/eac_ruby_utils/spec/locales/pt-BR.yml
397
405
  - vendor/eac_ruby_utils/spec/rubocop_check_spec.rb
398
406
  - vendor/eac_ruby_utils/spec/spec_helper.rb
407
+ - vendor/ehbrs_ruby_utils/Gemfile
408
+ - vendor/ehbrs_ruby_utils/ehbrs_ruby_utils.gemspec
409
+ - vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils.rb
410
+ - vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/executables.rb
411
+ - vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/version.rb
412
+ - vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/videos.rb
413
+ - vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/videos/container.rb
414
+ - vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/videos/container/file.rb
415
+ - vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/videos/container/info.rb
416
+ - vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/videos/quality.rb
417
+ - vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/videos/resolution.rb
418
+ - vendor/ehbrs_ruby_utils/spec/lib/ehbrs_ruby_utils/videos/resolution_spec.rb
419
+ - vendor/ehbrs_ruby_utils/spec/rubocop_check_spec.rb
420
+ - vendor/ehbrs_ruby_utils/spec/spec_helper.rb
399
421
  homepage:
400
422
  licenses: []
401
423
  metadata: {}