ehbrs-tools 0.16.0 → 0.16.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (115) hide show
  1. checksums.yaml +4 -4
  2. data/lib/ehbrs/runner/videos/probe.rb +3 -3
  3. data/lib/ehbrs/tools/version.rb +1 -1
  4. data/lib/ehbrs/vg/wii/wit/parsers/dump.rb +10 -5
  5. data/lib/ehbrs/videos/file.rb +4 -8
  6. data/lib/ehbrs/videos/track.rb +5 -13
  7. data/lib/ehbrs/videos/unsupported/checks/codec_extra_unlisted.rb +3 -1
  8. data/lib/ehbrs/videos/unsupported/checks/codec_extra_unsupported.rb +3 -1
  9. data/lib/ehbrs/videos/unsupported/checks/codec_unlisted.rb +4 -2
  10. data/lib/ehbrs/videos/unsupported/checks/codec_unsupported.rb +3 -1
  11. data/lib/ehbrs/videos/unsupported/checks/invalid_extension.rb +2 -0
  12. data/lib/ehbrs/videos/unsupported/fix_profile.rb +0 -13
  13. data/lib/ehbrs/videos/unsupported/fixes/supported_codec.rb +10 -10
  14. data/lib/ehbrs/videos/unsupported/profiles/base.rb +17 -3
  15. data/lib/ehbrs/videos/unsupported/profiles/philco.rb +5 -4
  16. data/vendor/aranha-parsers/Gemfile +5 -0
  17. data/vendor/aranha-parsers/aranha-parsers.gemspec +23 -0
  18. data/vendor/aranha-parsers/lib/aranha/parsers.rb +9 -0
  19. data/vendor/aranha-parsers/lib/aranha/parsers/base.rb +79 -0
  20. data/vendor/aranha-parsers/lib/aranha/parsers/html.rb +11 -0
  21. data/vendor/aranha-parsers/lib/aranha/parsers/html/base.rb +47 -0
  22. data/vendor/aranha-parsers/lib/aranha/parsers/html/item.rb +24 -0
  23. data/vendor/aranha-parsers/lib/aranha/parsers/html/item_list.rb +29 -0
  24. data/vendor/aranha-parsers/lib/aranha/parsers/html/node.rb +13 -0
  25. data/vendor/aranha-parsers/lib/aranha/parsers/html/node/base.rb +36 -0
  26. data/vendor/aranha-parsers/lib/aranha/parsers/html/node/default.rb +126 -0
  27. data/vendor/aranha-parsers/lib/aranha/parsers/invalid_state_exception.rb +8 -0
  28. data/vendor/aranha-parsers/lib/aranha/parsers/patches.rb +11 -0
  29. data/vendor/aranha-parsers/lib/aranha/parsers/patches/ofx_parser.rb +38 -0
  30. data/vendor/aranha-parsers/lib/aranha/parsers/source_address.rb +55 -0
  31. data/vendor/aranha-parsers/lib/aranha/parsers/source_address/file.rb +31 -0
  32. data/vendor/aranha-parsers/lib/aranha/parsers/source_address/hash_http_get.rb +25 -0
  33. data/vendor/aranha-parsers/lib/aranha/parsers/source_address/hash_http_post.rb +45 -0
  34. data/vendor/aranha-parsers/lib/aranha/parsers/source_address/http_get.rb +49 -0
  35. data/vendor/aranha-parsers/lib/aranha/parsers/source_target_fixtures.rb +77 -0
  36. data/vendor/aranha-parsers/lib/aranha/parsers/spec/source_target_fixtures_example.rb +78 -0
  37. data/vendor/aranha-parsers/lib/aranha/parsers/version.rb +7 -0
  38. data/vendor/aranha-parsers/spec/lib/aranha/parsers/source_address/http_get_spec.rb +21 -0
  39. data/vendor/aranha-parsers/spec/lib/aranha/parsers/source_address_spec.rb +74 -0
  40. data/vendor/aranha-parsers/spec/lib/aranha/parsers/source_target_fixtures_spec.rb +27 -0
  41. data/vendor/aranha-parsers/spec/lib/aranha/parsers/source_target_fixtures_spec_files/stub1.source.txt +1 -0
  42. data/vendor/aranha-parsers/spec/lib/aranha/parsers/source_target_fixtures_spec_files/stub1.target.html +1 -0
  43. data/vendor/aranha-parsers/spec/lib/aranha/parsers/source_target_fixtures_spec_files/stub2.source.html +1 -0
  44. data/vendor/aranha-parsers/spec/lib/aranha/parsers/source_target_fixtures_spec_files/stub3.target.yaml +1 -0
  45. data/vendor/aranha-parsers/spec/lib/rubocop_check_spec.rb +7 -0
  46. data/vendor/aranha-parsers/spec/spec_helper.rb +8 -0
  47. data/vendor/eac_cli/eac_cli.gemspec +1 -1
  48. data/vendor/eac_cli/lib/eac_cli/definition.rb +36 -31
  49. data/vendor/eac_cli/lib/eac_cli/definition/alternative.rb +83 -0
  50. data/vendor/eac_cli/lib/eac_cli/definition/help_formatter.rb +76 -0
  51. data/vendor/eac_cli/lib/eac_cli/definition/positional_argument.rb +15 -2
  52. data/vendor/eac_cli/lib/eac_cli/docopt/doc_builder.rb +18 -40
  53. data/vendor/eac_cli/lib/eac_cli/docopt/doc_builder/alternative.rb +50 -0
  54. data/vendor/eac_cli/lib/eac_cli/parser.rb +23 -3
  55. data/vendor/eac_cli/lib/eac_cli/parser/alternative.rb +92 -0
  56. data/vendor/eac_cli/lib/eac_cli/parser/alternative/argv.rb +17 -0
  57. data/vendor/eac_cli/lib/eac_cli/parser/alternative/double_dash.rb +24 -0
  58. data/vendor/eac_cli/lib/eac_cli/parser/alternative/options.rb +58 -0
  59. data/vendor/eac_cli/lib/eac_cli/parser/alternative/positionals.rb +30 -0
  60. data/vendor/eac_cli/lib/eac_cli/runner.rb +12 -4
  61. data/vendor/eac_cli/lib/eac_cli/runner/exit.rb +13 -0
  62. data/vendor/eac_cli/lib/eac_cli/runner_with/help.rb +18 -1
  63. data/vendor/eac_cli/lib/eac_cli/runner_with/output_file.rb +5 -1
  64. data/vendor/eac_cli/lib/eac_cli/runner_with/subcommands.rb +6 -1
  65. data/vendor/eac_cli/lib/eac_cli/version.rb +1 -1
  66. data/vendor/eac_cli/spec/lib/eac_cli/definition/alternative_spec.rb +14 -0
  67. data/vendor/eac_cli/spec/lib/eac_cli/docopt/runner_extension_spec.rb +10 -0
  68. data/vendor/eac_cli/spec/lib/eac_cli/parser/alternative_spec.rb +140 -0
  69. data/vendor/eac_cli/spec/lib/eac_cli/runner_spec.rb +17 -5
  70. data/vendor/eac_cli/spec/lib/eac_cli/runner_with/help_spec.rb +42 -0
  71. data/vendor/eac_cli/spec/lib/eac_cli/runner_with/output_file_spec.rb +53 -0
  72. data/vendor/eac_cli/spec/lib/eac_cli/runner_with/subcommands_spec.rb +29 -1
  73. data/vendor/eac_docker/lib/eac_docker/container.rb +24 -0
  74. data/vendor/eac_docker/lib/eac_docker/images/coded.rb +39 -0
  75. data/vendor/eac_docker/lib/eac_docker/images/templatized.rb +26 -0
  76. data/vendor/eac_docker/lib/eac_docker/registry.rb +17 -0
  77. data/vendor/eac_docker/lib/eac_docker/version.rb +1 -1
  78. data/vendor/eac_docker/spec/lib/eac_docker/images/coded_spec.rb +12 -0
  79. data/vendor/eac_docker/spec/lib/eac_docker/images/coded_spec_files/image1/Dockerfile +1 -0
  80. data/vendor/eac_docker/spec/lib/eac_docker/images/templatized_spec.rb +17 -0
  81. data/vendor/eac_docker/spec/lib/eac_docker/images/templatized_spec_files/stub_docker_image/Dockerfile +1 -0
  82. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/abstract_methods.rb +60 -0
  83. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_concern.rb +2 -50
  84. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_concern/class_setup.rb +52 -0
  85. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_concern/module_setup.rb +31 -0
  86. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_constructor.rb +53 -0
  87. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs.rb +4 -69
  88. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs/entry_reader.rb +81 -0
  89. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs/password_entry_reader.rb +18 -0
  90. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs/read_entry_options.rb +7 -2
  91. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs/store_passwords_entry_reader.rb +27 -0
  92. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/command.rb +4 -6
  93. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/command/concat.rb +33 -0
  94. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/command/envvars.rb +24 -0
  95. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/command/extra_options.rb +0 -21
  96. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/module/abstract_methods.rb +10 -0
  97. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/object/debug.rb +17 -0
  98. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/pathname/basename_sub.rb +2 -2
  99. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/struct.rb +7 -1
  100. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/version.rb +1 -1
  101. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/yaml.rb +3 -2
  102. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/abstract_methods_spec.rb +28 -0
  103. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/common_concern_spec.rb +30 -17
  104. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/common_constructor_spec.rb +66 -8
  105. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/struct_spec.rb +12 -1
  106. data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/version.rb +1 -1
  107. data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/videos/container.rb +30 -2
  108. data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/videos/convert_job.rb +91 -0
  109. data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/videos/stream.rb +51 -0
  110. metadata +92 -13
  111. data/vendor/eac_cli/lib/eac_cli/parser/options_collection.rb +0 -127
  112. data/vendor/eac_cli/lib/eac_cli/parser/parse_result.rb +0 -38
  113. data/vendor/eac_cli/lib/eac_cli/parser/positional_collection.rb +0 -77
  114. data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/videos/container/file.rb +0 -31
  115. data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/videos/container/info.rb +0 -21
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'active_support/concern'
4
+ require 'eac_ruby_utils/simple_cache'
5
+ require 'eac_ruby_utils/patches/object/if_present'
6
+
7
+ module EacRubyUtils
8
+ class CommonConcern
9
+ class ClassSetup
10
+ include ::EacRubyUtils::SimpleCache
11
+ attr_reader :a_class, :module_setup, :include_method
12
+
13
+ def initialize(module_setup, a_class, include_method)
14
+ @module_setup = module_setup
15
+ @a_class = a_class
16
+ @include_method = include_method
17
+ end
18
+
19
+ def run
20
+ %w[class_methods instance_methods after_callback].each do |suffix|
21
+ send("setup_#{suffix}")
22
+ end
23
+ end
24
+
25
+ def setup_class_methods
26
+ class_methods_module.if_present { |v| a_class.extend v }
27
+ end
28
+
29
+ def setup_instance_methods
30
+ instance_methods_module.if_present { |v| a_class.send(include_method, v) }
31
+ end
32
+
33
+ def setup_after_callback
34
+ module_setup.common_concern.after_callback.if_present do |v|
35
+ a_class.instance_eval(&v)
36
+ end
37
+ end
38
+
39
+ def class_methods_module_uncached
40
+ module_setup.a_module.const_get(CLASS_METHODS_MODULE_NAME)
41
+ rescue NameError
42
+ nil
43
+ end
44
+
45
+ def instance_methods_module_uncached
46
+ module_setup.a_module.const_get(INSTANCE_METHODS_MODULE_NAME)
47
+ rescue NameError
48
+ nil
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'active_support/concern'
4
+ require 'eac_ruby_utils/common_concern/class_setup'
5
+ require 'eac_ruby_utils/simple_cache'
6
+ require 'eac_ruby_utils/patches/object/if_present'
7
+
8
+ module EacRubyUtils
9
+ class CommonConcern
10
+ class ModuleSetup
11
+ include ::EacRubyUtils::SimpleCache
12
+ attr_reader :a_module, :common_concern
13
+
14
+ def initialize(common_concern, a_module)
15
+ @common_concern = common_concern
16
+ @a_module = a_module
17
+ end
18
+
19
+ def run
20
+ setup = self
21
+ a_module.extend(::ActiveSupport::Concern)
22
+ a_module.included do
23
+ ::EacRubyUtils::CommonConcern::ClassSetup.new(setup, self, :include).run
24
+ end
25
+ a_module.prepended do
26
+ ::EacRubyUtils::CommonConcern::ClassSetup.new(setup, self, :prepend).run
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -61,6 +61,8 @@ module EacRubyUtils
61
61
  setup_class_attr_readers(klass)
