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,31 +1,20 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'eac_ruby_utils/common_constructor'
|
4
3
|
require 'eac_ruby_utils/configs'
|
5
|
-
require 'eac_ruby_utils/
|
6
|
-
require 'eac_ruby_utils/options_consumer'
|
7
|
-
require 'eac_ruby_utils/patches/object/asserts'
|
8
|
-
require 'eac_ruby_utils/simple_cache'
|
4
|
+
require 'eac_ruby_utils/core_ext'
|
9
5
|
|
10
6
|
module EacRubyUtils
|
11
7
|
module Console
|
12
8
|
class Configs
|
13
|
-
|
9
|
+
require_sub __FILE__
|
10
|
+
enable_console_speaker
|
14
11
|
|
15
12
|
class << self
|
16
13
|
def entry_key_to_envvar_name(entry_key)
|
17
|
-
|
18
|
-
entry_key
|
19
|
-
else
|
20
|
-
::EacRubyUtils::PathsHash.parse_entry_key(entry_key)
|
21
|
-
end
|
22
|
-
path.join('_').gsub(/[^a-z0-9_]/i, '').gsub(/\A_+/, '').gsub(/_+\z/, '')
|
23
|
-
.gsub(/_{2,}/, '_').upcase
|
14
|
+
::EacRubyUtils::Console::Configs::EntryReader.entry_key_to_envvar_name(entry_key)
|
24
15
|
end
|
25
16
|
end
|
26
17
|
|
27
|
-
STORE_PASSWORDS_KEY = 'core.store_passwords'
|
28
|
-
|
29
18
|
attr_reader :configs
|
30
19
|
|
31
20
|
def initialize(configs_key, options = {})
|
@@ -34,101 +23,15 @@ module EacRubyUtils
|
|
34
23
|
end
|
35
24
|
|
36
25
|
def read_password(entry_key, options = {})
|
37
|
-
|
38
|
-
if store_passwords?
|
39
|
-
read_entry(entry_key, options)
|
40
|
-
else
|
41
|
-
looped_entry_value_from_input(entry_key, options)
|
42
|
-
end
|
26
|
+
::EacRubyUtils::Console::Configs::PasswordEntryReader.new(self, entry_key, options).read
|
43
27
|
end
|
44
28
|
|
45
29
|
def read_entry(entry_key, options = {})
|
46
|
-
|
47
|
-
unless options[:noenv]
|
48
|
-
envvar_value = envvar_read_entry(entry_key)
|
49
|
-
return envvar_value if envvar_value.present?
|
50
|
-
end
|
51
|
-
stored_value = configs.read_entry(entry_key)
|
52
|
-
return stored_value if stored_value
|
53
|
-
return read_entry_from_console(entry_key, options) unless options[:noinput]
|
54
|
-
|
55
|
-
raise "No value found for entry \"#{entry_key}\"" if options[:required]
|
30
|
+
::EacRubyUtils::Console::Configs::EntryReader.new(self, entry_key, options).read
|
56
31
|
end
|
57
32
|
|
58
33
|
def store_passwords?
|
59
|
-
|
60
|
-
STORE_PASSWORDS_KEY,
|
61
|
-
before_input: -> { store_password_banner },
|
62
|
-
validator: ->(entry_value) { %w[yes no].include?(entry_value) }
|
63
|
-
) == 'yes'
|
64
|
-
end
|
65
|
-
|
66
|
-
protected
|
67
|
-
|
68
|
-
def envvar_read_entry(entry_key)
|
69
|
-
ENV[self.class.entry_key_to_envvar_name(entry_key)]
|
70
|
-
end
|
71
|
-
|
72
|
-
def read_entry_from_console(entry_key, options)
|
73
|
-
options[:before_input].call if options[:before_input].present?
|
74
|
-
entry_value = looped_entry_value_from_input(entry_key, options)
|
75
|
-
configs.write_entry(entry_key, entry_value)
|
76
|
-
entry_value
|
77
|
-
end
|
78
|
-
|
79
|
-
def store_password_banner
|
80
|
-
infom 'Do you wanna to store passwords?'
|
81
|
-
infom "Warning: the passwords will be store in clear text in \"#{configs.storage_path}\""
|
82
|
-
infom 'Enter "yes" or "no"'
|
83
|
-
end
|
84
|
-
|
85
|
-
def looped_entry_value_from_input(entry_key, options)
|
86
|
-
loop do
|
87
|
-
entry_value = entry_value_from_input(entry_key, options)
|
88
|
-
next if entry_value.blank?
|
89
|
-
next if options[:validator] && !options[:validator].call(entry_value)
|
90
|
-
|
91
|
-
return entry_value
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
def entry_value_from_input(entry_key, options)
|
96
|
-
entry_value = request_input("Value for entry \"#{entry_key}\"",
|
97
|
-
options.request_input_options)
|
98
|
-
warn('Entered value is blank') if entry_value.blank?
|
99
|
-
entry_value
|
100
|
-
end
|
101
|
-
|
102
|
-
class ReadEntryOptions
|
103
|
-
include ::EacRubyUtils::SimpleCache
|
104
|
-
::EacRubyUtils::CommonConstructor.new(:options).setup_class(self)
|
105
|
-
|
106
|
-
DEFAULT_VALUES = {
|
107
|
-
before_input: nil, bool: false, list: false, noecho: false, noenv: false, noinput: false,
|
108
|
-
required: true, validator: nil
|
109
|
-
}.freeze
|
110
|
-
|
111
|
-
def [](key)
|
112
|
-
values.fetch(key.to_sym)
|
113
|
-
end
|
114
|
-
|
115
|
-
def request_input_options
|
116
|
-
values.slice(:bool, :list, :noecho)
|
117
|
-
end
|
118
|
-
|
119
|
-
private
|
120
|
-
|
121
|
-
def values_uncached
|
122
|
-
consumer = ::EacRubyUtils::OptionsConsumer.new(options)
|
123
|
-
r = {}
|
124
|
-
DEFAULT_VALUES.each do |key, default_value|
|
125
|
-
value = consumer.consume(key)
|
126
|
-
value = default_value if value.nil?
|
127
|
-
r[key] = value
|
128
|
-
end
|
129
|
-
consumer.validate
|
130
|
-
r
|
131
|
-
end
|
34
|
+
::EacRubyUtils::Console::Configs::StorePasswordsEntryReader.new(self) == 'yes'
|
132
35
|
end
|
133
36
|
end
|
134
37
|
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/console/configs/read_entry_options'
|
4
|
+
require 'eac_ruby_utils/core_ext'
|
5
|
+
|
6
|
+
module EacRubyUtils
|
7
|
+
module Console
|
8
|
+
class Configs
|
9
|
+
class EntryReader
|
10
|
+
enable_console_speaker
|
11
|
+
|
12
|
+
class << self
|
13
|
+
def entry_key_to_envvar_name(entry_key)
|
14
|
+
path = if entry_key.is_a?(::Array)
|
15
|
+
entry_key
|
16
|
+
else
|
17
|
+
::EacRubyUtils::PathsHash.parse_entry_key(entry_key)
|
18
|
+
end
|
19
|
+
path.join('_').gsub(/[^a-z0-9_]/i, '').gsub(/\A_+/, '').gsub(/_+\z/, '')
|
20
|
+
.gsub(/_{2,}/, '_').upcase
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
common_constructor :console_configs, :entry_key, :options do
|
25
|
+
self.options = ::EacRubyUtils::Console::Configs::ReadEntryOptions.new(options)
|
26
|
+
end
|
27
|
+
|
28
|
+
def read
|
29
|
+
%w[envvars storage console].each do |suffix|
|
30
|
+
value = send("read_from_#{suffix}")
|
31
|
+
return value if value.present?
|
32
|
+
end
|
33
|
+
return nil unless options[:required]
|
34
|
+
|
35
|
+
raise "No value found for entry \"#{entry_key}\""
|
36
|
+
end
|
37
|
+
|
38
|
+
def read_from_storage
|
39
|
+
console_configs.configs.read_entry(entry_key)
|
40
|
+
end
|
41
|
+
|
42
|
+
def read_from_envvars
|
43
|
+
return if options[:noenv]
|
44
|
+
|
45
|
+
env_entry_key = self.class.entry_key_to_envvar_name(entry_key)
|
46
|
+
return unless ENV.key?(env_entry_key)
|
47
|
+
|
48
|
+
ENV.fetch(env_entry_key).if_present(::EacRubyUtils::BlankNotBlank.instance)
|
49
|
+
end
|
50
|
+
|
51
|
+
def read_from_console
|
52
|
+
return if options[:noinput]
|
53
|
+
|
54
|
+
options[:before_input].if_present(&:call)
|
55
|
+
entry_value = looped_entry_value_from_input
|
56
|
+
console_configs.configs.write_entry(entry_key, entry_value) if options[:store]
|
57
|
+
entry_value
|
58
|
+
end
|
59
|
+
|
60
|
+
private
|
61
|
+
|
62
|
+
def looped_entry_value_from_input
|
63
|
+
loop do
|
64
|
+
entry_value = entry_value_from_input(entry_key, options)
|
65
|
+
next if entry_value.blank?
|
66
|
+
next if options[:validator] && !options[:validator].call(entry_value)
|
67
|
+
|
68
|
+
return entry_value
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def entry_value_from_input(entry_key, options)
|
73
|
+
entry_value = request_input("Value for entry \"#{entry_key}\"",
|
74
|
+
options.request_input_options)
|
75
|
+
warn('Entered value is blank') if entry_value.blank?
|
76
|
+
entry_value
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/console/configs/entry_reader'
|
4
|
+
|
5
|
+
module EacRubyUtils
|
6
|
+
module Console
|
7
|
+
class Configs
|
8
|
+
class PasswordEntryReader < ::EacRubyUtils::Console::Configs::EntryReader
|
9
|
+
ENTRY_KEY = 'core.store_passwords'
|
10
|
+
|
11
|
+
def initialize(console_configs, entry_key, options = {})
|
12
|
+
super(console_configs, entry_key, options.merge(noecho: true,
|
13
|
+
store: console_configs.store_passwords?))
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
|
5
|
+
module EacRubyUtils
|
6
|
+
module Console
|
7
|
+
class Configs
|
8
|
+
class ReadEntryOptions
|
9
|
+
enable_simple_cache
|
10
|
+
common_constructor :options do
|
11
|
+
self.options = options.to_h.symbolize_keys
|
12
|
+
.assert_valid_keys(DEFAULT_VALUES.keys).freeze
|
13
|
+
end
|
14
|
+
|
15
|
+
DEFAULT_VALUES = {
|
16
|
+
before_input: nil, bool: false, list: false, noecho: false, noenv: false, noinput: false,
|
17
|
+
required: true, store: true, validator: nil
|
18
|
+
}.freeze
|
19
|
+
|
20
|
+
delegate :to_h, to: :options
|
21
|
+
|
22
|
+
def [](key)
|
23
|
+
values.fetch(key.to_sym)
|
24
|
+
end
|
25
|
+
|
26
|
+
def request_input_options
|
27
|
+
values.slice(:bool, :list, :noecho)
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def values_uncached
|
33
|
+
consumer = options.to_options_consumer
|
34
|
+
r = {}
|
35
|
+
DEFAULT_VALUES.each do |key, default_value|
|
36
|
+
value = consumer.consume(key)
|
37
|
+
value = default_value if value.nil?
|
38
|
+
r[key] = value
|
39
|
+
end
|
40
|
+
consumer.validate
|
41
|
+
r
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/console/configs/entry_reader'
|
4
|
+
|
5
|
+
module EacRubyUtils
|
6
|
+
module Console
|
7
|
+
class Configs
|
8
|
+
class StorePasswordsEntryReader < ::EacRubyUtils::Console::Configs::EntryReader
|
9
|
+
ENTRY_KEY = 'core.store_passwords'
|
10
|
+
|
11
|
+
def initialize(console_configs)
|
12
|
+
super(console_configs, ENTRY_KEY,
|
13
|
+
before_input: -> { banner },
|
14
|
+
validator: ->(entry_value) { %w[yes no].include?(entry_value) }
|
15
|
+
)
|
16
|
+
end
|
17
|
+
|
18
|
+
def banner
|
19
|
+
infom 'Do you wanna to store passwords?'
|
20
|
+
infom 'Warning: the passwords will be store in clear text in ' \
|
21
|
+
"\"#{console_configs.configs.storage_path}\""
|
22
|
+
infom 'Enter "yes" or "no"'
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -1,8 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require '
|
4
|
-
require 'eac_ruby_utils/console/speaker'
|
5
|
-
require 'eac_ruby_utils/envs/command/extra_options'
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
6
4
|
require 'eac_ruby_utils/envs/process'
|
7
5
|
require 'eac_ruby_utils/envs/spawn'
|
8
6
|
require 'pp'
|
@@ -11,8 +9,8 @@ require 'shellwords'
|
|
11
9
|
module EacRubyUtils
|
12
10
|
module Envs
|
13
11
|
class Command
|
14
|
-
|
15
|
-
|
12
|
+
require_sub __FILE__, include_modules: true
|
13
|
+
enable_console_speaker
|
16
14
|
|
17
15
|
def initialize(env, command, extra_options = {})
|
18
16
|
@env = env
|
@@ -47,7 +45,7 @@ module EacRubyUtils
|
|
47
45
|
c = c.map { |x| escape(x) }.join(' ') if c.is_a?(Enumerable)
|
48
46
|
append_command_options(
|
49
47
|
@env.command_line(
|
50
|
-
append_chdir(
|
48
|
+
append_chdir(append_concat(append_envvars(c)))
|
51
49
|
),
|
52
50
|
options
|
53
51
|
)
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/struct'
|
4
|
+
|
5
|
+
module EacRubyUtils
|
6
|
+
module Envs
|
7
|
+
class Command
|
8
|
+
module Concat
|
9
|
+
def concat(operator, other_command)
|
10
|
+
duplicate_by_extra_options(concat: ::EacRubyUtils::Struct.new(
|
11
|
+
operator: operator, command: other_command
|
12
|
+
))
|
13
|
+
end
|
14
|
+
|
15
|
+
def or(other_command)
|
16
|
+
concat('||', other_command)
|
17
|
+
end
|
18
|
+
|
19
|
+
def pipe(other_command)
|
20
|
+
concat('|', other_command)
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def append_concat(command)
|
26
|
+
extra_options[:concat].if_present(command) do |v|
|
27
|
+
"#{command} #{v.operator} #{v.command.command}"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module EacRubyUtils
|
4
|
+
module Envs
|
5
|
+
class Command
|
6
|
+
module Envvars
|
7
|
+
def envvar(name, value)
|
8
|
+
duplicate_by_extra_options(envvars: envvars.merge(name => value))
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def append_envvars(command)
|
14
|
+
e = envvars.map { |k, v| "#{Shellwords.escape(k)}=#{Shellwords.escape(v)}" }.join(' ')
|
15
|
+
e.present? ? "#{e} #{command}" : command
|
16
|
+
end
|
17
|
+
|
18
|
+
def envvars
|
19
|
+
extra_options[:envvars] ||= {}.with_indifferent_access
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -12,39 +12,18 @@ module EacRubyUtils
|
|
12
12
|
duplicate_by_extra_options(chdir: dir)
|
13
13
|
end
|
14
14
|
|
15
|
-
def envvar(name, value)
|
16
|
-
duplicate_by_extra_options(envvars: envvars.merge(name => value))
|
17
|
-
end
|
18
|
-
|
19
15
|
def status_result(status_code, result)
|
20
16
|
duplicate_by_extra_options(status_results: status_results.merge(status_code => result))
|
21
17
|
end
|
22
18
|
|
23
|
-
def pipe(other_command)
|
24
|
-
duplicate_by_extra_options(pipe: other_command)
|
25
|
-
end
|
26
|
-
|
27
19
|
private
|
28
20
|
|
29
21
|
attr_reader :extra_options
|
30
22
|
|
31
|
-
def envvars
|
32
|
-
extra_options[:envvars] ||= {}.with_indifferent_access
|
33
|
-
end
|
34
|
-
|
35
23
|
def status_results
|
36
24
|
extra_options[:status_results] ||= {}.with_indifferent_access
|
37
25
|
end
|
38
26
|
|
39
|
-
def append_envvars(command)
|
40
|
-
e = envvars.map { |k, v| "#{Shellwords.escape(k)}=#{Shellwords.escape(v)}" }.join(' ')
|
41
|
-
e.present? ? "#{e} #{command}" : command
|
42
|
-
end
|
43
|
-
|
44
|
-
def append_pipe(command)
|
45
|
-
extra_options[:pipe].present? ? "#{command} | #{extra_options[:pipe].command}" : command
|
46
|
-
end
|
47
|
-
|
48
27
|
def append_chdir(command)
|
49
28
|
extra_options[:chdir].present? ? "(cd '#{extra_options[:chdir]}' ; #{command} )" : command
|
50
29
|
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'fileutils'
|
4
|
+
require 'pathname'
|
5
|
+
|
6
|
+
module EacRubyUtils
|
7
|
+
module Fs
|
8
|
+
class ClearableDirectory < ::Pathname
|
9
|
+
CLEARABLE_BASENAME = '.clearable_directory'
|
10
|
+
|
11
|
+
def clear
|
12
|
+
validate_clearable
|
13
|
+
directory? ? clear_directory : clear_no_directory
|
14
|
+
mkpath
|
15
|
+
::FileUtils.touch(clearable_note_file.to_path)
|
16
|
+
self
|
17
|
+
end
|
18
|
+
|
19
|
+
def clearable?
|
20
|
+
clearable_negate_message ? true : false
|
21
|
+
end
|
22
|
+
|
23
|
+
def clearable_negate_message
|
24
|
+
return if !exist? || empty?
|
25
|
+
return "Path \"#{self}\" exists, is not empty and is not a directory" unless directory?
|
26
|
+
return if clearable_note_file.exist?
|
27
|
+
|
28
|
+
"Directory \"#{self}\" is not empty and does not have a #{CLEARABLE_BASENAME} file"
|
29
|
+
end
|
30
|
+
|
31
|
+
def clearable_note_file
|
32
|
+
join(CLEARABLE_BASENAME)
|
33
|
+
end
|
34
|
+
|
35
|
+
def validate_clearable
|
36
|
+
message = clearable_negate_message
|
37
|
+
raise message if message
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
def clear_directory
|
43
|
+
children.each do |child|
|
44
|
+
if child.directory?
|
45
|
+
child.rmtree
|
46
|
+
elsif child.file?
|
47
|
+
child.unlink
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def clear_no_directory
|
53
|
+
::FileUtils.rm_rf(to_path)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|