ehbrs-tools 0.15.0 → 0.16.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- 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 +3 -5
- data/lib/ehbrs/runner/videos/extract.rb +10 -13
- data/lib/ehbrs/runner/videos/probe.rb +6 -9
- 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 +5 -7
- data/lib/ehbrs/runner/web_utils/videos.rb +4 -6
- data/lib/ehbrs/runner/web_utils/videos/download.rb +8 -11
- data/lib/ehbrs/runner/web_utils/videos/upload.rb +8 -11
- 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 +4 -8
- data/lib/ehbrs/videos/series/rename/file/options.rb +3 -13
- data/lib/ehbrs/videos/track.rb +20 -10
- data/lib/ehbrs/videos/unsupported/checks/codec_extra_unlisted.rb +2 -0
- data/lib/ehbrs/videos/unsupported/checks/codec_extra_unsupported.rb +2 -0
- data/lib/ehbrs/videos/unsupported/checks/codec_unlisted.rb +2 -0
- data/lib/ehbrs/videos/unsupported/checks/codec_unsupported.rb +2 -0
- data/lib/ehbrs/videos/unsupported/checks/invalid_extension.rb +2 -0
- data/lib/ehbrs/videos/unsupported/fixes/supported_codec.rb +1 -1
- data/lib/ehbrs/videos/unsupported/profiles/base.rb +17 -3
- data/lib/ehbrs/videos/unsupported/profiles/philco.rb +5 -4
- 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 +78 -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/definition.rb +49 -22
- data/vendor/eac_cli/lib/eac_cli/definition/alternative.rb +83 -0
- data/vendor/eac_cli/lib/eac_cli/definition/base_option.rb +17 -1
- data/vendor/eac_cli/lib/eac_cli/{parser/options_collection.rb → definition/help_formatter.rb} +20 -49
- data/vendor/eac_cli/lib/eac_cli/definition/positional_argument.rb +21 -4
- data/vendor/eac_cli/lib/eac_cli/docopt/doc_builder.rb +18 -40
- data/vendor/eac_cli/lib/eac_cli/docopt/doc_builder/alternative.rb +50 -0
- data/vendor/eac_cli/lib/eac_cli/docopt/runner_extension.rb +1 -0
- data/vendor/eac_cli/lib/eac_cli/parser.rb +23 -3
- data/vendor/eac_cli/lib/eac_cli/parser/alternative.rb +92 -0
- data/vendor/eac_cli/lib/eac_cli/parser/alternative/argv.rb +17 -0
- data/vendor/eac_cli/lib/eac_cli/parser/alternative/double_dash.rb +24 -0
- data/vendor/eac_cli/lib/eac_cli/parser/alternative/options.rb +58 -0
- data/vendor/eac_cli/lib/eac_cli/parser/alternative/positionals.rb +30 -0
- data/vendor/eac_cli/lib/eac_cli/parser/collector.rb +4 -0
- data/vendor/eac_cli/lib/eac_cli/patches/object/runner_with.rb +2 -1
- data/vendor/eac_cli/lib/eac_cli/runner.rb +17 -5
- data/vendor/eac_cli/lib/eac_cli/runner/context.rb +19 -2
- data/vendor/eac_cli/lib/eac_cli/runner/exit.rb +13 -0
- data/vendor/eac_cli/lib/eac_cli/runner_with/help.rb +18 -1
- data/vendor/eac_cli/lib/eac_cli/runner_with/output_file.rb +5 -1
- data/vendor/eac_cli/lib/eac_cli/runner_with/subcommands.rb +101 -0
- data/vendor/eac_cli/lib/eac_cli/version.rb +1 -1
- data/vendor/eac_cli/spec/lib/eac_cli/definition/alternative_spec.rb +14 -0
- data/vendor/eac_cli/spec/lib/eac_cli/docopt/runner_extension_spec.rb +35 -0
- data/vendor/eac_cli/spec/lib/eac_cli/parser/alternative_spec.rb +140 -0
- data/vendor/eac_cli/spec/lib/eac_cli/runner_spec.rb +59 -39
- data/vendor/eac_cli/spec/lib/eac_cli/runner_with/help_spec.rb +42 -0
- data/vendor/eac_cli/spec/lib/eac_cli/runner_with/output_file_spec.rb +53 -0
- data/vendor/eac_cli/spec/lib/eac_cli/runner_with/subcommands_spec.rb +85 -0
- data/vendor/eac_docker/lib/eac_docker/container.rb +24 -0
- data/vendor/eac_docker/lib/eac_docker/images/coded.rb +39 -0
- data/vendor/eac_docker/lib/eac_docker/images/templatized.rb +26 -0
- data/vendor/eac_docker/lib/eac_docker/registry.rb +17 -0
- data/vendor/eac_docker/lib/eac_docker/version.rb +1 -1
- data/vendor/eac_docker/spec/lib/eac_docker/images/coded_spec.rb +12 -0
- data/vendor/eac_docker/spec/lib/eac_docker/images/coded_spec_files/image1/Dockerfile +1 -0
- data/vendor/eac_docker/spec/lib/eac_docker/images/templatized_spec.rb +17 -0
- data/vendor/eac_docker/spec/lib/eac_docker/images/templatized_spec_files/stub_docker_image/Dockerfile +1 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/abstract_methods.rb +60 -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 +2 -50
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_concern/class_setup.rb +52 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_concern/module_setup.rb +31 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_constructor.rb +53 -0
- 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/envs/command.rb +4 -6
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/command/concat.rb +33 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/command/envvars.rb +24 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/command/extra_options.rb +0 -21
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/fs/clearable_directory.rb +57 -0
- 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/module/abstract_methods.rb +10 -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/struct.rb +11 -1
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/version.rb +1 -1
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/yaml.rb +3 -2
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/abstract_methods_spec.rb +28 -0
- 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/common_concern_spec.rb +30 -17
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/common_constructor_spec.rb +66 -8
- 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/eac_ruby_utils/spec/lib/eac_ruby_utils/struct_spec.rb +12 -1
- 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 +30 -2
- data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/videos/convert_job.rb +91 -0
- data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/videos/stream.rb +51 -0
- metadata +108 -13
- data/vendor/eac_cli/lib/eac_cli/parser/parse_result.rb +0 -21
- data/vendor/eac_cli/lib/eac_cli/parser/positional_collection.rb +0 -49
- data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/videos/container/file.rb +0 -31
- data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/videos/container/info.rb +0 -21
@@ -1,21 +1,25 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require '
|
4
|
-
require 'eac_ruby_utils/patches/object/asserts'
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
5
4
|
|
6
5
|
module EacRubyUtils
|
7
6
|
class PathsHash
|
7
|
+
require_sub __FILE__
|
8
|
+
|
8
9
|
class << self
|
9
10
|
def parse_entry_key(entry_key)
|
10
11
|
r = entry_key.to_s.strip
|
11
|
-
raise EntryKeyError, 'Entry key cannot start or end with dot' if
|
12
|
+
raise ::EacRubyUtils::PathsHash::EntryKeyError, 'Entry key cannot start or end with dot' if
|
12
13
|
r.start_with?('.') || r.end_with?('.')
|
13
14
|
|
14
15
|
r = r.split('.').map(&:strip)
|
15
|
-
|
16
|
+
if r.empty?
|
17
|
+
raise ::EacRubyUtils::PathsHash::EntryKeyError, "Entry key \"#{entry_key}\" is empty"
|
18
|
+
end
|
16
19
|
return r.map(&:to_sym) unless r.any?(&:blank?)
|
17
20
|
|
18
|
-
raise EntryKeyError,
|
21
|
+
raise ::EacRubyUtils::PathsHash::EntryKeyError,
|
22
|
+
"Entry key \"#{entry_key}\" has at least one blank part"
|
19
23
|
end
|
20
24
|
end
|
21
25
|
|
@@ -26,68 +30,27 @@ module EacRubyUtils
|
|
26
30
|
end
|
27
31
|
|
28
32
|
def [](entry_key)
|
29
|
-
root.read_entry(
|
33
|
+
root.read_entry(::EacRubyUtils::PathsHash::PathSearch.parse_entry_key(entry_key))
|
30
34
|
end
|
31
35
|
|
32
36
|
def []=(entry_key, entry_value)
|
33
|
-
root.write_entry(
|
37
|
+
root.write_entry(
|
38
|
+
::EacRubyUtils::PathsHash::PathSearch.parse_entry_key(entry_key), entry_value
|
39
|
+
)
|
34
40
|
end
|
35
41
|
|
36
|
-
|
37
|
-
|
38
|
-
private
|
39
|
-
|
40
|
-
attr_reader :data
|
41
|
-
|
42
|
-
class EntryKeyError < StandardError
|
42
|
+
def fetch(entry_key)
|
43
|
+
root.fetch(::EacRubyUtils::PathsHash::PathSearch.parse_entry_key(entry_key))
|
43
44
|
end
|
44
45
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
@data = source_hash.map { |k, v| [k.to_sym, v.is_a?(Hash) ? Node.new(v) : v] }.to_h
|
49
|
-
end
|
50
|
-
|
51
|
-
def to_h
|
52
|
-
data.map { |k, v| [k, v.is_a?(Node) ? v.to_h : v] }.to_h
|
53
|
-
end
|
54
|
-
|
55
|
-
def read_entry(path, current)
|
56
|
-
validate_path(path, current)
|
57
|
-
node_key = path.shift
|
58
|
-
node = data[node_key]
|
59
|
-
return (node.is_a?(Node) ? node.to_h : node) if path.empty?
|
60
|
-
return nil if node.blank?
|
61
|
-
return node.read_entry(path, current + [node_key]) if node.is_a?(Node)
|
62
|
-
|
63
|
-
raise(EntryKeyError,
|
64
|
-
"Path #{current.join(',')} is not a Node and path continues (#{current + path})")
|
65
|
-
end
|
66
|
-
|
67
|
-
def write_entry(path, value, current)
|
68
|
-
validate_path(path, current)
|
69
|
-
node_key = path.shift
|
70
|
-
write_entry_value(path, node_key, value, current)
|
71
|
-
end
|
72
|
-
|
73
|
-
private
|
46
|
+
def key?(entry_key)
|
47
|
+
root.entry?(::EacRubyUtils::PathsHash::PathSearch.parse_entry_key(entry_key))
|
48
|
+
end
|
74
49
|
|
75
|
-
|
76
|
-
if path.empty?
|
77
|
-
data[node_key] = value.is_a?(Hash) ? Node.new(value) : value
|
78
|
-
else
|
79
|
-
data[node_key] = Node.new({}) unless data[node_key].is_a?(Node)
|
80
|
-
data[node_key].write_entry(path, value, current + [node_key])
|
81
|
-
end
|
82
|
-
end
|
50
|
+
delegate :to_h, to: :root
|
83
51
|
|
84
|
-
|
85
|
-
path.assert_argument(Array, 'path')
|
86
|
-
current.assert_argument(Array, 'current')
|
87
|
-
raise EntryKeyError, 'Path is empty' if path.empty?
|
88
|
-
end
|
52
|
+
private
|
89
53
|
|
90
|
-
|
91
|
-
end
|
54
|
+
attr_reader :data
|
92
55
|
end
|
93
56
|
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
require 'eac_ruby_utils/paths_hash/entry_key_error'
|
5
|
+
|
6
|
+
module EacRubyUtils
|
7
|
+
class PathsHash
|
8
|
+
class Node
|
9
|
+
PATH_SEARCH_UNENDED_ERROR_MESSAGE = 'Path search is not a Node and is not ended'
|
10
|
+
|
11
|
+
def initialize(source_hash)
|
12
|
+
source_hash.assert_argument(Hash, 'source_hash')
|
13
|
+
@data = source_hash.map { |k, v| [k.to_sym, v.is_a?(Hash) ? Node.new(v) : v] }.to_h
|
14
|
+
end
|
15
|
+
|
16
|
+
def entry?(path_search)
|
17
|
+
return false unless data.key?(path_search.cursor)
|
18
|
+
return true if path_search.ended?
|
19
|
+
return data.fetch(path_search.cursor).entry?(path_search.succeeding) if
|
20
|
+
data.fetch(path_search.cursor).is_a?(Node)
|
21
|
+
|
22
|
+
false # Paths continue and there is not available nodes
|
23
|
+
end
|
24
|
+
|
25
|
+
def fetch(path_search)
|
26
|
+
if data.key?(path_search.cursor)
|
27
|
+
node = data.fetch(path_search.cursor)
|
28
|
+
return (node.is_a?(Node) ? node.to_h : node) if path_search.ended?
|
29
|
+
return nil if node.blank?
|
30
|
+
return node.fetch(path_search.succeeding) if node.is_a?(Node)
|
31
|
+
end
|
32
|
+
|
33
|
+
path_search.raise_error(PATH_SEARCH_UNENDED_ERROR_MESSAGE)
|
34
|
+
end
|
35
|
+
|
36
|
+
def to_h
|
37
|
+
data.map { |k, v| [k, v.is_a?(Node) ? v.to_h : v] }.to_h
|
38
|
+
end
|
39
|
+
|
40
|
+
def read_entry(path_search)
|
41
|
+
node = data[path_search.cursor]
|
42
|
+
return (node.is_a?(Node) ? node.to_h : node) if path_search.ended?
|
43
|
+
return nil if node.blank?
|
44
|
+
return node.read_entry(path_search.succeeding) if node.is_a?(Node)
|
45
|
+
|
46
|
+
path_search.raise_error(PATH_SEARCH_UNENDED_ERROR_MESSAGE)
|
47
|
+
end
|
48
|
+
|
49
|
+
def write_entry(path_search, value)
|
50
|
+
if path_search.ended?
|
51
|
+
data[path_search.cursor] = value.is_a?(Hash) ? self.class.new(value) : value
|
52
|
+
else
|
53
|
+
assert_data_node(path_search.cursor).write_entry(path_search.succeeding, value)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
private
|
58
|
+
|
59
|
+
attr_reader :data
|
60
|
+
|
61
|
+
def assert_data_node(key)
|
62
|
+
data[key] = self.class.new({}) unless data[key].is_a?(Node)
|
63
|
+
data[key]
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -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|
|
@@ -1,12 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'active_support/hash_with_indifferent_access'
|
4
|
+
require 'active_support/core_ext/module/delegation'
|
4
5
|
require 'active_support/core_ext/object/blank'
|
5
6
|
|
6
7
|
module EacRubyUtils
|
7
8
|
class Struct
|
8
9
|
def initialize(initial_data = {})
|
9
|
-
self.data =
|
10
|
+
self.data = initial_data.symbolize_keys
|
10
11
|
end
|
11
12
|
|
12
13
|
def [](key)
|
@@ -19,6 +20,11 @@ module EacRubyUtils
|
|
19
20
|
bool ? fetch(key).present? : data.fetch(key)
|
20
21
|
end
|
21
22
|
|
23
|
+
def merge(other)
|
24
|
+
other = self.class.new(other) unless other.is_a?(self.class)
|
25
|
+
self.class.new(to_h.merge(other.to_h))
|
26
|
+
end
|
27
|
+
|
22
28
|
def method_missing(method_name, *arguments, &block)
|
23
29
|
property_method?(method_name) ? fetch(method_name) : super
|
24
30
|
end
|
@@ -27,6 +33,10 @@ module EacRubyUtils
|
|
27
33
|
property_method?(method_name) || super
|
28
34
|
end
|
29
35
|
|
36
|
+
def slice_fetch(*keys)
|
37
|
+
self.class.new(keys.map { |key| [key, fetch(key)] }.to_h)
|
38
|
+
end
|
39
|
+
|
30
40
|
def to_h
|
31
41
|
data.dup
|
32
42
|
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,
|
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
|
@@ -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
|
@@ -9,34 +9,47 @@ RSpec.describe ::EacRubyUtils::CommonConcern do
|
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
12
|
+
let(:stub_module) do
|
13
|
+
::Module.new do
|
14
|
+
module ClassMethods # rubocop:disable RSpec/LeakyConstantDeclaration
|
15
|
+
def my_class_method
|
16
|
+
'class'
|
17
|
+
end
|
16
18
|
end
|
17
|
-
end
|
18
19
|
|
19
|
-
|
20
|
-
|
21
|
-
|
20
|
+
module InstanceMethods # rubocop:disable RSpec/LeakyConstantDeclaration
|
21
|
+
def my_instance_method
|
22
|
+
'instance'
|
23
|
+
end
|
22
24
|
end
|
23
25
|
end
|
24
26
|
end
|
25
27
|
|
26
|
-
|
27
|
-
|
28
|
-
|
28
|
+
let(:stub_class) do
|
29
|
+
::Class.new do
|
30
|
+
class << self
|
31
|
+
attr_accessor :valor
|
32
|
+
end
|
33
|
+
|
34
|
+
def method1
|
35
|
+
'from_stub_module'
|
36
|
+
end
|
29
37
|
end
|
30
38
|
end
|
31
39
|
|
32
|
-
let(:
|
40
|
+
let(:stub_class_instance) { stub_class.new }
|
33
41
|
|
34
42
|
before do
|
35
|
-
instance.setup(
|
36
|
-
MyClass.include MyModule
|
43
|
+
instance.setup(stub_module)
|
37
44
|
end
|
38
45
|
|
39
|
-
|
40
|
-
|
41
|
-
|
46
|
+
context 'when included' do
|
47
|
+
before do
|
48
|
+
stub_class.include stub_module
|
49
|
+
end
|
50
|
+
|
51
|
+
it { expect(stub_class_instance.my_instance_method).to eq('instance') }
|
52
|
+
it { expect(stub_class_instance.class.my_class_method).to eq('class') }
|
53
|
+
it { expect(stub_class_instance.class.valor).to eq('changed') }
|
54
|
+
end
|
42
55
|
end
|