avm-tools 0.93.0 → 0.95.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (124) hide show
  1. checksums.yaml +4 -4
  2. data/lib/avm/eac_webapp_base0/instance.rb +5 -2
  3. data/lib/avm/eac_webapp_base0/instance/subcommand_parent.rb +24 -0
  4. data/lib/avm/eac_webapp_base0/runner/data.rb +1 -0
  5. data/lib/avm/eac_webapp_base0/runner/data/dump.rb +1 -1
  6. data/lib/avm/eac_webapp_base0/runner/data/load.rb +1 -1
  7. data/lib/avm/git/auto_commit/commit_info.rb +2 -1
  8. data/lib/avm/git/auto_commit/rules.rb +4 -4
  9. data/lib/avm/git/auto_commit/rules/new.rb +24 -0
  10. data/lib/avm/git/auto_commit/rules/nth.rb +8 -0
  11. data/lib/avm/git/auto_commit_path.rb +0 -21
  12. data/lib/avm/git/file_auto_fixup.rb +19 -3
  13. data/lib/avm/ruby/bundler.rb +11 -0
  14. data/lib/avm/ruby/bundler/incompatible_parser.rb +25 -0
  15. data/lib/avm/ruby/bundler/incompatible_parser/depends_on.rb +25 -0
  16. data/lib/avm/ruby/bundler/incompatible_parser/gem_conflict.rb +39 -0
  17. data/lib/avm/ruby/bundler/incompatible_parser/in_gemfile.rb +19 -0
  18. data/lib/avm/ruby/bundler/incompatible_parser/line_buffer.rb +73 -0
  19. data/lib/avm/ruby/bundler/incompatible_parser/line_factory.rb +31 -0
  20. data/lib/avm/ruby/bundler/incompatible_parser/line_parser_base.rb +19 -0
  21. data/lib/avm/ruby/bundler/incompatible_parser/version_requirement.rb +26 -0
  22. data/lib/avm/ruby/gems/generator.rb +1 -5
  23. data/lib/avm/tools/runner/eac_redmine_base0/core_update.rb +7 -11
  24. data/lib/avm/tools/runner/git/auto_commit.rb +28 -28
  25. data/lib/avm/tools/runner/git/subrepo/fix.rb +1 -1
  26. data/lib/avm/tools/runner/local_project/ruby.rb +2 -6
  27. data/lib/avm/tools/runner/local_project/ruby/bundler.rb +3 -7
  28. data/lib/avm/tools/runner/local_project/ruby/bundler/gemfile_lock.rb +10 -13
  29. data/lib/avm/tools/runner/local_project/ruby/bundler/incompatible.rb +84 -0
  30. data/lib/avm/tools/version.rb +1 -1
  31. data/template/avm/ruby/gems/generator/static/spec/rubocop_spec.rb +1 -5
  32. data/template/avm/ruby/gems/generator/static/spec/spec_helper.rb +2 -0
  33. data/vendor/avm-apps/avm-apps.gemspec +1 -1
  34. data/vendor/avm-apps/lib/avm/apps/version.rb +1 -1
  35. data/vendor/avm-apps/spec/rubocop_spec.rb +1 -5
  36. data/vendor/avm-apps/spec/spec_helper.rb +3 -0
  37. data/vendor/eac_cli/eac_cli.gemspec +1 -1
  38. data/vendor/eac_cli/lib/eac_cli/core_ext.rb +2 -0
  39. data/vendor/eac_cli/lib/eac_cli/definition/base_option.rb +5 -1
  40. data/vendor/eac_cli/lib/eac_cli/docopt/doc_builder.rb +3 -1
  41. data/vendor/eac_cli/lib/eac_cli/parser/alternative/short_options.rb +4 -2
  42. data/vendor/eac_cli/lib/eac_cli/patches/object/runner_with.rb +2 -1
  43. data/vendor/eac_cli/lib/eac_cli/runner/context.rb +2 -1
  44. data/vendor/eac_cli/lib/eac_cli/runner/instance_methods.rb +8 -1
  45. data/vendor/eac_cli/lib/eac_cli/runner_with_set.rb +50 -0
  46. data/vendor/eac_cli/lib/eac_cli/version.rb +1 -1
  47. data/vendor/eac_cli/spec/rubocop_spec.rb +1 -5
  48. data/vendor/eac_cli/spec/spec_helper.rb +3 -0
  49. data/vendor/eac_docker/eac_docker.gemspec +1 -1
  50. data/vendor/eac_docker/lib/eac_docker/version.rb +1 -1
  51. data/vendor/eac_docker/spec/rubocop_spec.rb +1 -5
  52. data/vendor/eac_docker/spec/spec_helper.rb +3 -0
  53. data/vendor/eac_git/eac_git.gemspec +2 -1
  54. data/vendor/eac_git/lib/eac_git/local.rb +4 -0
  55. data/vendor/eac_git/lib/eac_git/local/commit.rb +53 -0
  56. data/vendor/eac_git/lib/eac_git/local/commit/changed_file.rb +46 -0
  57. data/vendor/eac_git/lib/eac_git/local/commit/diff_tree_line.rb +32 -0
  58. data/vendor/eac_git/lib/eac_git/local/dirty_files.rb +2 -3
  59. data/vendor/eac_git/lib/eac_git/rspec.rb +6 -1
  60. data/{lib/avm/git/spec_helper.rb → vendor/eac_git/lib/eac_git/rspec/stubbed_git_local_repo.rb} +16 -13
  61. data/vendor/eac_git/lib/eac_git/version.rb +1 -1
  62. data/vendor/eac_git/spec/lib/eac_git/local/commit/diff_tree_line_spec.rb +13 -0
  63. data/vendor/eac_git/spec/lib/eac_git/local/commit/diff_tree_line_spec_files/add.source.out +1 -0
  64. data/vendor/eac_git/spec/lib/eac_git/local/commit/diff_tree_line_spec_files/add.target.yaml +7 -0
  65. data/vendor/eac_git/spec/lib/eac_git/local/commit/diff_tree_line_spec_files/modify.source.out +1 -0
  66. data/vendor/eac_git/spec/lib/eac_git/local/commit/diff_tree_line_spec_files/modify.target.yaml +7 -0
  67. data/vendor/eac_git/spec/lib/eac_git/local/commit/diff_tree_line_spec_files/remove.source.out +1 -0
  68. data/vendor/eac_git/spec/lib/eac_git/local/commit/diff_tree_line_spec_files/remove.target.yaml +7 -0
  69. data/vendor/eac_git/spec/lib/eac_git/local/commit/diff_tree_line_spec_files/rename.source.out +2 -0
  70. data/vendor/eac_git/spec/lib/eac_git/local/commit/diff_tree_line_spec_files/rename.target.yaml +13 -0
  71. data/vendor/eac_git/spec/lib/eac_git/local/commit/diff_tree_line_spec_files/rename_modify.source.out +2 -0
  72. data/vendor/eac_git/spec/lib/eac_git/local/commit/diff_tree_line_spec_files/rename_modify.target.yaml +13 -0
  73. data/vendor/eac_git/spec/lib/eac_git/local/commit_spec.rb +58 -0
  74. data/vendor/eac_git/spec/rubocop_spec.rb +1 -5
  75. data/vendor/eac_git/spec/spec_helper.rb +3 -0
  76. data/vendor/eac_ruby_base0/eac_ruby_base0.gemspec +4 -4
  77. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/core_ext.rb +4 -0
  78. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/jobs_runner.rb +31 -0
  79. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/patches.rb +4 -0
  80. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/patches/class.rb +4 -0
  81. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/patches/class/jobs_runner.rb +10 -0
  82. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/patches/object.rb +5 -0
  83. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/patches/object/runner_with.rb +5 -0
  84. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/runner_with.rb +9 -0
  85. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/runner_with/confirmation.rb +36 -0
  86. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/runner_with/filesystem_traverser.rb +52 -0
  87. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/runner_with/input.rb +36 -0
  88. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/runner_with/output.rb +58 -0
  89. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/version.rb +1 -1
  90. data/vendor/eac_ruby_base0/spec/lib/eac_ruby_base0/runner_with/confirmation_spec.rb +42 -0
  91. data/vendor/eac_ruby_base0/spec/lib/eac_ruby_base0/runner_with/output_spec.rb +81 -0
  92. data/vendor/eac_ruby_base0/spec/rubocop_spec.rb +1 -5
  93. data/vendor/eac_ruby_base0/spec/spec_helper.rb +3 -0
  94. data/vendor/eac_ruby_gems_utils/eac_ruby_gems_utils.gemspec +1 -1
  95. data/vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/tests/base.rb +7 -10
  96. data/vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/tests/multiple.rb +9 -2
  97. data/vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/version.rb +1 -1
  98. data/vendor/eac_ruby_gems_utils/spec/code/rubocop_check_spec.rb +1 -5
  99. data/vendor/eac_ruby_gems_utils/spec/spec_helper.rb +3 -0
  100. data/vendor/eac_ruby_utils/eac_ruby_utils.gemspec +2 -1
  101. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/filesystem_cache.rb +6 -0
  102. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/fs/logs.rb +63 -0
  103. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/inflector.rb +9 -1
  104. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/listable/list.rb +3 -2
  105. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/local_time_zone.rb +8 -2
  106. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/class/settings_provider.rb +10 -0
  107. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/kernel/nyi.rb +4 -2
  108. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/object/if_nil.rb +17 -0
  109. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/regexp/to_parser.rb +10 -0
  110. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/string/inflector.rb +4 -2
  111. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/time/required_zone.rb +11 -0
  112. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/regexp_parser.rb +34 -0
  113. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/settings_provider.rb +10 -29
  114. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/settings_provider/setting_value.rb +69 -0
  115. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/simple_cache.rb +18 -5
  116. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/version.rb +1 -1
  117. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/settings_provider_spec.rb +8 -0
  118. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/simple_cache_spec.rb +9 -0
  119. data/vendor/eac_ruby_utils/spec/rubocop_check_spec.rb +1 -5
  120. data/vendor/eac_ruby_utils/spec/spec_helper.rb +3 -0
  121. metadata +55 -15
  122. data/lib/avm/tools/runner/git/auto_fixup.rb +0 -53
  123. data/vendor/eac_cli/lib/eac_cli/runner_with/output_file.rb +0 -30
  124. data/vendor/eac_cli/spec/lib/eac_cli/runner_with/output_file_spec.rb +0 -53