62
62
  setup_class_attr_writers(klass)
63
63
  setup_class_initialize(klass)
64
+
65
+ klass
64
66
  end
65
67
 
66
68
  def setup_class_attr_readers(klass)
@@ -79,9 +81,14 @@ module EacRubyUtils
79
81
  klass.define_callbacks :initialize
80
82
  klass.send(:define_method, :initialize) do |*args|
81
83
  Initialize.new(common_constructor, args, self).run
84
+ super(*SuperArgs.new(common_constructor, args, self).result)
82
85
  end
83
86
  end
84
87
 
88
+ def super_args
89
+ options[:super_args]
90
+ end
91
+
85
92
  class Initialize
86
93
  attr_reader :common_constructor, :args, :object
87
94
 
@@ -129,5 +136,51 @@ module EacRubyUtils
129
136
  " (given #{args.count}, expected #{common_constructor.args_count})"
130
137
  end
131
138
  end
139
+
140
+ class SuperArgs
141
+ attr_reader :common_constructor, :args, :object
142
+
143
+ def initialize(common_constructor, args, object)
144
+ @common_constructor = common_constructor
145
+ @args = args
146
+ @object = object
147
+ end
148
+
149
+ def auto_result
150
+ r = []
151
+ sub_args.each do |name, value|
152
+ i = super_arg_index(name)
153
+ r[i] = value if i
154
+ end
155
+ r
156
+ end
157
+
158
+ def result
159
+ result_from_options || auto_result
160
+ end
161
+
162
+ def result_from_options
163
+ return unless common_constructor.super_args
164
+
165
+ object.instance_exec(&common_constructor.super_args)
166
+ end
167
+
168
+ def sub_args
169
+ common_constructor.args.each_with_index.map do |name, index|
170
+ [name, args[index]]
171
+ end.to_h
172
+ end
173
+
174
+ def super_arg_index(name)
175
+ super_method.parameters.each_with_index do |arg, index|
176
+ return index if arg[1] == name
177
+ end
178
+ nil
179
+ end
180
+
181
+ def super_method
182
+ object.class.superclass ? object.class.superclass.instance_method(:initialize) : nil
183
+ end
184
+ end
132
185
  end
