avm-tools 0.77.0 → 0.82.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/lib/avm/data/unit.rb +8 -3
  3. data/lib/avm/eac_rails_base1/runner/code_runner.rb +1 -2
  4. data/lib/avm/eac_rails_base1/runner/rails_server.rb +33 -0
  5. data/lib/avm/eac_redmine_base0/data_unit.rb +29 -1
  6. data/lib/avm/patches/class/i18n.rb +31 -0
  7. data/lib/avm/patches/object/i18n.rb +2 -10
  8. data/lib/avm/projects/stereotypes/ruby_gem/update.rb +4 -1
  9. data/lib/avm/projects/stereotypes/ruby_gem/version_bump.rb +1 -2
  10. data/lib/avm/tools/runner/git/subrepo/clone.rb +84 -0
  11. data/lib/avm/tools/runner/git/subrepo/fix.rb +65 -0
  12. data/lib/avm/tools/version.rb +1 -1
  13. data/vendor/eac_cli/eac_cli.gemspec +1 -1
  14. data/vendor/eac_cli/lib/eac_cli/parser.rb +6 -4
  15. data/vendor/eac_cli/lib/eac_cli/parser/alternative.rb +4 -0
  16. data/vendor/eac_cli/lib/eac_cli/runner.rb +10 -2
  17. data/vendor/eac_cli/lib/eac_cli/runner/exit.rb +13 -0
  18. data/vendor/eac_cli/lib/eac_cli/runner_with/help.rb +15 -0
  19. data/vendor/eac_cli/lib/eac_cli/runner_with/output_file.rb +5 -1
  20. data/vendor/eac_cli/lib/eac_cli/runner_with/subcommands.rb +1 -1
  21. data/vendor/eac_cli/lib/eac_cli/version.rb +1 -1
  22. data/vendor/eac_cli/spec/lib/eac_cli/runner_spec.rb +6 -3
  23. data/vendor/eac_cli/spec/lib/eac_cli/runner_with/help_spec.rb +42 -0
  24. data/vendor/eac_cli/spec/lib/eac_cli/runner_with/output_file_spec.rb +53 -0
  25. data/vendor/eac_cli/spec/lib/eac_cli/runner_with/subcommands_spec.rb +0 -1
  26. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/abstract_methods.rb +5 -4
  27. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_concern.rb +2 -50
  28. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_concern/class_setup.rb +52 -0
  29. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_concern/module_setup.rb +31 -0
  30. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_constructor.rb +53 -0
  31. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/command.rb +4 -6
  32. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/command/concat.rb +33 -0
  33. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/command/envvars.rb +24 -0
  34. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/command/extra_options.rb +0 -21
  35. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/module/abstract_methods.rb +10 -0
  36. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/struct.rb +7 -1
  37. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/version.rb +1 -1
  38. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/common_concern_spec.rb +30 -17
  39. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/common_constructor_spec.rb +66 -8
  40. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/struct_spec.rb +12 -1
  41. metadata +14 -4
  42. data/lib/avm/tools/runner/eac_rails_base0/rails_server.rb +0 -36
  43. data/lib/avm/tools/runner/eac_rails_base0/runner.rb +0 -14
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EacCli
4
+ module Runner
5
+ class Exit < ::StandardError
6
+ attr_reader :status
7
+
8
+ def initialize(status = true)
9
+ @status = status
10
+ end
11
+ end
12
+ end
13
+ end
@@ -13,6 +13,21 @@ module EacCli
13
13
  options_argument false
14
14
  bool_opt '-h', '--help', 'Show help.', usage: true
15
15
  end
16
+
17
+ set_callback :run, :before do
18
+ help_run
19
+ end
20
+ end
21
+
22
+ def help_run
23
+ return unless parsed.help?
24
+
25
+ puts help_text
26
+ raise ::EacCli::Runner::Exit
27
+ end
28
+
29
+ def help_text
30
+ ::EacCli::Docopt::DocBuilder.new(self.class.runner_definition).to_s
16
31
  end
17
32
  end
18
33
  end
@@ -2,12 +2,16 @@
2
2
 
3
3
  require 'eac_cli/runner'
4
4
  require 'eac_ruby_utils/core_ext'
5
+ require 'eac_ruby_utils/abstract_methods'
5
6
 
6
7
  module EacCli
7
8
  module RunnerWith
8
9
  module OutputFile
9
10
  common_concern do
10
11
  include ::EacCli::Runner
12
+ include ::EacRubyUtils::AbstractMethods
13
+
14
+ abstract_methods :output_content
11
15
 
12
16
  runner_definition do
13
17
  arg_opt '-o', '--output-file', 'Output to file.'
@@ -18,7 +22,7 @@ module EacCli
18
22
  if parsed.output_file.present?
19
23
  ::File.write(parsed.output_file, output_content)
20
24
  else
21
- out output_content
25
+ $stdout.write(output_content)
22
26
  end
23
27
  end
24
28
  end
@@ -44,7 +44,7 @@ module EacCli
44
44
 
45
45
  def run_with_subcommand
46
46
  if subcommand_name
47
- subcommand_runner.run
47
+ subcommand_runner.run_run
48
48
  else
49
49
  run_without_subcommand
50
50
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacCli
4
- VERSION = '0.12.1'
4
+ VERSION = '0.12.3'
5
5
  end
@@ -28,7 +28,10 @@ RSpec.describe ::EacCli::Runner do
28
28
 
29
29
  context 'when all args are supplied' do
