ehbrs-tools 0.12.0 → 0.15.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (121) hide show
  1. checksums.yaml +4 -4
  2. data/lib/ehbrs/executables.rb +1 -1
  3. data/lib/ehbrs/runner.rb +9 -13
  4. data/lib/ehbrs/runner/finances.rb +19 -0
  5. data/lib/ehbrs/runner/finances/bb_browser.rb +40 -0
  6. data/lib/ehbrs/runner/fs/used_space.rb +4 -4
  7. data/lib/ehbrs/runner/videos.rb +6 -11
  8. data/lib/ehbrs/runner/videos/probe.rb +35 -0
  9. data/lib/ehbrs/runner/web_utils.rb +26 -0
  10. data/lib/ehbrs/runner/web_utils/videos.rb +20 -0
  11. data/lib/ehbrs/runner/web_utils/videos/download.rb +66 -0
  12. data/lib/ehbrs/runner/web_utils/videos/upload.rb +78 -0
  13. data/lib/ehbrs/tools/version.rb +1 -1
  14. data/lib/ehbrs/videos/file.rb +2 -1
  15. data/lib/ehbrs/videos/unsupported/fix_profile.rb +1 -0
  16. data/vendor/eac_cli/eac_cli.gemspec +3 -3
  17. data/vendor/eac_cli/lib/eac_cli/core_ext.rb +4 -0
  18. data/vendor/eac_cli/lib/eac_cli/default_runner.rb +6 -14
  19. data/vendor/eac_cli/lib/eac_cli/definition.rb +72 -0
  20. data/vendor/eac_cli/lib/eac_cli/definition/argument_option.rb +13 -0
  21. data/vendor/eac_cli/lib/eac_cli/{runner → definition}/base_option.rb +5 -1
  22. data/vendor/eac_cli/lib/eac_cli/definition/boolean_option.rb +13 -0
  23. data/vendor/eac_cli/lib/eac_cli/{runner → definition}/positional_argument.rb +5 -1
  24. data/vendor/eac_cli/lib/eac_cli/{runner/docopt_doc.rb → docopt/doc_builder.rb} +15 -8
  25. data/vendor/eac_cli/lib/eac_cli/docopt/runner_extension.rb +45 -0
  26. data/vendor/eac_cli/lib/eac_cli/parser.rb +14 -0
  27. data/vendor/eac_cli/lib/eac_cli/parser/collector.rb +56 -0
  28. data/vendor/eac_cli/lib/eac_cli/parser/error.rb +15 -0
  29. data/vendor/eac_cli/lib/eac_cli/parser/options_collection.rb +105 -0
  30. data/vendor/eac_cli/lib/eac_cli/parser/parse_result.rb +21 -0
  31. data/vendor/eac_cli/lib/eac_cli/parser/positional_collection.rb +49 -0
  32. data/vendor/eac_cli/lib/eac_cli/patches.rb +4 -0
  33. data/vendor/eac_cli/lib/eac_cli/patches/object.rb +5 -0
  34. data/vendor/eac_cli/lib/eac_cli/patches/object/runner_with.rb +24 -0
  35. data/vendor/eac_cli/lib/eac_cli/runner.rb +64 -7
  36. data/vendor/eac_cli/lib/eac_cli/runner/context.rb +18 -0
  37. data/vendor/eac_cli/lib/eac_cli/runner_with.rb +9 -0
  38. data/vendor/eac_cli/lib/eac_cli/runner_with/help.rb +19 -0
  39. data/vendor/eac_cli/lib/eac_cli/runner_with/output_file.rb +26 -0
  40. data/vendor/eac_cli/lib/eac_cli/version.rb +1 -1
  41. data/vendor/eac_cli/spec/lib/eac_cli/runner_spec.rb +70 -0
  42. data/vendor/eac_docker/Gemfile +5 -0
  43. data/vendor/eac_docker/eac_docker.gemspec +18 -0
  44. data/vendor/eac_docker/lib/eac_docker.rb +7 -0
  45. data/vendor/eac_docker/lib/eac_docker/container.rb +50 -0
  46. data/vendor/eac_docker/lib/eac_docker/executables.rb +18 -0
  47. data/vendor/eac_docker/lib/eac_docker/images.rb +9 -0
  48. data/vendor/eac_docker/lib/eac_docker/images/base.rb +14 -0
  49. data/vendor/eac_docker/lib/eac_docker/images/named.rb +30 -0
  50. data/vendor/eac_docker/lib/eac_docker/rspec.rb +17 -0
  51. data/vendor/eac_docker/lib/eac_docker/version.rb +5 -0
  52. data/vendor/eac_docker/spec/lib/eac_docker/executables_spec.rb +9 -0
  53. data/vendor/eac_docker/spec/rubocop_spec.rb +7 -0
  54. data/vendor/eac_docker/spec/spec_helper.rb +103 -0
  55. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/boolean.rb +31 -0
  56. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_concern.rb +4 -4
  57. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/docopt_runner.rb +6 -0
  58. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/docopt_runner/_class_methods.rb +2 -2
  59. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/docopt_runner/_subcommands.rb +8 -2
  60. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/command.rb +1 -0
  61. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/command/extra_options.rb +8 -0
  62. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/ssh_env.rb +12 -9
  63. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/ssh_env/dasho_options.rb +53 -0
  64. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/ssh_env/identity_file.rb +25 -0
  65. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/ssh_env/quiet.rb +24 -0
  66. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/ssh_env/terminal.rb +34 -0
  67. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/fs_cache.rb +1 -0
  68. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/immutable.rb +15 -0
  69. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/immutable/array_accessor.rb +32 -0
  70. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/immutable/base_accessor.rb +23 -0
  71. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/immutable/boolean_accessor.rb +16 -0
  72. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/immutable/class_methods.rb +20 -0
  73. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/immutable/common_accessor.rb +30 -0
  74. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/immutable/hash_accessor.rb +46 -0
  75. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/immutable/instance_methods.rb +21 -0
  76. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/inflector.rb +18 -0
  77. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/listable/list.rb +5 -0
  78. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/listable/value.rb +3 -2
  79. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/module/immutable.rb +10 -0
  80. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/object/if_respond.rb +22 -0
  81. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/string.rb +4 -0
  82. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/string/inflector.rb +9 -0
  83. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/require_sub.rb +38 -11
  84. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/simple_cache.rb +6 -2
  85. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/struct.rb +53 -0
  86. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/templates/directory.rb +7 -1
  87. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/templates/file.rb +8 -59
  88. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/templates/variable_not_found_error.rb +7 -0
  89. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/templates/variable_providers.rb +25 -0
  90. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/templates/variable_providers/base.rb +23 -0
  91. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/templates/variable_providers/entries_reader.rb +25 -0
  92. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/templates/variable_providers/generic.rb +25 -0
  93. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/templates/variable_providers/hash.rb +29 -0
  94. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/version.rb +1 -1
  95. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/inflector_spec.rb +15 -0
  96. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/ruby_spec.rb +22 -0
  97. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/struct_spec.rb +46 -0
  98. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/templates/file_spec.rb +1 -0
  99. data/vendor/ehbrs_ruby_utils/Gemfile +16 -0
  100. data/vendor/ehbrs_ruby_utils/ehbrs_ruby_utils.gemspec +20 -0
  101. data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils.rb +7 -0
  102. data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/executables.rb +28 -0
  103. data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/version.rb +5 -0
  104. data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/videos.rb +9 -0
  105. data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/videos/container.rb +11 -0
  106. data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/videos/container/file.rb +31 -0
  107. data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/videos/container/info.rb +21 -0
  108. data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/videos/quality.rb +68 -0
  109. data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/videos/resolution.rb +68 -0
  110. data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/web_utils.rb +9 -0
  111. data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/web_utils/instance.rb +32 -0
  112. data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/web_utils/videos.rb +11 -0
  113. data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/web_utils/videos/file.rb +40 -0
  114. data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/web_utils/videos/files_list.rb +76 -0
  115. data/vendor/ehbrs_ruby_utils/spec/lib/ehbrs_ruby_utils/videos/resolution_spec.rb +18 -0
  116. data/vendor/ehbrs_ruby_utils/spec/rubocop_check_spec.rb +7 -0
  117. data/vendor/ehbrs_ruby_utils/spec/spec_helper.rb +100 -0
  118. metadata +92 -10
  119. data/vendor/eac_cli/lib/eac_cli/runner/argument_option.rb +0 -13
  120. data/vendor/eac_cli/lib/eac_cli/runner/boolean_option.rb +0 -13
  121. data/vendor/eac_cli/lib/eac_cli/runner/definition.rb +0 -64
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+ require 'eac_ruby_utils/envs'
5
+
6
+ module EacDocker
7
+ module Executables
8
+ class << self
9
+ def env
10
+ ::EacRubyUtils::Envs.local
11
+ end
12
+
13
+ def docker
14
+ @docker ||= env.executable('docker', '--version')
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module EacDocker
6
+ module Images
7
+ require_sub __FILE__
8
+ end
9
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+ require 'eac_docker/container'
5
+
6
+ module EacDocker
7
+ module Images
8
+ class Base
9
+ def container
10
+ ::EacDocker::Container.new(self)
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_docker/executables'
4
+ require 'eac_docker/images/base'
5
+ require 'eac_ruby_utils/core_ext'
6
+
7
+ module EacDocker
8
+ module Images
9
+ class Named < ::EacDocker::Images::Base
10
+ common_constructor :source_tag
11
+
12
+ def id
13
+ source_tag
14
+ end
15
+
16
+ def provide
17
+ provide_command.execute!
18
+ self
19
+ end
20
+
21
+ def provide_command
22
+ ::EacDocker::Executables.docker.command(*docker_provide_args)
23
+ end
24
+
25
+ def docker_provide_args
26
+ ['pull', source_tag]
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/rspec/conditional'
4
+ require 'eac_docker/executables'
5
+
6
+ module EacDocker
7
+ module Rspec
8
+ class << self
9
+ def configure
10
+ ::EacRubyUtils::Rspec::Conditional.default.add(:docker) do
11
+ ::EacDocker::Executables.docker.validate
12
+ end
13
+ RSpec.configure { |config| ::EacRubyUtils::Rspec::Conditional.default.configure(config) }
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EacDocker
4
+ VERSION = '0.1.0'
5
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_docker/executables'
4
+
5
+ RSpec.describe(::EacDocker::Executables, docker: true) do
6
+ it 'output version' do
7
+ expect(described_class.docker.command('--version').execute!).to be_present
8
+ end
9
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_gem_support/spec/examples/rubocop_check'
4
+
5
+ RSpec.describe ::RuboCop, slow: true do
6
+ include_examples 'rubocop_check', ::File.expand_path('..', __dir__)
7
+ end
@@ -0,0 +1,103 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This file was generated by the `rspec --init` command. Conventionally, all
4
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
5
+ # The generated `.rspec` file contains `--require spec_helper` which will cause
6
+ # this file to always be loaded, without a need to explicitly require it in any
7
+ # files.
8
+ #
9
+ # Given that it is always loaded, you are encouraged to keep this file as
10
+ # light-weight as possible. Requiring heavyweight dependencies from this file
11
+ # will add to the boot time of your test suite on EVERY test run, even for an
12
+ # individual file that may not need all of that loaded. Instead, consider making
13
+ # a separate helper file that requires the additional dependencies and performs
14
+ # the additional setup, and require it from the spec files that actually need
15
+ # it.
16
+ #
17
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
18
+ RSpec.configure do |config|
19
+ # rspec-expectations config goes here. You can use an alternate
20
+ # assertion/expectation library such as wrong or the stdlib/minitest
21
+ # assertions if you prefer.
22
+ config.expect_with :rspec do |expectations|
23
+ # This option will default to `true` in RSpec 4. It makes the `description`
24
+ # and `failure_message` of custom matchers include text for helper methods
25
+ # defined using `chain`, e.g.:
26
+ # be_bigger_than(2).and_smaller_than(4).description
27
+ # # => "be bigger than 2 and smaller than 4"
28
+ # ...rather than:
29
+ # # => "be bigger than 2"
30
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
31
+ end
32
+
33
+ # rspec-mocks config goes here. You can use an alternate test double
34
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
35
+ config.mock_with :rspec do |mocks|
36
+ # Prevents you from mocking or stubbing a method that does not exist on
37
+ # a real object. This is generally recommended, and will default to
38
+ # `true` in RSpec 4.
39
+ mocks.verify_partial_doubles = true
40
+ end
41
+
42
+ # This option will default to `:apply_to_host_groups` in RSpec 4 (and will
43
+ # have no way to turn it off -- the option exists only for backwards
44
+ # compatibility in RSpec 3). It causes shared context metadata to be
45
+ # inherited by the metadata hash of host groups and examples, rather than
46
+ # triggering implicit auto-inclusion in groups with matching metadata.
47
+ config.shared_context_metadata_behavior = :apply_to_host_groups
48
+
49
+ # The settings below are suggested to provide a good initial experience
50
+ # with RSpec, but feel free to customize to your heart's content.
51
+ # # This allows you to limit a spec run to individual examples or groups
52
+ # # you care about by tagging them with `:focus` metadata. When nothing
53
+ # # is tagged with `:focus`, all examples get run. RSpec also provides
54
+ # # aliases for `it`, `describe`, and `context` that include `:focus`
55
+ # # metadata: `fit`, `fdescribe` and `fcontext`, respectively.
56
+ # config.filter_run_when_matching :focus
57
+ #
58
+ # # Allows RSpec to persist some state between runs in order to support
59
+ # # the `--only-failures` and `--next-failure` CLI options. We recommend
60
+ # # you configure your source control system to ignore this file.
61
+ # config.example_status_persistence_file_path = "spec/examples.txt"
62
+ #
63
+ # # Limits the available syntax to the non-monkey patched syntax that is
64
+ # # recommended. For more details, see:
65
+ # # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
66
+ # # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
67
+ # # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
68
+ # config.disable_monkey_patching!
69
+ #
70
+ # # This setting enables warnings. It's recommended, but in some cases may
71
+ # # be too noisy due to issues in dependencies.
72
+ # config.warnings = true
73
+ #
74
+ # # Many RSpec users commonly either run the entire suite or an individual
75
+ # # file, and it's useful to allow more verbose output when running an
76
+ # # individual spec file.
77
+ # if config.files_to_run.one?
78
+ # # Use the documentation formatter for detailed output,
79
+ # # unless a formatter has already been configured
80
+ # # (e.g. via a command-line flag).
81
+ # config.default_formatter = "doc"
82
+ # end
83
+ #
84
+ # # Print the 10 slowest examples and example groups at the
85
+ # # end of the spec run, to help surface which specs are running
86
+ # # particularly slow.
87
+ # config.profile_examples = 10
88
+ #
89
+ # # Run specs in random order to surface order dependencies. If you find an
90
+ # # order dependency and want to debug it, you can fix the order by providing
91
+ # # the seed, which is printed after each run.
92
+ # # --seed 1234
93
+ # config.order = :random
94
+ #
95
+ # # Seed global randomization in this process using the `--seed` CLI option.
96
+ # # Setting this allows you to use `--seed` to deterministically reproduce
97
+ # # test failures related to randomization by passing the same `--seed` value
98
+ # # as the one that triggered the failure.
99
+ # Kernel.srand config.seed
100
+ end
101
+
102
+ require 'eac_docker/rspec'
103
+ ::EacDocker::Rspec.configure
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EacRubyUtils
4
+ class Boolean
5
+ class << self
6
+ def parse(value)
7
+ return parse_string(value) if value.is_a?(::String)
8
+ return parse_string(value.to_s) if value.is_a?(::Symbol)
9
+ return parse_number(value) if value.is_a?(::Number)
10
+
11
+ value ? true : false
12
+ end
13
+
14
+ private
15
+
16
+ def parse_string(value)
17
+ ['', 'n', 'no', 'f', 'false'].include?(value.strip.downcase) ? false : true
18
+ end
19
+
20
+ def parse_number(value)
21
+ value.zero?
22
+ end
23
+ end
24
+
25
+ attr_reader :value
26
+
27
+ def initialize(value)
28
+ @value = self.class.parse(value)
29
+ end
30
+ end
31
+ end
@@ -21,10 +21,10 @@ module EacRubyUtils
21
21
 