133
186
  end
@@ -11,18 +11,10 @@ module EacRubyUtils
11
11
 
12
12
  class << self
13
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
14
+ ::EacRubyUtils::Console::Configs::EntryReader.entry_key_to_envvar_name(entry_key)
21
15
  end
22
16
  end
23
17
 
24
- STORE_PASSWORDS_KEY = 'core.store_passwords'
25
-
26
18
  attr_reader :configs
27
19
 
28
20
  def initialize(configs_key, options = {})
@@ -31,72 +23,15 @@ module EacRubyUtils
31
23
  end
32
24
 
33
25
  def read_password(entry_key, options = {})
34
- options = ReadEntryOptions.new(options.merge(noecho: true))
35
- if store_passwords?
36
- read_entry(entry_key, options)
37
- else
38
- looped_entry_value_from_input(entry_key, options)
39
- end
26
+ ::EacRubyUtils::Console::Configs::PasswordEntryReader.new(self, entry_key, options).read
40
27
  end
41
28
 
42
29
  def read_entry(entry_key, options = {})
43
- options = ReadEntryOptions.new(options)
44
- unless options[:noenv]
45
- envvar_value = envvar_read_entry(entry_key)
46
- return envvar_value if envvar_value.present?
47
- end
48
- stored_value = configs.read_entry(entry_key)
49
- return stored_value if stored_value
50
- return read_entry_from_console(entry_key, options) unless options[:noinput]
51
-
52
- raise "No value found for entry \"#{entry_key}\"" if options[:required]
30
+ ::EacRubyUtils::Console::Configs::EntryReader.new(self, entry_key, options).read
53
31
  end
