ehbrs-tools 0.24.0 → 0.27.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.avm.yml +4 -0
- data/.rspec +1 -0
- data/.rubocop.yml +39 -0
- data/Gemfile.lock +286 -0
- data/lib/ehbrs/{core_ext.rb → tools/core_ext.rb} +0 -0
- data/lib/ehbrs/tools/runner/finances/bb_browser.rb +1 -1
- data/lib/ehbrs/tools/runner/fs/selected.rb +19 -22
- data/lib/ehbrs/tools/runner/music/lyrics.rb +69 -0
- data/lib/ehbrs/tools/runner/web_utils/videos/download.rb +20 -10
- data/lib/ehbrs/tools/runner/web_utils/videos/upload.rb +1 -1
- data/lib/ehbrs/tools/version.rb +1 -1
- data/lib/ehbrs/videos/extract/package.rb +2 -2
- data/lib/ehbrs/videos/extract/package_file.rb +0 -1
- data/spec/code/rubocop_spec.rb +3 -0
- data/spec/lib/ehbrs/cooking_book/recipe/measure_spec.rb +21 -0
- data/spec/lib/ehbrs/observers/base_spec.rb +93 -0
- data/spec/lib/ehbrs/tools/runner/fs/used_space_spec.rb +61 -0
- data/spec/lib/ehbrs/tools/runner/vg/ips_spec.rb +31 -0
- data/spec/lib/ehbrs/tools/runner/vg/ips_spec_files/expected.rom +0 -0
- data/spec/lib/ehbrs/tools/runner/vg/ips_spec_files/patch_0.ips +0 -0
- data/spec/lib/ehbrs/tools/runner/vg/ips_spec_files/patch_1.ips +0 -0
- data/spec/lib/ehbrs/tools/runner/vg/ips_spec_files/source.rom +0 -0
- data/spec/lib/ehbrs/tools/runner/videos/probe_spec.rb +19 -0
- data/spec/lib/ehbrs/tools/runner/videos/probe_spec_files/fixed.target.yaml +105 -0
- data/spec/lib/ehbrs/tools/runner/videos/unsupported_spec.rb +75 -0
- data/spec/lib/ehbrs/tools/runner/videos/unsupported_spec_files/dts_audio.probe.yaml +90 -0
- data/spec/lib/ehbrs/tools/runner_spec.rb +16 -0
- data/spec/lib/ehbrs/vg/wii/game_file_spec.rb +21 -0
- data/spec/lib/ehbrs/vg/wii/wit/parsers/dump_spec.rb +11 -0
- data/spec/lib/ehbrs/vg/wii/wit/parsers/dump_spec_files/pikmin2_R92P01_wia.source.witdump +27 -0
- data/spec/lib/ehbrs/vg/wii/wit/parsers/dump_spec_files/pikmin2_R92P01_wia.target.yaml +22 -0
- data/spec/lib/ehbrs/vg/wii/wit/parsers/dump_spec_files/pikmin2_pal_iso.source.witdump +28 -0
- data/spec/lib/ehbrs/vg/wii/wit/parsers/dump_spec_files/pikmin2_pal_iso.target.yaml +21 -0
- data/spec/lib/ehbrs/vg/wii/wit/parsers/dump_spec_files/resident_evil_code_veronica_disc2_iso.source.witdump +16 -0
- data/spec/lib/ehbrs/vg/wii/wit/parsers/dump_spec_files/resident_evil_code_veronica_disc2_iso.target.yaml +19 -0
- data/spec/lib/ehbrs/vg/wii/wit/parsers/dump_spec_files/super_mario_galaxy_wbfs.source.witdump +28 -0
- data/spec/lib/ehbrs/vg/wii/wit/parsers/dump_spec_files/super_mario_galaxy_wbfs.target.yaml +23 -0
- data/spec/lib/ehbrs/vg/wii/wit/path_spec.rb +33 -0
- data/spec/spec_helper/videos.rb +30 -0
- data/spec/spec_helper/videos_files/stub_source.mp4 +0 -0
- data/spec/spec_helper.rb +7 -0
- data/vendor/aranha-parsers/aranha-parsers.gemspec +3 -2
- data/vendor/aranha-parsers/lib/aranha/parsers/rspec/setup.rb +15 -0
- data/vendor/aranha-parsers/lib/aranha/parsers/rspec/{source_target_fixtures_example.rb → shared_examples/source_target_fixtures.rb} +0 -0
- data/vendor/aranha-parsers/lib/aranha/parsers/source_address/fetch_content_error.rb +10 -0
- data/vendor/aranha-parsers/lib/aranha/parsers/source_address/http_get.rb +15 -2
- data/vendor/aranha-parsers/lib/aranha/parsers/version.rb +1 -1
- data/vendor/eac_cli/lib/eac_cli/definition/argument_option.rb +1 -1
- data/vendor/eac_cli/lib/eac_cli/definition/base_option.rb +9 -1
- data/vendor/eac_cli/lib/eac_cli/definition/boolean_option.rb +6 -0
- data/vendor/eac_cli/lib/eac_cli/runner_with/help/builder.rb +3 -3
- data/vendor/eac_cli/lib/eac_cli/version.rb +1 -1
- data/vendor/eac_cli/spec/lib/eac_cli/runner_spec.rb +6 -5
- data/vendor/eac_docker/eac_docker.gemspec +2 -2
- data/vendor/eac_docker/lib/eac_docker/rspec/setup.rb +17 -0
- data/vendor/eac_docker/lib/eac_docker/version.rb +1 -1
- data/vendor/eac_ruby_utils/eac_ruby_utils.gemspec +1 -1
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/compact.rb +22 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/fs_cache.rb +1 -1
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/gems_registry/gem.rb +36 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/gems_registry.rb +2 -3
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/object/compact.rb +20 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/string/delimited.rb +16 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/recursive_builder.rb +51 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/rspec/default_setup.rb +4 -2
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/rspec/setup/conditionals.rb +17 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/rspec/setup.rb +4 -37
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/rspec/setup_manager.rb +49 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/string_delimited.rb +70 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/version.rb +1 -1
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/compact_spec.rb +20 -0
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/object/compact_spec.rb +20 -0
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/string/delimited_spec.rb +34 -0
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/recursive_builder_spec.rb +65 -0
- data/vendor/ehbrs_ruby_utils/ehbrs_ruby_utils.gemspec +6 -1
- data/{lib/ehbrs → vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils}/fs/compressed_package.rb +1 -1
- data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/fs/selected/build.rb +41 -0
- data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/fs/selected/build_file.rb +27 -0
- data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/fs/selected.rb +35 -0
- data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/fs.rb +10 -0
- data/{lib/ehbrs/fs.rb → vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/music.rb} +2 -2
- data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/version.rb +1 -1
- data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/videos/container.rb +31 -0
- data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/videos/stream.rb +1 -1
- data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/web_utils/videos/file/rename.rb +28 -0
- data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/web_utils/videos/file.rb +11 -8
- data/vendor/ultimate_lyrics/Gemfile +5 -0
- data/vendor/ultimate_lyrics/bin/download_parser_spec_files.rb +94 -0
- data/vendor/ultimate_lyrics/lib/ultimate_lyrics/field.rb +83 -0
- data/vendor/ultimate_lyrics/lib/ultimate_lyrics/lyrics.rb +13 -0
- data/vendor/ultimate_lyrics/lib/ultimate_lyrics/parser.rb +28 -0
- data/vendor/ultimate_lyrics/lib/ultimate_lyrics/provider/exclude_item.rb +17 -0
- data/vendor/ultimate_lyrics/lib/ultimate_lyrics/provider/extract_item.rb +21 -0
- data/vendor/ultimate_lyrics/lib/ultimate_lyrics/provider/item.rb +48 -0
- data/vendor/ultimate_lyrics/lib/ultimate_lyrics/provider/replace_fields.rb +13 -0
- data/vendor/ultimate_lyrics/lib/ultimate_lyrics/provider/rule.rb +52 -0
- data/vendor/ultimate_lyrics/lib/ultimate_lyrics/provider/url_format.rb +21 -0
- data/vendor/ultimate_lyrics/lib/ultimate_lyrics/provider.rb +92 -0
- data/vendor/ultimate_lyrics/lib/ultimate_lyrics/provider_search.rb +43 -0
- data/vendor/ultimate_lyrics/lib/ultimate_lyrics/providers_data.xml +355 -0
- data/vendor/ultimate_lyrics/lib/ultimate_lyrics/song_metadata/field.rb +24 -0
- data/vendor/ultimate_lyrics/lib/ultimate_lyrics/song_metadata.rb +28 -0
- data/vendor/ultimate_lyrics/lib/ultimate_lyrics/version.rb +5 -0
- data/vendor/ultimate_lyrics/lib/ultimate_lyrics.rb +7 -0
- data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec.rb +20 -0
- data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/encyclopaedia_metallum__michael_jackson_thriller.source.html +8 -0
- data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/encyclopaedia_metallum__michael_jackson_thriller.target.yaml +3 -0
- data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/encyclopaedia_metallum__michael_jackson_thriller.url +1 -0
- data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/encyclopaedia_metallum__milton_nascimento_rouxinol.source.html +8 -0
- data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/encyclopaedia_metallum__milton_nascimento_rouxinol.target.yaml +3 -0
- data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/encyclopaedia_metallum__milton_nascimento_rouxinol.url +1 -0
- data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/hindilyrics_net_bollywood_songs__michael_jackson_thriller.source.html +193 -0
- data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/hindilyrics_net_bollywood_songs__michael_jackson_thriller.target.yaml +3 -0
- data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/hindilyrics_net_bollywood_songs__michael_jackson_thriller.url +1 -0
- data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/hindilyrics_net_bollywood_songs__milton_nascimento_rouxinol.source.html +193 -0
- data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/hindilyrics_net_bollywood_songs__milton_nascimento_rouxinol.target.yaml +3 -0
- data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/hindilyrics_net_bollywood_songs__milton_nascimento_rouxinol.url +1 -0
- data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/lyrics_com__michael_jackson_thriller.source.html +87 -0
- data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/lyrics_com__michael_jackson_thriller.target.yaml +36 -0
- data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/lyrics_com__michael_jackson_thriller.url +1 -0
- data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/lyrics_com__milton_nascimento_rouxinol.source.html +4 -0
- data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/lyrics_com__milton_nascimento_rouxinol.target.yaml +5 -0
- data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/lyrics_com__milton_nascimento_rouxinol.url +1 -0
- data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/lyricsplugin_com__michael_jackson_thriller.source.html +2 -0
- data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/lyricsplugin_com__michael_jackson_thriller.target.yaml +3 -0
- data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/lyricsplugin_com__michael_jackson_thriller.url +1 -0
- data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/lyricsplugin_com__milton_nascimento_rouxinol.source.html +2 -0
- data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/lyricsplugin_com__milton_nascimento_rouxinol.target.yaml +3 -0
- data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/lyricsplugin_com__milton_nascimento_rouxinol.url +1 -0
- data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/lyricsreg_com__milton_nascimento_rouxinol.source.html +101 -0
- data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/lyricsreg_com__milton_nascimento_rouxinol.target.yaml +3 -0
- data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/lyricsreg_com__milton_nascimento_rouxinol.url +1 -0
- data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/mp3lyrics_org__michael_jackson_thriller.source.html +29 -0
- data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/mp3lyrics_org__michael_jackson_thriller.target.yaml +3 -0
- data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/mp3lyrics_org__michael_jackson_thriller.url +1 -0
- data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/mp3lyrics_org__milton_nascimento_rouxinol.source.html +29 -0
- data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/mp3lyrics_org__milton_nascimento_rouxinol.target.yaml +3 -0
- data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/mp3lyrics_org__milton_nascimento_rouxinol.url +1 -0
- data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/songlyrics_com__michael_jackson_thriller.source.html +1298 -0
- data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/songlyrics_com__michael_jackson_thriller.target.yaml +3 -0
- data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/songlyrics_com__michael_jackson_thriller.url +1 -0
- data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/provider_search_spec.rb +72 -0
- data/vendor/ultimate_lyrics/spec/rubocop_spec.rb +3 -0
- data/vendor/ultimate_lyrics/spec/spec_helper.rb +4 -0
- data/vendor/ultimate_lyrics/ultimate_lyrics.gemspec +21 -0
- metadata +168 -11
- data/vendor/aranha-parsers/lib/aranha/parsers/rspec/setup_include.rb +0 -17
- data/vendor/eac_docker/lib/eac_docker/rspec/setup_include.rb +0 -23
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/rspec/conditional.rb +0 -35
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/rspec/stubbed_ssh.rb +0 -44
@@ -1,45 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'eac_ruby_utils/
|
4
|
-
require 'eac_ruby_utils/patches/object/if_respond'
|
5
|
-
require 'eac_ruby_utils/patches/object/to_pathname'
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
6
4
|
|
7
5
|
module EacRubyUtils
|
8
6
|
module Rspec
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
class << self
|
13
|
-
def create(app_root_path, rspec_config = nil)
|
14
|
-
if rspec_config
|
15
|
-
new(app_root_path, rspec_config)
|
16
|
-
else
|
17
|
-
::RSpec.configure { |new_rspec_config| new(app_root_path, new_rspec_config) }
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
attr_reader :app_root_path, :rspec_config
|
23
|
-
|
24
|
-
def initialize(app_root_path, rspec_config)
|
25
|
-
@app_root_path = app_root_path.to_pathname
|
26
|
-
@rspec_config = rspec_config
|
27
|
-
include_registry
|
28
|
-
end
|
29
|
-
|
30
|
-
# @return [EacRubyUtils::GemsRegistry]
|
31
|
-
def gems_registry
|
32
|
-
@gems_registry ||= ::EacRubyUtils::GemsRegistry.new(GEMS_REGISTRY_SUFFIX)
|
33
|
-
end
|
34
|
-
|
35
|
-
protected
|
36
|
-
|
37
|
-
def include_registry
|
38
|
-
gems_registry.registered.each do |gem|
|
39
|
-
singleton_class.include(gem.registered_module)
|
40
|
-
gem.registered_module.setup(self) if gem.registered_module.respond_to?(:setup)
|
41
|
-
end
|
42
|
-
end
|
7
|
+
module Setup
|
8
|
+
extend ::ActiveSupport::Concern
|
9
|
+
require_sub __FILE__, include_modules: true
|
43
10
|
end
|
44
11
|
end
|
45
12
|
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/gems_registry'
|
4
|
+
require 'eac_ruby_utils/patches/object/if_respond'
|
5
|
+
require 'eac_ruby_utils/patches/object/to_pathname'
|
6
|
+
|
7
|
+
module EacRubyUtils
|
8
|
+
module Rspec
|
9
|
+
class SetupManager
|
10
|
+
GEMS_REGISTRY_SUFFIX = 'Rspec::Setup'
|
11
|
+
|
12
|
+
class << self
|
13
|
+
def create(app_root_path, rspec_config = nil)
|
14
|
+
if rspec_config
|
15
|
+
new(app_root_path, rspec_config)
|
16
|
+
else
|
17
|
+
::RSpec.configure { |new_rspec_config| new(app_root_path, new_rspec_config) }
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
attr_reader :app_root_path, :rspec_config
|
23
|
+
|
24
|
+
def initialize(app_root_path, rspec_config)
|
25
|
+
@app_root_path = app_root_path.to_pathname
|
26
|
+
@rspec_config = rspec_config
|
27
|
+
include_registry
|
28
|
+
end
|
29
|
+
|
30
|
+
# @return [EacRubyUtils::GemsRegistry]
|
31
|
+
def gems_registry
|
32
|
+
@gems_registry ||= ::EacRubyUtils::GemsRegistry.new(GEMS_REGISTRY_SUFFIX)
|
33
|
+
end
|
34
|
+
|
35
|
+
protected
|
36
|
+
|
37
|
+
def include_registry
|
38
|
+
gems_registry.registered.each do |gem|
|
39
|
+
include_gem_registered(gem.registered_module)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
# @param gem [EacRubyUtils::GemsRegistry::Gem]
|
44
|
+
def include_gem_registered(registered_module)
|
45
|
+
extend(registered_module)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module EacRubyUtils
|
4
|
+
class StringDelimited
|
5
|
+
attr_reader :string, :begin_delimiter, :end_delimiter
|
6
|
+
|
7
|
+
def initialize(string, begin_delimiter, end_delimiter)
|
8
|
+
@string = string
|
9
|
+
@begin_delimiter = begin_delimiter
|
10
|
+
@end_delimiter = end_delimiter
|
11
|
+
end
|
12
|
+
|
13
|
+
def inner
|
14
|
+
between_indexes(content_index, end_index).to_s
|
15
|
+
end
|
16
|
+
|
17
|
+
def outer
|
18
|
+
between_indexes(begin_index, after_end_index).to_s
|
19
|
+
end
|
20
|
+
|
21
|
+
def without_inner
|
22
|
+
without_join(
|
23
|
+
between_indexes(sos_index, content_index), between_indexes(end_index, eos_index)
|
24
|
+
)
|
25
|
+
end
|
26
|
+
|
27
|
+
def without_outer
|
28
|
+
without_join(
|
29
|
+
between_indexes(sos_index, begin_index),
|
30
|
+
between_indexes(after_end_index, eos_index)
|
31
|
+
)
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
def after_end_index
|
37
|
+
end_index.if_present { |v| v + end_delimiter.length }
|
38
|
+
end
|
39
|
+
|
40
|
+
def begin_index
|
41
|
+
string.index(begin_delimiter)
|
42
|
+
end
|
43
|
+
|
44
|
+
def between_indexes(a_begin_index, a_end_index)
|
45
|
+
a_begin_index && a_end_index ? string[a_begin_index, a_end_index - a_begin_index] : nil
|
46
|
+
end
|
47
|
+
|
48
|
+
def content_index
|
49
|
+
begin_index.if_present { |v| v + begin_delimiter.length }
|
50
|
+
end
|
51
|
+
|
52
|
+
def without_join(*strings)
|
53
|
+
return string if strings.any?(&:nil?)
|
54
|
+
|
55
|
+
strings.join('')
|
56
|
+
end
|
57
|
+
|
58
|
+
def end_index
|
59
|
+
content_index.if_present { |_v| string.index(end_delimiter, content_index) }
|
60
|
+
end
|
61
|
+
|
62
|
+
def sos_index
|
63
|
+
0
|
64
|
+
end
|
65
|
+
|
66
|
+
def eos_index
|
67
|
+
string.length
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/compact'
|
4
|
+
|
5
|
+
::RSpec.describe ::EacRubyUtils::Compact do
|
6
|
+
let(:object) { ::OpenStruct.new(a_attr: 'a_value', b_attr: 'b_value') }
|
7
|
+
let(:instance) { described_class.new(object, %w[a_attr b_attr]) }
|
8
|
+
|
9
|
+
describe '#to_a' do
|
10
|
+
it do
|
11
|
+
expect(instance.to_a).to eq(%w[a_value b_value])
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe '#to_h' do
|
16
|
+
it do
|
17
|
+
expect(instance.to_h).to eq(a_attr: 'a_value', b_attr: 'b_value')
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/patches/object/compact'
|
4
|
+
|
5
|
+
::RSpec.describe ::Object do
|
6
|
+
let(:instance) { ::OpenStruct.new(a_attr: 'a_value', b_attr: 'b_value') }
|
7
|
+
let(:attributes) { %w[a_attr b_attr] }
|
8
|
+
|
9
|
+
describe '#compact' do
|
10
|
+
it do
|
11
|
+
expect(instance.compact_to_a(*attributes)).to eq(%w[a_value b_value])
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe '#to_h' do
|
16
|
+
it do
|
17
|
+
expect(instance.compact_to_h(*attributes)).to eq(a_attr: 'a_value', b_attr: 'b_value')
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/patches/string/delimited'
|
4
|
+
|
5
|
+
::RSpec.describe ::String do
|
6
|
+
let(:instance) { 'A text with <b>content between</b> tags.' }
|
7
|
+
|
8
|
+
{
|
9
|
+
['<b>', '</b>'] => {
|
10
|
+
'inner' => 'content between',
|
11
|
+
'without_inner' => 'A text with <b></b> tags.',
|
12
|
+
'outer' => '<b>content between</b>',
|
13
|
+
'without_outer' => 'A text with tags.'
|
14
|
+
},
|
15
|
+
['<b>', '</br>'] => {
|
16
|
+
'inner' => '',
|
17
|
+
'without_inner' => 'A text with <b>content between</b> tags.',
|
18
|
+
'outer' => '',
|
19
|
+
'without_outer' => 'A text with <b>content between</b> tags.'
|
20
|
+
}
|
21
|
+
}.each do |delimiters, expected_values|
|
22
|
+
context "when delimiters are #{delimiters}" do
|
23
|
+
let(:bdel) { delimiters[0] }
|
24
|
+
let(:edel) { delimiters[1] }
|
25
|
+
|
26
|
+
expected_values.each do |method_suffix, expected_value|
|
27
|
+
method_name = "delimited_#{method_suffix}"
|
28
|
+
it "#{method_name} should return \"#{expected_value}\"" do
|
29
|
+
expect(instance.send(method_name, bdel, edel)).to eq(expected_value)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/recursive_builder'
|
4
|
+
|
5
|
+
RSpec.describe ::EacRubyUtils::RecursiveBuilder do
|
6
|
+
let(:item_class) do
|
7
|
+
::Class.new do
|
8
|
+
class << self
|
9
|
+
def create(label, dependencies_keys)
|
10
|
+
item = new(label, dependencies_keys)
|
11
|
+
registry[item.label] = item
|
12
|
+
item
|
13
|
+
end
|
14
|
+
|
15
|
+
def registry
|
16
|
+
@registry ||= {}
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
attr_reader :label, :dependencies_keys
|
21
|
+
|
22
|
+
def initialize(label, dependencies_keys)
|
23
|
+
@label = label
|
24
|
+
@dependencies_keys = dependencies_keys.freeze
|
25
|
+
end
|
26
|
+
|
27
|
+
def dependencies
|
28
|
+
dependencies_keys.map { |key| self.class.registry.fetch(key) }
|
29
|
+
end
|
30
|
+
|
31
|
+
def to_s
|
32
|
+
label
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
items = [
|
38
|
+
[:a, %w[c], %w[a c]],
|
39
|
+
[:b, %w[a], %w[b a c]],
|
40
|
+
[:c, [], %w[c]],
|
41
|
+
[:d, %w[a b c e], %w[d a b c e]],
|
42
|
+
[:e, %w[c b], %w[e c b a]]
|
43
|
+
]
|
44
|
+
|
45
|
+
items.each do |item|
|
46
|
+
let(item[0]) { item_class.create(item[0].to_s, item[1]) }
|
47
|
+
before { send(item[0]) }
|
48
|
+
end
|
49
|
+
|
50
|
+
describe '#result' do
|
51
|
+
items.each do |item|
|
52
|
+
context "when root is \"#{item[0]}\"" do
|
53
|
+
let(:root) { send(item[0]) }
|
54
|
+
let(:dependencies) { item[2].map { |d| send(d) } }
|
55
|
+
let(:builder) do
|
56
|
+
described_class.new(root, &:dependencies)
|
57
|
+
end
|
58
|
+
|
59
|
+
it "is #{item[2]}" do
|
60
|
+
expect(builder.result).to eq(dependencies)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -12,10 +12,15 @@ Gem::Specification.new do |s|
|
|
12
12
|
s.authors = ['Eduardo H. Bogoni']
|
13
13
|
s.summary = 'Utilities for EHB/RS\'s Ruby projects.'
|
14
14
|
|
15
|
-
s.files = Dir['{lib}/**/*']
|
15
|
+
s.files = Dir['{lib,template}/**/*']
|
16
|
+
s.test_files = Dir['{spec}/**/*', '.rubocop.yml', '.rspec']
|
16
17
|
|
18
|
+
s.add_dependency 'aranha-parsers', '~> 0.8', '>= 0.8.5'
|
19
|
+
s.add_dependency 'avm', '~> 0.3', '>= 0.3.2'
|
17
20
|
s.add_dependency 'eac_ruby_utils', '~> 0.70'
|
18
21
|
s.add_dependency 'eac_templates', '~> 0.1', '>= 0.1.1'
|
22
|
+
s.add_dependency 'taglib-ruby', '~> 1.1'
|
23
|
+
s.add_dependency 'ultimate_lyrics', '~> 0.1'
|
19
24
|
|
20
25
|
s.add_development_dependency 'aranha-parsers', '~> 0.8'
|
21
26
|
s.add_development_dependency 'eac_ruby_gem_support', '~> 0.3'
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
require 'ehbrs_ruby_utils/fs/selected/build_file'
|
5
|
+
|
6
|
+
module EhbrsRubyUtils
|
7
|
+
module Fs
|
8
|
+
class Selected
|
9
|
+
class Build
|
10
|
+
DEFAULT_TARGET_BASENAME_PROC = ::Proc.new { |basename| basename }
|
11
|
+
|
12
|
+
attr_reader :selected, :target_dir, :target_basename_proc
|
13
|
+
|
14
|
+
def initialize(selected, target_dir, &target_basename_proc)
|
15
|
+
@selected = selected
|
16
|
+
@target_dir = target_dir.to_pathname
|
17
|
+
@target_basename_proc = target_basename_proc.presence || DEFAULT_TARGET_BASENAME_PROC
|
18
|
+
end
|
19
|
+
|
20
|
+
def perform
|
21
|
+
clear_target_dir
|
22
|
+
link_selected_found
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def clear_target_dir
|
28
|
+
target_dir.children.each do |c|
|
29
|
+
c.unlink if c.symlink? && c.directory?
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def link_selected_found
|
34
|
+
selected.found.each do |found|
|
35
|
+
::EhbrsRubyUtils::Fs::Selected::BuildFile.new(self, found).perform
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
|
5
|
+
module EhbrsRubyUtils
|
6
|
+
module Fs
|
7
|
+
class Selected
|
8
|
+
class BuildFile
|
9
|
+
common_constructor :build, :path do
|
10
|
+
self.path = path.to_pathname
|
11
|
+
end
|
12
|
+
|
13
|
+
def perform
|
14
|
+
target_path.make_symlink(path)
|
15
|
+
end
|
16
|
+
|
17
|
+
def target_path
|
18
|
+
build.target_dir.join(target_basename)
|
19
|
+
end
|
20
|
+
|
21
|
+
def target_basename
|
22
|
+
build.target_basename_proc.call(path.basename.to_path)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
|
5
|
+
module EhbrsRubyUtils
|
6
|
+
module Fs
|
7
|
+
class Selected
|
8
|
+
require_sub __FILE__
|
9
|
+
DEFAULT_FILENAME = '.selected'
|
10
|
+
|
11
|
+
enable_listable
|
12
|
+
enable_simple_cache
|
13
|
+
lists.add_symbol :option, :filename, :target_name_builder
|
14
|
+
common_constructor :root_path, :options, default: [{}] do
|
15
|
+
self.root_path = root_path.to_pathname
|
16
|
+
self.options = self.class.lists.option.hash_keys_validate!(options)
|
17
|
+
end
|
18
|
+
|
19
|
+
def build(target_dir)
|
20
|
+
::EhbrsRubyUtils::Fs::Selected::Build.new(self, target_dir)
|
21
|
+
end
|
22
|
+
|
23
|
+
def filename
|
24
|
+
options[OPTION_FILENAME].if_present(DEFAULT_FILENAME)
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
# @return [Pathname]
|
30
|
+
def found_uncached
|
31
|
+
root_path.glob("**/#{filename}").map(&:parent).sort
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -4,23 +4,49 @@ require 'eac_ruby_utils/core_ext'
|
|
4
4
|
require 'ehbrs_ruby_utils/executables'
|
5
5
|
require 'ehbrs_ruby_utils/videos/stream'
|
6
6
|
require 'json'
|
7
|
+
require 'taglib'
|
8
|
+
require 'ultimate_lyrics/provider_search'
|
9
|
+
require 'ultimate_lyrics/song_metadata'
|
7
10
|
|
8
11
|
module EhbrsRubyUtils
|
9
12
|
module Videos
|
10
13
|
class Container
|
14
|
+
class << self
|
15
|
+
def from_file(path)
|
16
|
+
new(path)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
11
20
|
enable_simple_cache
|
12
21
|
common_constructor :path do
|
13
22
|
self.path = path.to_pathname
|
14
23
|
end
|
15
24
|
|
25
|
+
delegate :tag, to: :tag_file
|
26
|
+
delegate :to_s, to: :path
|
27
|
+
|
16
28
|
::EhbrsRubyUtils::Videos::Stream.lists.codec_type.each_value do |stream_type|
|
17
29
|
define_method stream_type.to_s.pluralize do
|
18
30
|
streams.select { |stream| stream.codec_type == stream_type }
|
19
31
|
end
|
20
32
|
end
|
21
33
|
|
34
|
+
# @param provider [UltimateLyrics::Provider]
|
35
|
+
# @return [UltimateLyrics::Lyrics]
|
36
|
+
def lyrics_by_provider(provider)
|
37
|
+
::UltimateLyrics::ProviderSearch.new(provider, song_metadata).lyrics
|
38
|
+
end
|
39
|
+
|
22
40
|
private
|
23
41
|
|
42
|
+
# @return [UltimateLyrics::SongMetadata]
|
43
|
+
def song_metadata_uncached
|
44
|
+
::UltimateLyrics::SongMetadata.new(
|
45
|
+
::UltimateLyrics::SongMetadata::Field.lists.sources.values
|
46
|
+
.map { |source| [source, tag.send(source)] }.to_h
|
47
|
+
)
|
48
|
+
end
|
49
|
+
|
24
50
|
def probe_data_uncached
|
25
51
|
::JSON.parse(
|
26
52
|
::EhbrsRubyUtils::Executables.ffprobe.command(
|
@@ -34,6 +60,11 @@ module EhbrsRubyUtils
|
|
34
60
|
::EhbrsRubyUtils::Videos::Stream.new(stream_ffprobe_data)
|
35
61
|
end
|
36
62
|
end
|
63
|
+
|
64
|
+
# @return [TagLib::FileRef]
|
65
|
+
def tag_file_uncached
|
66
|
+
::TagLib::FileRef.new(path.to_path)
|
67
|
+
end
|
37
68
|
end
|
38
69
|
end
|
39
70
|
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
|
5
|
+
module EhbrsRubyUtils
|
6
|
+
module WebUtils
|
7
|
+
module Videos
|
8
|
+
class File < ::SimpleDelegator
|
9
|
+
class Rename
|
10
|
+
common_constructor :file, :target_path
|
11
|
+
|
12
|
+
delegate :original_path, to: :file
|
13
|
+
|
14
|
+
def can_rename?
|
15
|
+
::File.exist?(original_path) && !::File.exist?(target_path)
|
16
|
+
end
|
17
|
+
|
18
|
+
def perform
|
19
|
+
return unless can_rename?
|
20
|
+
|
21
|
+
::FileUtils.mkdir_p(::File.dirname(target_path))
|
22
|
+
::FileUtils.mv(original_path, target_path)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -1,11 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'ostruct'
|
4
|
+
require 'eac_ruby_utils/core_ext'
|
4
5
|
|
5
6
|
module EhbrsRubyUtils
|
6
7
|
module WebUtils
|
7
8
|
module Videos
|
8
9
|
class File < ::SimpleDelegator
|
10
|
+
require_sub __FILE__
|
11
|
+
|
9
12
|
def initialize(data)
|
10
13
|
super(::OpenStruct.new(data))
|
11
14
|
end
|
@@ -14,12 +17,15 @@ module EhbrsRubyUtils
|
|
14
17
|
::File.exist?(original_path)
|
15
18
|
end
|
16
19
|
|
17
|
-
def
|
18
|
-
|
20
|
+
def move(target_dir)
|
21
|
+
::EhbrsRubyUtils::WebUtils::Videos::File::Rename.new(
|
22
|
+
self,
|
23
|
+
target_dir.to_pathname.join(original_path.to_pathname.relative_path_from(root_path))
|
24
|
+
).perform
|
19
25
|
end
|
20
26
|
|
21
|
-
def
|
22
|
-
|
27
|
+
def path_changed?
|
28
|
+
original_path != new_path
|
23
29
|
end
|
24
30
|
|
25
31
|
def remove
|
@@ -29,10 +35,7 @@ module EhbrsRubyUtils
|
|
29
35
|
end
|
30
36
|
|
31
37
|
def rename
|
32
|
-
|
33
|
-
|
34
|
-
::FileUtils.mkdir_p(::File.dirname(new_path))
|
35
|
-
::FileUtils.mv(original_path, new_path)
|
38
|
+
::EhbrsRubyUtils::WebUtils::Videos::File::Rename.new(self, new_path).perform
|
36
39
|
end
|
37
40
|
end
|
38
41
|
end
|