@@ -20,9 +20,8 @@ module EacGit
20
20
  end
21
21
 
22
22
  def dirty_files
23
- command('status', '--porcelain', '--untracked-files').execute!.each_line.map do |line|
24
- parse_status_line(line.gsub(/\n\z/, ''))
25
- end
23
+ command('status', '--porcelain=v1', '--untracked-files', '--no-renames')
24
+ .execute!.each_line.map { |line| parse_status_line(line.gsub(/\n\z/, '')) }
26
25
  end
27
26
 
28
27
  private
@@ -5,12 +5,17 @@ require 'eac_git/executables'
5
5
 
6
6
  module EacGit
7
7
  module Rspec
8
+ require_sub __FILE__
9
+
8
10
  class << self
9
11
  def configure
10
12
  ::EacRubyUtils::Rspec::Conditional.default.add(:git) do
11
13
  ::EacGit::Executables.git.validate
12
14
  end
13
- RSpec.configure { |config| ::EacRubyUtils::Rspec::Conditional.default.configure(config) }
15
+ RSpec.configure do |config|
16
+ ::EacRubyUtils::Rspec::Conditional.default.configure(config)
17
+ config.include ::EacGit::Rspec::StubbedGitLocalRepo
18
+ end
14
19
  end
15
20
  end
