ehbrs-tools 0.16.3 → 0.19.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/runner/videos/unsupported.rb +1 -1
- 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/check_support.rb +1 -1
- 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/lib/ehbrs/videos/unsupported/profiles/aoc.rb +27 -0
- 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/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/alternative.rb +4 -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_with/help.rb +3 -1
- 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 +22 -1
- data/vendor/eac_cli/spec/lib/eac_cli/runner_with/subcommands_spec.rb +29 -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/module_setup.rb +16 -6
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_constructor.rb +2 -99
- 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/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/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 +14 -4
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/common_constructor_spec.rb +30 -0
- 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/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 +89 -9
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/time/local_time_zone.rb +0 -25
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_cli/core_ext'
|
4
|
+
require 'eac_ruby_gems_utils/tests/multiple'
|
5
|
+
|
6
|
+
module EacRubyBase0
|
7
|
+
module Runner
|
8
|
+
class TestAll
|
9
|
+
runner_with :help do
|
10
|
+
desc 'Test core and local gems.'
|
11
|
+
end
|
12
|
+
|
13
|
+
def run
|
14
|
+
fatal_error 'Some test did not pass' unless tests.ok?
|
15
|
+
end
|
16
|
+
|
17
|
+
def tests_uncached
|
18
|
+
::EacRubyGemsUtils::Tests::Multiple.new(runner_context.call(:application).all_gems)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,100 @@
|
|
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
|
@@ -17,15 +17,25 @@ module EacRubyUtils
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def run
|
20
|
-
setup = self
|
21
20
|
a_module.extend(::ActiveSupport::Concern)
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
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
|
27
31
|
end
|
28
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
|
29
39
|
end
|
30
40
|
end
|
31
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
|
@@ -76,111 +77,13 @@ module EacRubyUtils
|
|
76
77
|
end
|
77
78
|
|
78
79
|
def setup_class_initialize(klass)
|
79
|
-
common_constructor = self
|
80
80
|
klass.include(::ActiveSupport::Callbacks)
|
81
81
|
klass.define_callbacks :initialize
|
82
|
-
|
83
|
-
Initialize.new(common_constructor, args, self).run
|
84
|
-
super(*SuperArgs.new(common_constructor, args, self).result)
|
85
|
-
end
|
82
|
+
::EacRubyUtils::CommonConstructor::ClassInitialize.new(self, klass).run
|
86
83
|
end
|
87
84
|
|
88
85
|
def super_args
|
89
86
|
options[:super_args]
|
90
87
|
end
|
91
|
-
|
92
|
-
class Initialize
|
93
|
-
attr_reader :common_constructor, :args, :object
|
94
|
-
|
95
|
-
def initialize(common_constructor, args, object)
|
96
|
-
@common_constructor = common_constructor
|
97
|
-
@args = args
|
98
|
-
@object = object
|
99
|
-
end
|
100
|
-
|
101
|
-
def run
|
102
|
-
validate_args_count
|
103
|
-
object.run_callbacks :initialize do
|
104
|
-
object_attributes_set
|
105
|
-
object_after_callback
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
private
|
110
|
-
|
111
|
-
def arg_value(arg_name)
|
112
|
-
arg_index = common_constructor.args.index(arg_name)
|
113
|
-
if arg_index < args.count
|
114
|
-
args[arg_index]
|
115
|
-
else
|
116
|
-
common_constructor.default_values[arg_index - common_constructor.args_count_min]
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
def object_after_callback
|
121
|
-
return unless common_constructor.after_set_block
|
122
|
-
|
123
|
-
object.instance_eval(&common_constructor.after_set_block)
|
124
|
-
end
|
125
|
-
|
126
|
-
def object_attributes_set
|
127
|
-
common_constructor.args.each do |arg_name|
|
128
|
-
object.send("#{arg_name}=", arg_value(arg_name))
|
129
|
-
end
|
130
|
-
end
|
131
|
-
|
132
|
-
def validate_args_count
|
133
|
-
return if common_constructor.args_count.include?(args.count)
|
134
|
-
|
135
|
-
raise ArgumentError, "#{object.class}.initialize: wrong number of arguments" \
|
136
|
-
" (given #{args.count}, expected #{common_constructor.args_count})"
|
137
|
-
end
|
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
|
185
88
|
end
|
186
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}...]") +
|