avm-tools 0.79.0 → 0.83.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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_base0/apache_host.rb +2 -9
  4. data/lib/avm/eac_rails_base1/apache_host.rb +17 -0
  5. data/lib/avm/eac_rails_base1/runner/code_runner.rb +1 -2
  6. data/lib/avm/eac_rails_base1/runner/rails_server.rb +33 -0
  7. data/lib/avm/eac_redmine_base0/apache_host.rb +10 -0
  8. data/lib/avm/eac_redmine_base0/data_unit.rb +29 -1
  9. data/lib/avm/eac_writings_base1.rb +9 -0
  10. data/lib/avm/eac_writings_base1/build.rb +45 -0
  11. data/lib/avm/eac_writings_base1/build/file.rb +28 -0
  12. data/lib/avm/eac_writings_base1/project.rb +13 -0
  13. data/lib/avm/executables.rb +1 -1
  14. data/lib/avm/tools/runner/git/subrepo/fix.rb +65 -0
  15. data/lib/avm/tools/runner/local_project/eac_writings_base1.rb +32 -0
  16. data/lib/avm/tools/runner/local_project/eac_writings_base1/build.rb +48 -0
  17. data/lib/avm/tools/version.rb +1 -1
  18. data/vendor/eac_cli/eac_cli.gemspec +1 -1
  19. data/vendor/eac_cli/lib/eac_cli/parser.rb +6 -4
  20. data/vendor/eac_cli/lib/eac_cli/parser/alternative.rb +4 -0
  21. data/vendor/eac_cli/lib/eac_cli/runner.rb +10 -2
  22. data/vendor/eac_cli/lib/eac_cli/runner/exit.rb +13 -0
  23. data/vendor/eac_cli/lib/eac_cli/runner_with/help.rb +17 -0
  24. data/vendor/eac_cli/lib/eac_cli/runner_with/subcommands.rb +6 -1
  25. data/vendor/eac_cli/lib/eac_cli/version.rb +1 -1
  26. data/vendor/eac_cli/spec/lib/eac_cli/runner_spec.rb +6 -3
  27. data/vendor/eac_cli/spec/lib/eac_cli/runner_with/help_spec.rb +42 -0
  28. data/vendor/eac_cli/spec/lib/eac_cli/runner_with/subcommands_spec.rb +29 -1
  29. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_concern.rb +2 -50
  30. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_concern/class_setup.rb +52 -0
  31. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_concern/module_setup.rb +31 -0
  32. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/command.rb +4 -6
  33. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/command/concat.rb +33 -0
  34. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/command/envvars.rb +24 -0
  35. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/command/extra_options.rb +0 -21
  36. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/pathname/basename_sub.rb +2 -2
  37. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/struct.rb +7 -1
  38. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/version.rb +1 -1
  39. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/common_concern_spec.rb +30 -17
  40. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/struct_spec.rb +12 -1
  41. metadata +18 -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
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Avm
4
4
  module Tools
5
- VERSION = '0.79.0'
5
+ VERSION = '0.83.0'
6
6
  end
7
7
  end
@@ -12,7 +12,7 @@ Gem::Specification.new do |s|
12
12
 
13
13
  s.files = Dir['{lib}/**/*', 'Gemfile']
14
14
 
15
- s.add_dependency 'eac_ruby_utils', '~> 0.50'
15
+ s.add_dependency 'eac_ruby_utils', '~> 0.55'
16
16
 
17
17
  s.add_development_dependency 'eac_ruby_gem_support', '~> 0.1', '>= 0.1.2'
18
18
  end
@@ -12,12 +12,14 @@ module EacCli
12
12
 
13
13
  def parsed_uncached
14
14
  raise 'Definition has no alternatives' if alternatives.empty?
15
+ raise first_error unless alternatives.select(&:success?).any?
15
16
 
16
- alternatives.each do |alt_parser|
17
- return alt_parser.parsed unless alt_parser.error?
18
- end
17
+ alternatives_parsed(true).merge(alternatives_parsed(false))
18
+ end
19
19
 
20
- raise first_error
20
+ def alternatives_parsed(error)
21
+ alternatives.select { |a| error == a.error? }.map(&:parsed).reverse
22
+ .inject(::EacRubyUtils::Struct.new) { |a, e| a.merge(e) }
21
23
  end