16
21
  end
@@ -1,28 +1,31 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'eac_git/local'
3
4
  require 'eac_ruby_utils/envs'
4
- require 'eac_launcher/git/base'
5
5
  require 'fileutils'
6
6
  require 'tmpdir'
7
7
 
8
- module Avm
9
- module Git
10
- module SpecHelper
11
- def stubbed_git_repository(bare = false)
8
+ module EacGit
9
+ module Rspec
10
+ module StubbedGitLocalRepo
11
+ def stubbed_git_local_repo(bare = false)
12
12
  path = ::Dir.mktmpdir
13
- ::EacRubyUtils::Envs.local.command(stubbed_git_repository_args(path, bare)).execute!
14
- StubbedGitRepository.new(path)
13
+ ::EacRubyUtils::Envs.local.command(stubbed_git_local_repo_args(path, bare)).execute!
14
+ repo = StubbedGitRepository.new(path)
15
+ repo.command('config', 'user.email', 'theuser@example.net').execute!
16
+ repo.command('config', 'user.name', 'The User').execute!
17
+ repo
15
18
  end
16
19
 
17
20
  private
18
21
 
19
- def stubbed_git_repository_args(path, bare)
22
+ def stubbed_git_local_repo_args(path, bare)
20
23
  r = %w[git init]
21
24
  r << '--bare' if bare
22
25
  r + [path]
23
26
  end
24
27
 
25
- class StubbedGitRepository < ::EacLauncher::Git::Base
28
+ class StubbedGitRepository < ::EacGit::Local
26
29
  def file(*subpath)
27
30
  StubbedGitRepositoryFile.new(self, subpath)
