ehbrs-tools 0.16.2 → 0.18.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ehbrs/cooking_book.rb +9 -0
- data/lib/ehbrs/cooking_book/build.rb +45 -0
- data/lib/ehbrs/cooking_book/build/base_page.rb +43 -0
- data/lib/ehbrs/cooking_book/build/index_page.rb +26 -0
- data/lib/ehbrs/cooking_book/build/recipe_page.rb +27 -0
- data/lib/ehbrs/cooking_book/project.rb +25 -0
- data/lib/ehbrs/cooking_book/recipe.rb +37 -0
- data/lib/ehbrs/cooking_book/recipe/ingredient.rb +21 -0
- data/lib/ehbrs/cooking_book/recipe/measure.rb +60 -0
- data/lib/ehbrs/cooking_book/recipe/part.rb +32 -0
- data/lib/ehbrs/patches/module/erb_template.rb +11 -0
- data/lib/ehbrs/patches/object/erb_template.rb +9 -0
- data/lib/ehbrs/patches/object/template.rb +7 -0
- data/lib/ehbrs/runner.rb +6 -13
- data/lib/ehbrs/runner/cooking_book.rb +30 -0
- data/lib/ehbrs/runner/cooking_book/build.rb +32 -0
- data/lib/ehbrs/runner/telegram.rb +26 -0
- data/lib/ehbrs/runner/telegram/send_message.rb +29 -0
- data/lib/ehbrs/telegram.rb +9 -0
- data/lib/ehbrs/telegram/message_sending.rb +32 -0
- data/lib/ehbrs/tools/application.rb +13 -0
- data/lib/ehbrs/tools/instance.rb +16 -0
- data/lib/ehbrs/tools/version.rb +1 -1
- data/lib/ehbrs/videos/track.rb +1 -19
- data/lib/ehbrs/videos/unsupported/checks/codec_extra_unlisted.rb +1 -1
- data/lib/ehbrs/videos/unsupported/checks/codec_extra_unsupported.rb +1 -1
- data/lib/ehbrs/videos/unsupported/checks/codec_unlisted.rb +2 -2
- data/lib/ehbrs/videos/unsupported/checks/codec_unsupported.rb +1 -1
- data/lib/ehbrs/videos/unsupported/fix_profile.rb +0 -13
- data/lib/ehbrs/videos/unsupported/fixes/supported_codec.rb +10 -10
- data/template/ehbrs/cooking_book/build/base_page/layout.html.erb +20 -0
- data/template/ehbrs/cooking_book/build/index_page/inner.html.erb +6 -0
- data/template/ehbrs/cooking_book/build/recipe_page/inner.html.erb +6 -0
- data/template/ehbrs/cooking_book/build/recipe_page/part.html.erb +27 -0
- data/vendor/eac_cli/eac_cli.gemspec +1 -1
- data/vendor/eac_cli/lib/eac_cli/docopt/runner_context_replacement.rb +15 -0
- data/vendor/eac_cli/lib/eac_cli/docopt/runner_extension.rb +5 -0
- data/vendor/eac_cli/lib/eac_cli/parser.rb +6 -4
- data/vendor/eac_cli/lib/eac_cli/parser/alternative.rb +8 -4
- data/vendor/eac_cli/lib/eac_cli/parser/alternative/long_options.rb +37 -0
- data/vendor/eac_cli/lib/eac_cli/parser/alternative/option_argument.rb +29 -0
- data/vendor/eac_cli/lib/eac_cli/parser/alternative/options.rb +7 -36
- data/vendor/eac_cli/lib/eac_cli/parser/alternative/short_options.rb +45 -0
- data/vendor/eac_cli/lib/eac_cli/runner.rb +10 -2
- data/vendor/eac_cli/lib/eac_cli/runner/exit.rb +13 -0
- data/vendor/eac_cli/lib/eac_cli/runner_with/help.rb +17 -0
- data/vendor/eac_cli/lib/eac_cli/runner_with/subcommands.rb +19 -2
- data/vendor/eac_cli/lib/eac_cli/version.rb +1 -1
- data/vendor/eac_cli/spec/lib/eac_cli/runner_spec.rb +28 -4
- 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/subcommands_spec.rb +29 -1
- 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_base0/Gemfile +5 -0
- data/vendor/eac_ruby_base0/eac_ruby_base0.gemspec +20 -0
- data/vendor/eac_ruby_base0/lib/eac_ruby_base0.rb +7 -0
- data/vendor/eac_ruby_base0/lib/eac_ruby_base0/application.rb +69 -0
- data/vendor/eac_ruby_base0/lib/eac_ruby_base0/runner.rb +54 -0
- data/vendor/eac_ruby_base0/lib/eac_ruby_base0/runner/test_all.rb +22 -0
- data/vendor/eac_ruby_base0/lib/eac_ruby_base0/version.rb +5 -0
- data/vendor/eac_ruby_base0/spec/rubocop_spec.rb +7 -0
- data/vendor/eac_ruby_base0/spec/spec_helper.rb +100 -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 +41 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_constructor.rb +6 -50
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_constructor/class_initialize.rb +29 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_constructor/instance_initialize.rb +53 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_constructor/super_args.rb +54 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/docopt_runner/_subcommands.rb +10 -1
- 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/traverser.rb +0 -2
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/inflector.rb +4 -1
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/local_time_zone.rb +38 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/kernel.rb +4 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/kernel/nyi.rb +8 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/module/template.rb +10 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/object/template.rb +1 -8
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/pathname/basename_sub.rb +2 -2
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/time/default_time_zone_set.rb +3 -2
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/struct.rb +7 -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 +8 -0
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/common_concern_spec.rb +40 -17
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/common_constructor_spec.rb +96 -8
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/inflector_spec.rb +2 -1
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/local_time_zone_spec.rb +17 -0
- 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/stream.rb +1 -1
- metadata +101 -9
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/time/local_time_zone.rb +0 -25
@@ -1,8 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require '
|
4
|
-
require 'eac_ruby_utils/simple_cache'
|
5
|
-
require 'eac_ruby_utils/patches/object/if_present'
|
3
|
+
require 'eac_ruby_utils/common_concern/module_setup'
|
6
4
|
|
7
5
|
module EacRubyUtils
|
8
6
|
class CommonConcern
|
@@ -16,53 +14,7 @@ module EacRubyUtils
|
|
16
14
|
end
|
17
15
|
|
18
16
|
def setup(a_module)
|
19
|
-
|
20
|
-
end
|
21
|
-
|
22
|
-
class Setup
|
23
|
-
include ::EacRubyUtils::SimpleCache
|
24
|
-
attr_reader :a_module, :common_concern
|
25
|
-
|
26
|
-
def initialize(common_concern, a_module)
|
27
|
-
@common_concern = common_concern
|
28
|
-
@a_module = a_module
|
29
|
-
end
|
30
|
-
|
31
|
-
def run
|
32
|
-
setup = self
|
33
|
-
a_module.extend(::ActiveSupport::Concern)
|
34
|
-
a_module.included do
|
35
|
-
%w[class_methods instance_methods after_callback].each do |suffix|
|
36
|
-
setup.send("setup_#{suffix}", self)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
def setup_class_methods(base)
|
42
|
-
class_methods_module.if_present { |v| base.extend v }
|
43
|
-
end
|
44
|
-
|
45
|
-
def setup_instance_methods(base)
|
46
|
-
instance_methods_module.if_present { |v| base.include v }
|
47
|
-
end
|
48
|
-
|
49
|
-
def setup_after_callback(base)
|
50
|
-
common_concern.after_callback.if_present do |v|
|
51
|
-
base.instance_eval(&v)
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
def class_methods_module_uncached
|
56
|
-
a_module.const_get(CLASS_METHODS_MODULE_NAME)
|
57
|
-
rescue NameError
|
58
|
-
nil
|
59
|
-
end
|
60
|
-
|
61
|
-
def instance_methods_module_uncached
|
62
|
-
a_module.const_get(INSTANCE_METHODS_MODULE_NAME)
|
63
|
-
rescue NameError
|
64
|
-
nil
|
65
|
-
end
|
17
|
+
::EacRubyUtils::CommonConcern::ModuleSetup.new(self, a_module).run
|
66
18
|
end
|
67
19
|
end
|
68
20
|
end
|
@@ -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,41 @@
|
|
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
|
+
a_module.extend(::ActiveSupport::Concern)
|
21
|
+
include_or_prepend(:included, :include)
|
22
|
+
include_or_prepend(:prepended, :prepend)
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def include_or_prepend(module_method, class_setup_method)
|
28
|
+
setup = self
|
29
|
+
a_module.send(module_method, *a_module_method_args(module_method)) do
|
30
|
+
::EacRubyUtils::CommonConcern::ClassSetup.new(setup, self, class_setup_method).run
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def a_module_method_args(module_method)
|
35
|
+
method_arity = a_module.method(module_method).arity
|
36
|
+
method_arity = -method_arity - 1 if method_arity.negative?
|
37
|
+
method_arity.times.map { |_n| a_module }
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'active_support/callbacks'
|
4
4
|
require 'eac_ruby_utils/arguments_consumer'
|
5
|
+
require 'eac_ruby_utils/common_constructor/class_initialize'
|
5
6
|
require 'ostruct'
|
6
7
|
|
7
8
|
module EacRubyUtils
|
@@ -61,6 +62,8 @@ module EacRubyUtils
|
|
61
62
|
setup_class_attr_readers(klass)
|
62
63
|
setup_class_attr_writers(klass)
|
63
64
|
setup_class_initialize(klass)
|
65
|
+
|
66
|
+
klass
|
64
67
|
end
|
65
68
|
|
66
69
|
def setup_class_attr_readers(klass)
|
@@ -74,60 +77,13 @@ module EacRubyUtils
|
|
74
77
|
end
|
75
78
|
|
76
79
|
def setup_class_initialize(klass)
|
77
|
-
common_constructor = self
|
78
80
|
klass.include(::ActiveSupport::Callbacks)
|
79
81
|
klass.define_callbacks :initialize
|
80
|
-
|
81
|
-
Initialize.new(common_constructor, args, self).run
|
82
|
-
end
|
82
|
+
::EacRubyUtils::CommonConstructor::ClassInitialize.new(self, klass).run
|
83
83
|
end
|
84
84
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
def initialize(common_constructor, args, object)
|
89
|
-
@common_constructor = common_constructor
|
90
|
-
@args = args
|
91
|
-
@object = object
|
92
|
-
end
|
93
|
-
|
94
|
-
def run
|
95
|
-
validate_args_count
|
96
|
-
object.run_callbacks :initialize do
|
97
|
-
object_attributes_set
|
98
|
-
object_after_callback
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
private
|
103
|
-
|
104
|
-
def arg_value(arg_name)
|
105
|
-
arg_index = common_constructor.args.index(arg_name)
|
106
|
-
if arg_index < args.count
|
107
|
-
args[arg_index]
|
108
|
-
else
|
109
|
-
common_constructor.default_values[arg_index - common_constructor.args_count_min]
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
def object_after_callback
|
114
|
-
return unless common_constructor.after_set_block
|
115
|
-
|
116
|
-
object.instance_eval(&common_constructor.after_set_block)
|
117
|
-
end
|
118
|
-
|
119
|
-
def object_attributes_set
|
120
|
-
common_constructor.args.each do |arg_name|
|
121
|
-
object.send("#{arg_name}=", arg_value(arg_name))
|
122
|
-
end
|
123
|
-
end
|
124
|
-
|
125
|
-
def validate_args_count
|
126
|
-
return if common_constructor.args_count.include?(args.count)
|
127
|
-
|
128
|
-
raise ArgumentError, "#{object.class}.initialize: wrong number of arguments" \
|
129
|
-
" (given #{args.count}, expected #{common_constructor.args_count})"
|
130
|
-
end
|
85
|
+
def super_args
|
86
|
+
options[:super_args]
|
131
87
|
end
|
132
88
|
end
|
133
89
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/common_constructor/instance_initialize'
|
4
|
+
require 'eac_ruby_utils/common_constructor/super_args'
|
5
|
+
|
6
|
+
module EacRubyUtils
|
7
|
+
class CommonConstructor
|
8
|
+
class ClassInitialize
|
9
|
+
attr_reader :common_constructor, :klass
|
10
|
+
|
11
|
+
def initialize(common_constructor, klass)
|
12
|
+
@common_constructor = common_constructor
|
13
|
+
@klass = klass
|
14
|
+
end
|
15
|
+
|
16
|
+
def run
|
17
|
+
class_initialize = self
|
18
|
+
klass.send(:define_method, :initialize) do |*args|
|
19
|
+
::EacRubyUtils::CommonConstructor::InstanceInitialize.new(
|
20
|
+
class_initialize.common_constructor, args, self
|
21
|
+
).run
|
22
|
+
super(*::EacRubyUtils::CommonConstructor::SuperArgs.new(
|
23
|
+
class_initialize, args, self
|
24
|
+
).result)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module EacRubyUtils
|
4
|
+
class CommonConstructor
|
5
|
+
class InstanceInitialize
|
6
|
+
attr_reader :common_constructor, :args, :object
|
7
|
+
|
8
|
+
def initialize(common_constructor, args, object)
|
9
|
+
@common_constructor = common_constructor
|
10
|
+
@args = args
|
11
|
+
@object = object
|
12
|
+
end
|
13
|
+
|
14
|
+
def run
|
15
|
+
validate_args_count
|
16
|
+
object.run_callbacks :initialize do
|
17
|
+
object_attributes_set
|
18
|
+
object_after_callback
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def arg_value(arg_name)
|
25
|
+
arg_index = common_constructor.args.index(arg_name)
|
26
|
+
if arg_index < args.count
|
27
|
+
args[arg_index]
|
28
|
+
else
|
29
|
+
common_constructor.default_values[arg_index - common_constructor.args_count_min]
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def object_after_callback
|
34
|
+
return unless common_constructor.after_set_block
|
35
|
+
|
36
|
+
object.instance_eval(&common_constructor.after_set_block)
|
37
|
+
end
|
38
|
+
|
39
|
+
def object_attributes_set
|
40
|
+
common_constructor.args.each do |arg_name|
|
41
|
+
object.send("#{arg_name}=", arg_value(arg_name))
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def validate_args_count
|
46
|
+
return if common_constructor.args_count.include?(args.count)
|
47
|
+
|
48
|
+
raise ArgumentError, "#{object.class}.initialize: wrong number of arguments" \
|
49
|
+
" (given #{args.count}, expected #{common_constructor.args_count})"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'active_support/core_ext/module/delegation'
|
4
|
+
|
5
|
+
module EacRubyUtils
|
6
|
+
class CommonConstructor
|
7
|
+
class SuperArgs
|
8
|
+
attr_reader :class_initialize, :args, :object
|
9
|
+
delegate :common_constructor, to: :class_initialize
|
10
|
+
|
11
|
+
def initialize(class_initialize, args, object)
|
12
|
+
@class_initialize = class_initialize
|
13
|
+
@args = args
|
14
|
+
@object = object
|
15
|
+
end
|
16
|
+
|
17
|
+
def auto_result
|
18
|
+
r = []
|
19
|
+
sub_args.each do |name, value|
|
20
|
+
i = super_arg_index(name)
|
21
|
+
r[i] = value if i
|
22
|
+
end
|
23
|
+
r
|
24
|
+
end
|
25
|
+
|
26
|
+
def result
|
27
|
+
result_from_options || auto_result
|
28
|
+
end
|
29
|
+
|
30
|
+
def result_from_options
|
31
|
+
return unless common_constructor.super_args
|
32
|
+
|
33
|
+
object.instance_exec(&common_constructor.super_args)
|
34
|
+
end
|
35
|
+
|
36
|
+
def sub_args
|
37
|
+
common_constructor.args.each_with_index.map do |name, index|
|
38
|
+
[name, args[index]]
|
39
|
+
end.to_h
|
40
|
+
end
|
41
|
+
|
42
|
+
def super_arg_index(name)
|
43
|
+
super_method.parameters.each_with_index do |arg, index|
|
44
|
+
return index if arg[1] == name
|
45
|
+
end
|
46
|
+
nil
|
47
|
+
end
|
48
|
+
|
49
|
+
def super_method
|
50
|
+
class_initialize.klass.superclass&.instance_method(:initialize)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -38,7 +38,7 @@ module EacRubyUtils
|
|
38
38
|
def run_with_subcommand
|
39
39
|
if subcommand_name
|
40
40
|
check_valid_subcommand
|
41
|
-
|
41
|
+
subcommand_run
|
42
42
|
else
|
43
43
|
run_without_subcommand
|
44
44
|
end
|
@@ -52,6 +52,15 @@ module EacRubyUtils
|
|
52
52
|
)
|
53
53
|
end
|
54
54
|
|
55
|
+
def subcommand_run
|
56
|
+
if !subcommand.is_a?(::EacRubyUtils::Console::DocoptRunner) &&
|
57
|
+
subcommand.respond_to?(:run_run)
|
58
|
+
subcommand.run_run
|
59
|
+
else
|
60
|
+
subcommand.run
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
55
64
|
def target_doc
|
56
65
|
super.gsub(SUBCOMMANDS_MACRO,
|
57
66
|
"#{target_doc_subcommand_arg} [#{SUBCOMMAND_ARGS_ARG}...]") +
|
@@ -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
|