22
22
  class Setup
23
23
  include ::EacRubyUtils::SimpleCache
24
- attr_reader :a_module, :common_constructor
24
+ attr_reader :a_module, :common_concern
25
25
 
26
- def initialize(common_constructor, a_module)
27
- @common_constructor = common_constructor
26
+ def initialize(common_concern, a_module)
27
+ @common_concern = common_concern
28
28
  @a_module = a_module
29
29
  end
30
30
 
@@ -47,7 +47,7 @@ module EacRubyUtils
47
47
  end
48
48
 
49
49
  def setup_after_callback(base)
50
- common_constructor.after_callback.if_present do |v|
50
+ common_concern.after_callback.if_present do |v|
51
51
  base.instance_eval(&v)
52
52
  end
53
53
  end
@@ -14,6 +14,12 @@ module EacRubyUtils
14
14
  class DocoptRunner
15
15
  include ::EacRubyUtils::Contextualizable
16
16
 
17
+ class << self
18
+ def create(settings = {})
19
+ new(settings)
20
+ end
21
+ end
22
+
17
23
  attr_reader :settings
18
24
 
19
25
  def initialize(settings = {})
@@ -3,11 +3,11 @@
3
3
  module EacRubyUtils
4
4
  module Console
5
5
  class DocoptRunner