28
31
  end
@@ -37,19 +40,19 @@ module Avm
37
40
  end
38
41
 
39
42
  def path
40
- ::File.join(git, *subpath)
43
+ git.root_path.join(*subpath)
41
44
  end
42
45
 
43
46
  def touch
44
- ::FileUtils.touch(path)
47
+ ::FileUtils.touch(path.to_path)
45
48
  end
46
49
 
47
50
  def delete
48
- ::File.unlink(path)
51
+ path.unlink
49
52
  end
50
53
 
51
54
  def write(content)
52
- ::File.write(path, content)
55
+ path.write(content)
53
56
  end
54
57
  end
55
58
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacGit
4
- VERSION = '0.3.2'
4
+ VERSION = '0.4.2'
5
5
  end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_git/local/commit/diff_tree_line'
4
+
5
+ RSpec.describe ::EacGit::Local::Commit::DiffTreeLine, git: true do
6
+ include_examples 'source_target_fixtures', __FILE__ do
7
+ def source_data(source_file)
8
+ ::File.read(source_file).each_line.map do |line|
9
+ described_class.new(line).fields
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1 @@
1
+ :000000 100644 0000000000000000000000000000000000000000 f380aec0bd8dd777edac43b11636e46cad04273a A nomes.txt
@@ -0,0 +1,7 @@
1
+ ---
2
+ - src_mode: '000000'
3
+ dst_mode: '100644'
4
+ src_sha1: '0000000000000000000000000000000000000000'
5
+ dst_sha1: f380aec0bd8dd777edac43b11636e46cad04273a
6
+ status: A
7
+ path: nomes.txt
@@ -0,0 +1 @@
1
+ :100644 100644 40bcdecb4214cd8a3fcf96cd25a2beb87e7e7cd8 4a30dfae816b984f05cfb594e0d5958bb8c387ae M nomes.txt
@@ -0,0 +1,7 @@
1
+ ---
2
+ - src_mode: '100644'
3
+ dst_mode: '100644'
4
+ src_sha1: 40bcdecb4214cd8a3fcf96cd25a2beb87e7e7cd8
5
+ dst_sha1: 4a30dfae816b984f05cfb594e0d5958bb8c387ae
6
+ status: M
7
+ path: nomes.txt
@@ -0,0 +1 @@
1
+ :100644 000000 10728718a2915256ab162f1e05178ebff9efa6ce 0000000000000000000000000000000000000000 D nomes3.txt
@@ -0,0 +1,7 @@
1
+ ---
2
+ - src_mode: '100644'
3
+ dst_mode: '000000'
4
+ src_sha1: 10728718a2915256ab162f1e05178ebff9efa6ce
5
+ dst_sha1: '0000000000000000000000000000000000000000'
6
+ status: D
7
+ path: nomes3.txt
@@ -0,0 +1,2 @@
1
+ :100644 000000 4a30dfae816b984f05cfb594e0d5958bb8c387ae 0000000000000000000000000000000000000000 D nomes.txt
2
+ :000000 100644 0000000000000000000000000000000000000000 4a30dfae816b984f05cfb594e0d5958bb8c387ae A nomes2.txt
@@ -0,0 +1,13 @@
1
+ ---
2
+ - src_mode: '100644'
3
+ dst_mode: '000000'
4
+ src_sha1: 4a30dfae816b984f05cfb594e0d5958bb8c387ae
5
+ dst_sha1: '0000000000000000000000000000000000000000'
6
+ status: D
7
+ path: nomes.txt
8
+ - src_mode: '000000'
9
+ dst_mode: '100644'
10
+ src_sha1: '0000000000000000000000000000000000000000'
11
+ dst_sha1: 4a30dfae816b984f05cfb594e0d5958bb8c387ae
12
+ status: A
13
+ path: nomes2.txt
@@ -0,0 +1,2 @@
1
+ :100644 000000 4a30dfae816b984f05cfb594e0d5958bb8c387ae 0000000000000000000000000000000000000000 D nomes2.txt
2
+ :000000 100644 0000000000000000000000000000000000000000 10728718a2915256ab162f1e05178ebff9efa6ce A nomes3.txt
@@ -0,0 +1,13 @@
1
+ ---
2
+ - src_mode: '100644'
3
+ dst_mode: '000000'
4
+ src_sha1: 4a30dfae816b984f05cfb594e0d5958bb8c387ae
5
+ dst_sha1: '0000000000000000000000000000000000000000'
6
+ status: D
7
+ path: nomes2.txt
8
+ - src_mode: '000000'
9
+ dst_mode: '100644'
10
+ src_sha1: '0000000000000000000000000000000000000000'
11
+ dst_sha1: 10728718a2915256ab162f1e05178ebff9efa6ce
12
+ status: A
13
+ path: nomes3.txt
@@ -0,0 +1,58 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_git/local'
4
+ require 'eac_git/local/commit'
5
+ require 'tmpdir'
6
+
7
+ RSpec.describe ::EacGit::Local::Commit, git: true do
8
+ let(:git) { stubbed_git_local_repo }
9
+
10
+ let(:first_commit_sha1) do
11
+ git.file('a.txt').write('AAA')
12
+ git.file('b.txt').write('BBB')
13
+ git.command('add', '.').execute!
14
+ git.command('commit', '-m', 'First commit.').execute!
15
+ git.rev_parse('HEAD')
16
+ end
17
+
18
+ let(:second_commit_sha1) do
19
+ first_commit_sha1
20
+ git.file('a.txt').write('AAAAA')
21
+ git.file('b.txt').delete
22
+ git.file('ç.txt').write('CCC')
23
+ git.command('add', '.').execute!
24
+ git.command('commit', '-m', 'Second commit.').execute!
25
+ git.rev_parse('HEAD')
26
+ end
27
+
28
+ let(:first_commit) { described_class.new(git, first_commit_sha1) }
29
+ let(:second_commit) { described_class.new(git, second_commit_sha1) }
30
+
31
+ describe '#changed_files' do
32
+ it { expect(first_commit.changed_files.count).to eq(2) }
33
+ it { expect(second_commit.changed_files.count).to eq(3) }
34
+
35
+ {
36
+ 'first_commit' => %w[a.txt b.txt],
37
+ 'second_commit' => %w[a.txt b.txt ç.txt]
38
+ }.each do |commit_name, filenames|
39
+ filenames.each do |filename|
40
+ it "find file \"#{filename}\" in commit \"#{commit_name}\"" do
41
+ commit = send(commit_name)
42
+ file = commit.changed_files.find { |f| f.path == filename }
43
+ expect(file).to be_a(::EacGit::Local::Commit::ChangedFile)
44
+ end
45
+ end
46
+ end
47
+ end
48
+
49
+ describe '#changed_files_size' do
50
+ it { expect(first_commit.changed_files_size).to eq(6) }
51
+ it { expect(second_commit.changed_files_size).to eq(8) }
52
+ end
53
+
54
+ describe '#root_child?' do
55
+ it { expect(first_commit.root_child?).to eq(true) }
56
+ it { expect(second_commit.root_child?).to eq(false) }
57
+ end
58
+ end
@@ -1,7 +1,3 @@
1
1
  # frozen_string_literal: true