22
24
 
23
25
  def alternatives_uncached
@@ -22,6 +22,10 @@ module EacCli
22
22
  error.present?
23
23
  end
24
24
 
25
+ def success?
26
+ !error?
27
+ end
28
+
25
29
  def parsed
26
30
  @parsed ||= collector.to_data.freeze
27
31
  end
@@ -44,6 +44,8 @@ module EacCli
44
44
  extend AfterClassMethods
45
45
  include InstanceMethods
46
46
  ::EacCli::Docopt::RunnerExtension.check(self)
47
+ include ActiveSupport::Callbacks
48
+ define_callbacks :run
47
49
  end
48
50
 
49
51
  module AfterClassMethods
@@ -55,8 +57,7 @@ module EacCli
55
57
 
56
58
  def run(*runner_context_args)
57
59
  r = create(*runner_context_args)
58
- r.parsed
59
- r.run
60
+ r.run_run
60
61
  r
61
62
  end
62
63
 
@@ -72,6 +73,13 @@ module EacCli
72
73
  end
73
74
 
74
75
  module InstanceMethods
76
+ def run_run
77
+ parsed
78
+ run_callbacks(:run) { run }
79
+ rescue ::EacCli::Runner::Exit # rubocop:disable Lint/SuppressedException
80
+ # Do nothing
81
+ end
82
+
75
83
  def runner_context
76
84
  return @runner_context if @runner_context
77
85
 
@@ -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,23 @@ 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
+ r = ::EacCli::Docopt::DocBuilder.new(self.class.runner_definition).to_s
31
+ r += help_extra_text if respond_to?(:help_extra_text)
32
+ r
16
33
  end
17
34
  end
18
35
  end
@@ -31,6 +31,11 @@ module EacCli
31
31
  end
32
32
  end
33
33
 
34
+ def help_extra_text
35
+ (['Subcommands:'] + available_subcommands.keys.map { |s| " #{s}" })
36
+ .map { |v| "#{v}\n" }.join
37
+ end
38
+
34
39
  def method_missing(method_name, *arguments, &block)
35
40
  return run_with_subcommand(*arguments, &block) if
36
41
  run_with_subcommand_alias_run?(method_name)
@@ -44,7 +49,7 @@ module EacCli
44
49
 
45
50
  def run_with_subcommand
46
51
  if subcommand_name
47
- subcommand_runner.run
52
+ subcommand_runner.run_run
48
53
  else
49
54
  run_without_subcommand
50
55
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacCli
4
- VERSION = '0.12.2'
4
+ VERSION = '0.12.4'
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
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'eac_cli/runner'
4
+ require 'eac_cli/runner_with/help'
4
5
  require 'eac_cli/runner_with/subcommands'
5
6
 
6
7
  RSpec.describe ::EacCli::RunnerWith::Subcommands do
@@ -8,7 +9,6 @@ RSpec.describe ::EacCli::RunnerWith::Subcommands do
8
9
  the_module = described_class
9
10
  the_child = child_runner
10
11
  Class.new do
11
- include ::EacCli::Runner
12
12
  include the_module
13
13
  const_set('ChildCmd', the_child)
14
14
 
@@ -54,4 +54,32 @@ RSpec.describe ::EacCli::RunnerWith::Subcommands do
54
54
  expect { instance.run }.to raise_error(::EacCli::Parser::Error)
55
55
  end
56
56
  end
57
+
58
+ context 'with help' do
59
+ let(:instance) { parent_runner.create(%w[--help]) }
60
+ let(:expected_output) do
61
+ <<~OUTPUT
62
+ A stub root runner.
63
+
64
+ Usage:
65
+ __PROGRAM__ [options] __SUBCOMMANDS__ [<subcommand_args>...]
66
+ __PROGRAM__ --help
67
+
68
+ Options:
69
+ -r --root-var=<value> A root variable.
70
+ -h --help Show help.
71
+
72
+ Subcommands:
73
+ child-cmd
74
+ OUTPUT
75
+ end
76
+
77
+ before do
78
+ parent_runner.include(::EacCli::RunnerWith::Help)
79
+ end
80
+
81
+ it 'show help text' do
82
+ expect { instance.run_run }.to output(expected_output).to_stdout_from_any_process
83
+ end
84
+ end
57
85
  end
@@ -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
@@ -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
  )