ehbrs-tools 0.13.1 → 0.16.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ehbrs/executables.rb +1 -1
- data/lib/ehbrs/runner.rb +4 -7
- data/lib/ehbrs/runner/finances.rb +4 -7
- data/lib/ehbrs/runner/finances/bb_browser.rb +5 -10
- data/lib/ehbrs/runner/fs.rb +4 -7
- data/lib/ehbrs/runner/fs/used_space.rb +4 -5
- data/lib/ehbrs/runner/google.rb +4 -7
- data/lib/ehbrs/runner/google/translate.rb +7 -12
- data/lib/ehbrs/runner/self.rb +4 -7
- data/lib/ehbrs/runner/self/test.rb +5 -10
- data/lib/ehbrs/runner/vg.rb +4 -7
- data/lib/ehbrs/runner/vg/ips.rb +9 -14
- data/lib/ehbrs/runner/vg/wii.rb +10 -13
- data/lib/ehbrs/runner/videos.rb +7 -14
- data/lib/ehbrs/runner/videos/extract.rb +10 -13
- data/lib/ehbrs/runner/videos/probe.rb +32 -0
- data/lib/ehbrs/runner/videos/series.rb +5 -8
- data/lib/ehbrs/runner/videos/series/rename.rb +9 -12
- data/lib/ehbrs/runner/videos/unsupported.rb +9 -13
- data/lib/ehbrs/runner/web_utils.rb +24 -0
- data/lib/ehbrs/runner/web_utils/videos.rb +18 -0
- data/lib/ehbrs/runner/web_utils/videos/download.rb +63 -0
- data/lib/ehbrs/runner/web_utils/videos/upload.rb +75 -0
- data/lib/ehbrs/tools/version.rb +1 -1
- data/lib/ehbrs/vg/wii/wit/parsers/dump.rb +10 -5
- data/lib/ehbrs/videos/file.rb +2 -1
- data/lib/ehbrs/videos/series/rename/file/options.rb +3 -13
- data/lib/ehbrs/videos/unsupported/fix_profile.rb +1 -0
- data/vendor/aranha-parsers/Gemfile +5 -0
- data/vendor/aranha-parsers/aranha-parsers.gemspec +23 -0
- data/vendor/aranha-parsers/lib/aranha/parsers.rb +9 -0
- data/vendor/aranha-parsers/lib/aranha/parsers/base.rb +79 -0
- data/vendor/aranha-parsers/lib/aranha/parsers/html.rb +11 -0
- data/vendor/aranha-parsers/lib/aranha/parsers/html/base.rb +47 -0
- data/vendor/aranha-parsers/lib/aranha/parsers/html/item.rb +24 -0
- data/vendor/aranha-parsers/lib/aranha/parsers/html/item_list.rb +29 -0
- data/vendor/aranha-parsers/lib/aranha/parsers/html/node.rb +13 -0
- data/vendor/aranha-parsers/lib/aranha/parsers/html/node/base.rb +36 -0
- data/vendor/aranha-parsers/lib/aranha/parsers/html/node/default.rb +126 -0
- data/vendor/aranha-parsers/lib/aranha/parsers/invalid_state_exception.rb +8 -0
- data/vendor/aranha-parsers/lib/aranha/parsers/patches.rb +11 -0
- data/vendor/aranha-parsers/lib/aranha/parsers/patches/ofx_parser.rb +38 -0
- data/vendor/aranha-parsers/lib/aranha/parsers/source_address.rb +55 -0
- data/vendor/aranha-parsers/lib/aranha/parsers/source_address/file.rb +31 -0
- data/vendor/aranha-parsers/lib/aranha/parsers/source_address/hash_http_get.rb +25 -0
- data/vendor/aranha-parsers/lib/aranha/parsers/source_address/hash_http_post.rb +45 -0
- data/vendor/aranha-parsers/lib/aranha/parsers/source_address/http_get.rb +49 -0
- data/vendor/aranha-parsers/lib/aranha/parsers/source_target_fixtures.rb +77 -0
- data/vendor/aranha-parsers/lib/aranha/parsers/spec/source_target_fixtures_example.rb +70 -0
- data/vendor/aranha-parsers/lib/aranha/parsers/version.rb +7 -0
- data/vendor/aranha-parsers/spec/lib/aranha/parsers/source_address/http_get_spec.rb +21 -0
- data/vendor/aranha-parsers/spec/lib/aranha/parsers/source_address_spec.rb +74 -0
- data/vendor/aranha-parsers/spec/lib/aranha/parsers/source_target_fixtures_spec.rb +27 -0
- data/vendor/aranha-parsers/spec/lib/aranha/parsers/source_target_fixtures_spec_files/stub1.source.txt +1 -0
- data/vendor/aranha-parsers/spec/lib/aranha/parsers/source_target_fixtures_spec_files/stub1.target.html +1 -0
- data/vendor/aranha-parsers/spec/lib/aranha/parsers/source_target_fixtures_spec_files/stub2.source.html +1 -0
- data/vendor/aranha-parsers/spec/lib/aranha/parsers/source_target_fixtures_spec_files/stub3.target.yaml +1 -0
- data/vendor/aranha-parsers/spec/lib/rubocop_check_spec.rb +7 -0
- data/vendor/aranha-parsers/spec/spec_helper.rb +8 -0
- data/vendor/eac_cli/eac_cli.gemspec +1 -1
- data/vendor/eac_cli/lib/eac_cli/core_ext.rb +4 -0
- data/vendor/eac_cli/lib/eac_cli/default_runner.rb +6 -14
- data/vendor/eac_cli/lib/eac_cli/definition.rb +35 -3
- data/vendor/eac_cli/lib/eac_cli/definition/base_option.rb +17 -1
- data/vendor/eac_cli/lib/eac_cli/definition/help_formatter.rb +76 -0
- data/vendor/eac_cli/lib/eac_cli/definition/positional_argument.rb +21 -4
- data/vendor/eac_cli/lib/eac_cli/docopt/runner_extension.rb +4 -9
- data/vendor/eac_cli/lib/eac_cli/parser/collector.rb +4 -0
- data/vendor/eac_cli/lib/eac_cli/parser/options_collection.rb +27 -64
- data/vendor/eac_cli/lib/eac_cli/parser/parse_result.rb +17 -0
- data/vendor/eac_cli/lib/eac_cli/parser/positional_collection.rb +47 -19
- data/vendor/eac_cli/lib/eac_cli/patches.rb +4 -0
- data/vendor/eac_cli/lib/eac_cli/patches/object.rb +5 -0
- data/vendor/eac_cli/lib/eac_cli/patches/object/runner_with.rb +25 -0
- data/vendor/eac_cli/lib/eac_cli/runner.rb +51 -10
- data/vendor/eac_cli/lib/eac_cli/runner/context.rb +20 -3
- data/vendor/eac_cli/lib/eac_cli/runner_with.rb +9 -0
- data/vendor/eac_cli/lib/eac_cli/runner_with/help.rb +19 -0
- data/vendor/eac_cli/lib/eac_cli/runner_with/output_file.rb +26 -0
- data/vendor/eac_cli/lib/eac_cli/runner_with/subcommands.rb +96 -0
- data/vendor/eac_cli/lib/eac_cli/version.rb +1 -1
- data/vendor/eac_cli/spec/lib/eac_cli/docopt/runner_extension_spec.rb +25 -0
- data/vendor/eac_cli/spec/lib/eac_cli/runner_spec.rb +48 -40
- data/vendor/eac_cli/spec/lib/eac_cli/runner_with/subcommands_spec.rb +57 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/blank_not_blank.rb +19 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_concern.rb +4 -4
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/configs/base.rb +43 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/configs/file.rb +12 -31
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs.rb +7 -104
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs/entry_reader.rb +81 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs/password_entry_reader.rb +18 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs/read_entry_options.rb +46 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs/store_passwords_entry_reader.rb +27 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/fs/clearable_directory.rb +57 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/listable/value.rb +3 -2
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/enumerator.rb +4 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/enumerator/current.rb +9 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/enumerator/stopped.rb +14 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/object/debug.rb +17 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/paths_hash.rb +21 -58
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/paths_hash/entry_key_error.rb +8 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/paths_hash/node.rb +67 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/paths_hash/path_search.rb +39 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/ruby/command.rb +2 -1
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/simple_cache.rb +6 -2
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/struct.rb +10 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/version.rb +1 -1
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/blank_not_blank_spec.rb +16 -0
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/configs_spec.rb +15 -0
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/enumerator/current_spec.rb +26 -0
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/enumerator/stopped_spec.rb +32 -0
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/paths_hash_spec.rb +52 -13
- data/vendor/ehbrs_ruby_utils/Gemfile +16 -0
- data/vendor/ehbrs_ruby_utils/ehbrs_ruby_utils.gemspec +20 -0
- data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils.rb +7 -0
- data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/executables.rb +28 -0
- data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/version.rb +5 -0
- data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/videos.rb +9 -0
- data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/videos/container.rb +11 -0
- data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/videos/container/file.rb +31 -0
- data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/videos/container/info.rb +21 -0
- data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/videos/quality.rb +68 -0
- data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/videos/resolution.rb +68 -0
- data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/web_utils.rb +9 -0
- data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/web_utils/instance.rb +32 -0
- data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/web_utils/videos.rb +11 -0
- data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/web_utils/videos/file.rb +40 -0
- data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/web_utils/videos/files_list.rb +76 -0
- data/vendor/ehbrs_ruby_utils/spec/lib/ehbrs_ruby_utils/videos/resolution_spec.rb +18 -0
- data/vendor/ehbrs_ruby_utils/spec/rubocop_check_spec.rb +7 -0
- data/vendor/ehbrs_ruby_utils/spec/spec_helper.rb +100 -0
- metadata +85 -2
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module EacRubyUtils
|
4
|
+
class PathsHash
|
5
|
+
class PathSearch
|
6
|
+
class << self
|
7
|
+
def parse_entry_key(string)
|
8
|
+
new(::EacRubyUtils::PathsHash.parse_entry_key(string), [])
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
common_constructor :current, :previous do
|
13
|
+
self.current = current.assert_argument(Array, 'current').freeze
|
14
|
+
self.previous = previous.assert_argument(Array, 'previous')
|
15
|
+
raise ::EacRubyUtils::PathsHash::EntryKeyError, 'Current is empty' if current.empty?
|
16
|
+
end
|
17
|
+
|
18
|
+
def cursor
|
19
|
+
current.first
|
20
|
+
end
|
21
|
+
|
22
|
+
def ended?
|
23
|
+
current.count <= 1
|
24
|
+
end
|
25
|
+
|
26
|
+
def raise_error(message)
|
27
|
+
raise ::EacRubyUtils::PathsHash::EntryKeyError, "#{message} (#{self})"
|
28
|
+
end
|
29
|
+
|
30
|
+
def succeeding
|
31
|
+
self.class.new(current[1..-1], previous + [cursor])
|
32
|
+
end
|
33
|
+
|
34
|
+
def to_s
|
35
|
+
"#{self.class}[Current: #{current}, Previous: #{previous}]"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -8,7 +8,8 @@ module EacRubyUtils
|
|
8
8
|
# A [EacRubyUtils::Envs::Command] which runs in a clean Ruby environment.
|
9
9
|
class Command < ::EacRubyUtils::Envs::Command
|
10
10
|
def initialize(bundle_args, extra_options = {})
|
11
|
-
|
11
|
+
host_env = extra_options.delete(:host_env)
|
12
|
+
super(host_env || ::EacRubyUtils::Envs.local, bundle_args, extra_options)
|
12
13
|
end
|
13
14
|
|
14
15
|
%w[system execute].each do |method_prefix|
|
@@ -27,6 +27,16 @@ module EacRubyUtils
|
|
27
27
|
property_method?(method_name) || super
|
28
28
|
end
|
29
29
|
|
30
|
+
def slice_fetch(*keys)
|
31
|
+
self.class.new(keys.map { |key| [key, fetch(key)] }.to_h)
|
32
|
+
end
|
33
|
+
|
34
|
+
def to_h
|
35
|
+
data.dup
|
36
|
+
end
|
37
|
+
|
38
|
+
delegate :to_s, to: :data
|
39
|
+
|
30
40
|
private
|
31
41
|
|
32
42
|
attr_accessor :data
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/blank_not_blank'
|
4
|
+
|
5
|
+
RSpec.describe ::EacRubyUtils::BlankNotBlank do
|
6
|
+
let(:instance) { described_class.instance }
|
7
|
+
|
8
|
+
it do
|
9
|
+
expect { described_class.new }.to raise_error(::NoMethodError)
|
10
|
+
end
|
11
|
+
|
12
|
+
it { expect(instance).to be_present }
|
13
|
+
it { expect(instance).not_to be_blank }
|
14
|
+
it { expect(instance).to be_truthy }
|
15
|
+
it { expect(instance).to eq('') }
|
16
|
+
end
|
@@ -28,4 +28,19 @@ RSpec.describe ::EacRubyUtils::Configs do
|
|
28
28
|
|
29
29
|
it { expect(::YAML.load_file(storage_path)).to eq(parent: { child: 'value1' }) }
|
30
30
|
end
|
31
|
+
|
32
|
+
describe '#read' do
|
33
|
+
let(:present_key) { 'a.present.key' }
|
34
|
+
let(:blank_key) { 'a.blank.key' }
|
35
|
+
|
36
|
+
before do
|
37
|
+
instance[present_key] = 'A value'
|
38
|
+
instance[blank_key] = ''
|
39
|
+
instance.save
|
40
|
+
instance.load
|
41
|
+
end
|
42
|
+
|
43
|
+
it { expect(instance[present_key]).to be_present }
|
44
|
+
it { expect(instance[blank_key]).to be_present }
|
45
|
+
end
|
31
46
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/patches/enumerator/current'
|
4
|
+
|
5
|
+
RSpec.describe ::Enumerator do
|
6
|
+
let(:list) { %w[a b] }
|
7
|
+
let(:instance) { list.each }
|
8
|
+
|
9
|
+
it { expect(instance).to be_a(described_class) }
|
10
|
+
it { expect(instance.current).to eq('a') }
|
11
|
+
|
12
|
+
context 'with first next' do
|
13
|
+
before { instance.next }
|
14
|
+
|
15
|
+
it { expect(instance.current).to eq('b') }
|
16
|
+
end
|
17
|
+
|
18
|
+
context 'with last next' do
|
19
|
+
before do
|
20
|
+
instance.next
|
21
|
+
instance.next
|
22
|
+
end
|
23
|
+
|
24
|
+
it { expect(instance.current).to eq(nil) }
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/patches/enumerator/stopped'
|
4
|
+
|
5
|
+
RSpec.describe ::Enumerator do
|
6
|
+
let(:list) { %w[a b] }
|
7
|
+
let(:instance) { list.each }
|
8
|
+
|
9
|
+
it { expect(instance).to be_a(described_class) }
|
10
|
+
it { expect(instance.peek).to eq('a') }
|
11
|
+
it { expect(instance).to be_ongoing }
|
12
|
+
it { expect(instance).not_to be_stopped }
|
13
|
+
|
14
|
+
context 'with first next' do
|
15
|
+
before { instance.next }
|
16
|
+
|
17
|
+
it { expect(instance.peek).to eq('b') }
|
18
|
+
it { expect(instance).to be_ongoing }
|
19
|
+
it { expect(instance).not_to be_stopped }
|
20
|
+
end
|
21
|
+
|
22
|
+
context 'with last next' do
|
23
|
+
before do
|
24
|
+
instance.next
|
25
|
+
instance.next
|
26
|
+
end
|
27
|
+
|
28
|
+
it { expect { instance.peek }.to raise_error(::StopIteration) }
|
29
|
+
it { expect(instance).not_to be_ongoing }
|
30
|
+
it { expect(instance).to be_stopped }
|
31
|
+
end
|
32
|
+
end
|
@@ -3,20 +3,20 @@
|
|
3
3
|
require 'eac_ruby_utils/paths_hash'
|
4
4
|
|
5
5
|
RSpec.describe ::EacRubyUtils::PathsHash do
|
6
|
-
|
7
|
-
|
8
|
-
{
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
child2: 'v2'
|
15
|
-
}
|
6
|
+
let(:source_hash) do
|
7
|
+
{
|
8
|
+
parent: {
|
9
|
+
child1: {
|
10
|
+
child1_1: 'v1_1',
|
11
|
+
child1_2: 'v1_2'
|
12
|
+
},
|
13
|
+
child2: 'v2'
|
16
14
|
}
|
17
|
-
|
18
|
-
|
15
|
+
}
|
16
|
+
end
|
17
|
+
let(:instance) { described_class.new(source_hash) }
|
19
18
|
|
19
|
+
describe '#[]' do
|
20
20
|
{
|
21
21
|
'parent.child1.child1_1' => 'v1_1',
|
22
22
|
'parent.child1.child1_2' => 'v1_2',
|
@@ -38,7 +38,7 @@ RSpec.describe ::EacRubyUtils::PathsHash do
|
|
38
38
|
end
|
39
39
|
|
40
40
|
describe '#[]=' do
|
41
|
-
let(:
|
41
|
+
let(:source_hash) { {} }
|
42
42
|
|
43
43
|
before do
|
44
44
|
instance['a.b.c'] = '123'
|
@@ -46,4 +46,43 @@ RSpec.describe ::EacRubyUtils::PathsHash do
|
|
46
46
|
|
47
47
|
it { expect(instance.to_h).to eq(a: { b: { c: '123' } }) }
|
48
48
|
end
|
49
|
+
|
50
|
+
describe '#fetch' do
|
51
|
+
{
|
52
|
+
'parent.child1.child1_1' => 'v1_1',
|
53
|
+
'parent.child1.child1_2' => 'v1_2',
|
54
|
+
'parent.child1.child1_2.no_exist' => ::EacRubyUtils::PathsHash::EntryKeyError,
|
55
|
+
'parent.child1.child1_3' => ::EacRubyUtils::PathsHash::EntryKeyError,
|
56
|
+
'parent.child2' => 'v2',
|
57
|
+
'no_exist' => ::EacRubyUtils::PathsHash::EntryKeyError,
|
58
|
+
'parent.child1' => {
|
59
|
+
child1_1: 'v1_1',
|
60
|
+
child1_2: 'v1_2'
|
61
|
+
}
|
62
|
+
}.each do |entry_key, expected_value|
|
63
|
+
if expected_value.is_a?(::Class) && expected_value < ::Exception
|
64
|
+
it "raise error #{expected_value}" do
|
65
|
+
expect { instance.fetch(entry_key) }.to raise_error(expected_value)
|
66
|
+
end
|
67
|
+
else
|
68
|
+
it "\#fetch return \"#{expected_value}\"" do
|
69
|
+
expect(instance.fetch(entry_key)).to eq(expected_value)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
describe '#key?' do
|
76
|
+
{
|
77
|
+
'parent.child1.child1_1' => true,
|
78
|
+
'parent.child1.child1_2' => true,
|
79
|
+
'parent.child1.child1_2.no_exist' => false,
|
80
|
+
'parent.child1.child1_3' => false,
|
81
|
+
'parent.child2' => true,
|
82
|
+
'no_exist' => false,
|
83
|
+
'parent.child1' => true
|
84
|
+
}.each do |entry_key, expected_value|
|
85
|
+
it { expect(instance.key?(entry_key)).to eq(expected_value) }
|
86
|
+
end
|
87
|
+
end
|
49
88
|
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,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,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
|