2
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
3
+ ::EacRubyGemSupport::Rspec.default.describe_rubocop
@@ -97,7 +97,10 @@ RSpec.configure do |config|
97
97
  # # test failures related to randomization by passing the same `--seed` value
98
98
  # # as the one that triggered the failure.
99
99
  # Kernel.srand config.seed
100
+ require 'eac_ruby_gem_support/rspec'
101
+ ::EacRubyGemSupport::Rspec.setup(::File.expand_path('..', __dir__), config)
100
102
  end
101
103
 
102
104
  require 'eac_git/rspec'
103
105
  ::EacGit::Rspec.configure
106
+ require 'aranha/parsers/spec/source_target_fixtures_example'
@@ -12,9 +12,9 @@ Gem::Specification.new do |s|
12
12
 
13
13
  s.files = Dir['{lib}/**/*']
14
14
 
15
- s.add_dependency 'eac_cli', '~> 0.7'
16
- s.add_dependency 'eac_ruby_gems_utils', '~> 0.7', '>= 0.7.2'
17
- s.add_dependency 'eac_ruby_utils', '~> 0.46'
15
+ s.add_dependency 'eac_cli', '~> 0.15', '>= 0.15.1'
16
+ s.add_dependency 'eac_ruby_gems_utils', '~> 0.8'
17
+ s.add_dependency 'eac_ruby_utils', '~> 0.60'
18
18
 
19
- s.add_development_dependency 'eac_ruby_gem_support', '~> 0.1', '>= 0.1.2'
19
+ s.add_development_dependency 'eac_ruby_gem_support', '~> 0.2'
20
20
  end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_cli/core_ext'