54
32
 
55
33
  def store_passwords?
56
- read_entry(
57
- STORE_PASSWORDS_KEY,
58
- before_input: -> { store_password_banner },
59
- validator: ->(entry_value) { %w[yes no].include?(entry_value) }
60
- ) == 'yes'
61
- end
62
-
63
- protected
64
-
65
- def envvar_read_entry(entry_key)
66
- env_entry_key = self.class.entry_key_to_envvar_name(entry_key)
67
- return nil unless ENV.key?(env_entry_key)
68
-
69
- ENV.fetch(env_entry_key).if_present(::EacRubyUtils::BlankNotBlank.instance)
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
34
+ ::EacRubyUtils::Console::Configs::StorePasswordsEntryReader.new(self) == 'yes'
100
35
  end
101
36
  end
102
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
@@ -7,13 +7,18 @@ module EacRubyUtils
7
7
  class Configs
8
8
  class ReadEntryOptions
9
9
  enable_simple_cache
10
- common_constructor :options
10
+ common_constructor :options do
11
+ self.options = options.to_h.symbolize_keys
12
+ .assert_valid_keys(DEFAULT_VALUES.keys).freeze
13
+ end
11
14
 
12
15
  DEFAULT_VALUES = {
13
16
  before_input: nil, bool: false, list: false, noecho: false, noenv: false, noinput: false,
14
- required: true, validator: nil
17
+ required: true, store: true, validator: nil
15
18
  }.freeze
16
19
 
20
+ delegate :to_h, to: :options
21
+
17
22
  def [](key)
18
23
  values.fetch(key.to_sym)
19
24
  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 'active_support/core_ext/hash/indifferent_access'
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
- include EacRubyUtils::Console::Speaker
15
- include EacRubyUtils::Envs::Command::ExtraOptions
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(append_pipe(append_envvars(c)))
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