6
- DOCOPT_ERROR_EXIT_CODE = 0x22220000
6
+ DOCOPT_ERROR_EXIT_CODE = 0xC0
7
7
 
8
8
  class << self
9
9
  def run(options = {})
10
- new(options).send(:run)
10
+ create(options).send(:run)
11
11
  rescue Docopt::Exit => e
12
12
  STDERR.write(e.message + "\n")
13
13
  ::Kernel.exit(DOCOPT_ERROR_EXIT_CODE) # rubocop:disable Rails/Exit
@@ -25,6 +25,8 @@ module EacRubyUtils
25
25
  end
26
26
 
27
27
  module SubcommandsSupport
28
+ EXTRA_AVAILABLE_SUBCOMMANDS_METHOD_NAME = :extra_available_subcommands
29
+
28
30
  def check_subcommands_arg
29
31
  if subcommand_arg_as_list?
30
32
  singleton_class.include(SubcommandsSupport::SubcommandArgAsList)
@@ -43,7 +45,7 @@ module EacRubyUtils
43
45
  end
44
46
 
45
47
  def subcommand
46
- @subcommand ||= subcommand_class_name(subcommand_name).constantize.new(
48
+ @subcommand ||= subcommand_class_name(subcommand_name).constantize.create(
47
49
  argv: subcommand_args,
48
50
  program_name: subcommand_program,
49
51
  parent: self
@@ -77,7 +79,11 @@ module EacRubyUtils
77
79
  end
78
80
 
79
81
  def available_subcommands
80
- (setting_value(:subcommands, false) || auto_available_subcommands).sort
82
+ r = ::Set.new(setting_value(:subcommands, false) || auto_available_subcommands)
83
+ if respond_to?(EXTRA_AVAILABLE_SUBCOMMANDS_METHOD_NAME, true)
84
+ r += send(EXTRA_AVAILABLE_SUBCOMMANDS_METHOD_NAME)
85
+ end
86
+ r.sort
81
87
  end
82
88
 
83
89
  def auto_available_subcommands
@@ -54,6 +54,7 @@ module EacRubyUtils
54
54
  end
55
55
 
56
56
  def execute!(options = {})
57
+ options[:exit_outputs] = status_results.merge(options[:exit_outputs].presence || {})
57
58
  er = ExecuteResult.new(execute(options), options)
58
59
  return er.result if er.success?
59
60
 
@@ -16,6 +16,10 @@ module EacRubyUtils
16
16
  duplicate_by_extra_options(envvars: envvars.merge(name => value))
17
17
  end
18
18
 
19
+ def status_result(status_code, result)
20
+ duplicate_by_extra_options(status_results: status_results.merge(status_code => result))
21
+ end
22
+
19
23
  def pipe(other_command)
20
24
  duplicate_by_extra_options(pipe: other_command)
21
25
  end
@@ -28,6 +32,10 @@ module EacRubyUtils
28
32
  extra_options[:envvars] ||= {}.with_indifferent_access
29
33
  end
30
34
 
35
+ def status_results
36
+ extra_options[:status_results] ||= {}.with_indifferent_access
37
+ end
38
+
31
39
  def append_envvars(command)
32
40
  e = envvars.map { |k, v| "#{Shellwords.escape(k)}=#{Shellwords.escape(v)}" }.join(' ')
33
41
  e.present? ? "#{e} #{command}" : command
@@ -2,12 +2,16 @@
2
2
 
3
3
  require 'addressable'
4
4
  require 'eac_ruby_utils/envs/base_env'
5
+ require 'eac_ruby_utils/patches/object/if_present'
6
+ require 'eac_ruby_utils/patches/module/require_sub'
5
7
  require 'net/ssh'
6
8
  require 'shellwords'
7
9
 
8
10
  module EacRubyUtils
9
11
  module Envs
10
12
  class SshEnv < ::EacRubyUtils::Envs::BaseEnv
13
+ require_sub __FILE__, include_modules: true
14
+
11
15
  USER_PATTERN = /[a-z_][a-z0-9_-]*/.freeze
12
16
  HOSTNAME_PATTERN = /[^@]+/.freeze
13
17
  USER_HOSTNAME_PATTERN = /\A(?:(#{USER_PATTERN})@)?(#{HOSTNAME_PATTERN})\z/.freeze
@@ -49,17 +53,16 @@ module EacRubyUtils
49
53
  private
50
54
 
51
55
  def ssh_command_line
52
- r = %w[ssh]
53
- r += ['-p', uri.port] if uri.port.present?
54
- r += ssh_command_line_options
55
- r << user_hostname_uri
56
- r.map { |a| Shellwords.escape(a) }.join(' ')
56
+ (%w[ssh] +
57
+ %w[nodasho dasho port].flat_map { |m| send("ssh_command_line_#{m}_args") } +
58
+ [user_hostname_uri])
59
+ .map { |a| Shellwords.escape(a) }.join(' ')
57
60
  end
58
61
 
59
- def ssh_command_line_options
60
- r = []
61
- uri.query_values&.each { |k, v| r += ['-o', "#{k}=#{v}"] }
62
- r
62
+ def ssh_command_line_port_args
63
+ uri.port.if_present([]) do |v|
64
+ ['-p', v]
65
+ end
63
66
  end
64
67
 
65
68
  def user_hostname_uri
@@ -0,0 +1,53 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/patches/module/common_concern'
4
+ require 'eac_ruby_utils/patches/module/simple_cache'
5
+
6
+ module EacRubyUtils
7
+ module Envs
8
+ class SshEnv < ::EacRubyUtils::Envs::BaseEnv
9
+ module DashoOptions
10
+ common_concern
11
+
12
+ module ClassMethods
13
+ def add_nodasho_option(name)
14
+ return if nodasho_options.include?(name)
15
+
16
+ nodasho_options << name
17
+ const_set("#{name.underscore}_option".upcase, name)
18
+ end
19
+
20
+ def nodasho_options
21
+ @nodasho_options ||= []
22
+ end
23
+ end
24
+
25
+ module InstanceMethods
26
+ def ssh_command_line_dasho_args
27
+ r = []
28
+ uri.query_values&.each do |k, v|
29
+ r += ['-o', "#{k}=#{v}"] unless nodasho_options.include?(k)
30
+ end
31
+ r
32
+ end
33
+
34
+ def ssh_command_line_nodasho_args
35
+ nodasho_options.flat_map do |option_name|
36
+ uri_query_value(option_name).if_present([]) do |option_value|
37
+ send("ssh_command_line_#{option_name.underscore}_args", option_value)
38
+ end
39
+ end
40
+ end
41
+
42
+ def nodasho_options
43
+ self.class.nodasho_options
44
+ end
45
+
46
+ def uri_query_value(name)
47
+ uri.query_values.if_present { |v| v[name] }
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end