4
+ require 'eac_ruby_base0/patches'
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/console/speaker'
4
+ require 'eac_ruby_utils/settings_provider'
5
+
6
+ module EacRubyBase0
7
+ module JobsRunner
8
+ common_concern do
9
+ include ::EacRubyUtils::Console::Speaker
10
+ include ::EacRubyUtils::SettingsProvider
11
+ end
12
+
13
+ def run_job(job)
14
+ return unless run_job?(job)
15
+
16
+ infom "Running job \"#{job}\"..."
17
+ send(job)
18
+ end
19
+
20
+ def run_job?(job)
21
+ the_method = "run_#{job}?"
22
+ respond_to?(the_method, true) ? send(the_method) : true
23
+ end
24
+
25
+ def run_jobs(*jobs)
26
+ jobs = setting_value(:jobs) if jobs.empty?
27
+ jobs.each { |job| run_job(job) }
28
+ success 'Done'
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/require_sub'
4
+ ::EacRubyUtils.require_sub(__FILE__)
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/require_sub'
4
+ ::EacRubyUtils.require_sub(__FILE__)
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_base0/jobs_runner'
4
+ require 'eac_ruby_utils/patch'
5
+
6
+ class Class
7
+ def enable_jobs_runner
8
+ ::EacRubyUtils.patch(self, ::EacRubyBase0::JobsRunner)
9
+ end
10
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ Dir["#{File.dirname(__FILE__)}/#{::File.basename(__FILE__, '.*')}/*.rb"].sort.each do |path|
4
+ require path
5
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_cli/core_ext'
4
+ require 'eac_ruby_base0/runner_with'
5
+ ::EacCli::RunnerWithSet.default.add_namespace(::EacRubyBase0::RunnerWith)
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module EacRubyBase0
6
+ module RunnerWith
7
+ require_sub __FILE__
8
+ end
9
+ end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_cli/runner'
4
+ require 'eac_ruby_utils/core_ext'
5
+ require 'eac_ruby_utils/fs/traversable'
6
+
7
+ module EacRubyBase0
8
+ module RunnerWith
9
+ module Confirmation
10
+ DEFAULT_CONFIRM_QUESTION_TEXT = 'Confirm?'
11
+
12
+ common_concern do
13
+ include ::EacCli::Runner
14
+ enable_settings_provider
15
+ runner_definition do
16
+ bool_opt '--no', 'Deny confirmation without question.'
17
+ bool_opt '--yes', 'Accept confirmation without question.'
18
+ end
19
+ end
20
+
21
+ def confirm?(message = nil)
22
+ return false if parsed.no?
23
+ return true if parsed.yes?
24
+
25
+ request_input(
26
+ message || setting_value(:confirm_question_text, default: DEFAULT_CONFIRM_QUESTION_TEXT),
27
+ bool: true
28
+ )
29
+ end
30
+
31
+ def run_confirm(message = nil)
32
+ yield if confirm?(message)
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_cli/runner'
4
+ require 'eac_ruby_utils/core_ext'
5
+ require 'eac_ruby_utils/fs/traversable'
6
+ require 'eac_ruby_utils/settings_provider'
7
+
8
+ module EacRubyBase0
9
+ module RunnerWith
10
+ module FilesystemTraverser
11
+ DEFAULT_DEFAULT_TRAVERSER_RECURSIVE = false
12
+
13
+ common_concern do
14
+ include ::EacCli::Runner
15
+ include ::EacRubyUtils::Fs::Traversable
16
+ enable_settings_provider
17
+ include TopMethods
18
+ runner_definition do
19
+ bool_opt '-R', '--recursive', 'Recursive.'
20
+ bool_opt '--no-recursive', 'No recursive.'
21
+ pos_arg :paths, optional: true, repeat: true
22
+ end
23
+ end
24
+
25
+ module TopMethods
26
+ def on_none_path_informed
27
+ infom 'Warning: none path informed'
28
+ end
29
+
30
+ def paths
31
+ parsed.paths.map(&:to_pathname)
32
+ end
33
+
34
+ def run_filesystem_traverser
35
+ if parsed.paths.any?
36
+ parsed.paths.each { |path| traverser_check_path(path) }
37
+ else
38
+ on_none_path_informed
39
+ end
40
+ end
41
+
42
+ def traverser_recursive
43
+ return false if parsed.no_recursive?
44
+ return true if parsed.recursive?
45
+
46
+ setting_value(:default_traverser_recursive, required: false)
47
+ .if_not_nil(DEFAULT_DEFAULT_TRAVERSER_RECURSIVE)
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end