30
30
  let(:argv) { %w[--opt1 aaa --opt2 bbb ccc ddd] }
31
- let(:parsed_expected) { { opt1: 'aaa', opt2: true, pos1: 'bbb', pos2: %w[ccc ddd] } }
31
+ let(:parsed_expected) do
32
+ { opt1: 'aaa', opt2: true, opt3: false, pos1: 'bbb',
33
+ pos2: %w[ccc ddd] }
34
+ end
32
35
 
33
36
  it { expect(parsed_actual).to eq(parsed_expected) }
34
37
  it { expect(instance.parsed.opt1).to eq('aaa') }
@@ -39,7 +42,7 @@ RSpec.describe ::EacCli::Runner do
39
42
 
40
43
  context 'when only required args are supplied' do
41
44
  let(:argv) { %w[bbb] }
42
- let(:parsed_expected) { { opt1: nil, opt2: false, pos1: 'bbb', pos2: [] } }
45
+ let(:parsed_expected) { { opt1: nil, opt2: false, opt3: false, pos1: 'bbb', pos2: [] } }
43
46
 
44
47
  it { expect(parsed_actual).to eq(parsed_expected) }
45
48
  it { expect(instance.parsed.opt1).to be_nil }
@@ -58,7 +61,7 @@ RSpec.describe ::EacCli::Runner do
58
61
 
59
62
  context 'when alternative args are supplied' do
60
63
  let(:argv) { %w[--opt3] }
61
- let(:parsed_expected) { { opt3: true } }
64
+ let(:parsed_expected) { { opt1: nil, opt2: false, opt3: true, pos1: nil, pos2: [] } }
62
65
 
63
66
  it { expect(parsed_actual).to eq(parsed_expected) }
64
67
  it { expect(instance.parsed.opt3?).to eq(true) }
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_cli/runner_with/help'
4
+ require 'eac_ruby_utils/fs/temp'
5
+
6
+ RSpec.describe ::EacCli::RunnerWith::Help do
7
+ let(:runner) do
8
+ the_module = described_class
9
+ Class.new do
10
+ include the_module
11
+
12
+ runner_definition do
13
+ desc 'A stub runner.'
14
+ pos_arg :a_argument
15
+ end
16
+
17
+ def run
18
+ puts 'Runner run'
19
+ end
20
+ end
21
+ end
22
+
23
+ let(:runner_argv) { ['--help'] }
24
+ let(:instance) { runner.create(argv: runner_argv) }
25
+ let(:expected_output) do
26
+ <<~OUTPUT
27
+ A stub runner.
28
+
29
+ Usage:
30
+ __PROGRAM__ [options] <a_argument>
31
+ __PROGRAM__ --help
32
+
33
+ Options:
34
+ -h --help Show help.
35
+
36
+ OUTPUT
37
+ end
38
+
39
+ it 'show help text' do
40
+ expect { instance.run_run }.to output(expected_output).to_stdout_from_any_process
41
+ end
42
+ end
@@ -0,0 +1,53 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_cli/runner_with/output_file'
4
+ require 'eac_ruby_utils/fs/temp'
5
+
6
+ RSpec.describe ::EacCli::RunnerWith::OutputFile do
7
+ let(:runner) do
8
+ the_module = described_class
9
+ Class.new do
10
+ include the_module
11
+
12
+ runner_definition do
13
+ desc 'A stub root runner.'
14
+ pos_arg :input_text
15
+ end
16
+
17
+ def run
18
+ run_output
19
+ end
20
+
21
+ def output_content
22
+ parsed.input_text
23
+ end
24
+ end
25
+ end
26
+
27
+ let(:stub_text) { 'STUB_TEXT' }
28
+ let(:instance) { runner.create(argv: runner_argv) }
29
+
30
+ context 'without --output-file option' do
31
+ let(:runner_argv) { [stub_text] }
32
+
33
+ it do
34
+ expect { instance.run }.to output(stub_text).to_stdout_from_any_process
35
+ end
36
+ end
37
+
38
+ context 'with --output-file option' do
39
+ let(:output_file) { ::EacRubyUtils::Fs::Temp.file }
40
+ let(:runner_argv) { ['--output-file', output_file.to_path, stub_text] }
41
+
42
+ before do
43
+ instance.run
44
+ end
45
+
46
+ after do
47
+ output_file.remove
48
+ end
49
+
50
+ it { expect(output_file).to exist }
51
+ it { expect(output_file.read).to eq(stub_text) }
52
+ end
53
+ end
@@ -8,7 +8,6 @@ RSpec.describe ::EacCli::RunnerWith::Subcommands do
8
8
  the_module = described_class
9
9
  the_child = child_runner
10
10
  Class.new do
11
- include ::EacCli::Runner
12
11
  include the_module
13
12
  const_set('ChildCmd', the_child)
14
13
 
@@ -29,10 +29,11 @@ module EacRubyUtils
29
29
 
30
30
  module ClassMethods
31
31
  def abstract_methods(*methods_names)
32
- @abstract_methods ||= Set.new
33
- @abstract_methods += methods_names.map(&:to_sym)
34
-
35
- @abstract_methods.to_enum
32
+ methods_names.each do |method_name|
33
+ define_method method_name do
34
+ raise_abstract_method(method_name)
35
+ end
36
+ end
36
37
  end
37
38
  end
38
39
 
@@ -1,8 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'active_support/concern'
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
- Setup.new(self, a_module).run
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,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