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
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+ require 'avm/ruby/bundler/incompatible_parser/depends_on'
5
+ require 'avm/ruby/bundler/incompatible_parser/gem_conflict'
6
+ require 'avm/ruby/bundler/incompatible_parser/in_gemfile'
7
+
8
+ module Avm
9
+ module Ruby
10
+ module Bundler
11
+ class IncompatibleParser
12
+ class LineFactory
13
+ TYPES = [GemConflict, InGemfile, DependsOn, VersionRequirement].freeze
14
+
15
+ enable_simple_cache
16
+ common_constructor :content do
17
+ self.content = content.strip
18
+ end
19
+
20
+ delegate :blank?, to: :content
21
+
22
+ private
23
+
24
+ def result_uncached
25
+ TYPES.lazy.map { |type| type.parse(content) }.find(&:present?)
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module Ruby
7
+ module Bundler
8
+ class IncompatibleParser
9
+ class LineParserBase
10
+ class << self
11
+ def parse(line_content)
12
+ const_get('LINE_PARSER').parse(line_content)
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+ require 'avm/ruby/bundler/incompatible_parser/line_parser_base'
5
+
6
+ module Avm
7
+ module Ruby
8
+ module Bundler
9
+ class IncompatibleParser
10
+ class VersionRequirement < ::Avm::Ruby::Bundler::IncompatibleParser::LineParserBase
11
+ LINE_PARSER = /\A([a-z][a-z_0-9]*)(?: \((.+)\))?\z/
12
+ .to_parser { |m| new(m[1], m[2]) }
13
+
14
+ enable_simple_cache
15
+ attr_accessor :stack
16
+
17
+ common_constructor :gem_name, :requirements_source
18
+
19
+ def data
20
+ { requirements_source: requirements_source, stack: stack.map(&:data) }
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -8,7 +8,7 @@ module Avm
8
8
  module Gems
9
9
  class Generator
10
10
  IDENT = ' '
11
- JOBS = %w[root_directory gemspec root_lib version_lib static gemfile_lock rspec].freeze
11
+ JOBS = %w[root_directory gemspec root_lib version_lib static gemfile_lock].freeze
12
12
  TEMPLATE_VARIABLES = %w[lib_path name root_module].freeze
13
13
 
14
14
  enable_console_speaker
@@ -92,10 +92,6 @@ module Avm
92
92
  template_apply('root_lib', "lib/#{lib_path}.rb")
93
93
  end
94
94
 
95
- def generate_rspec
96
- self_gem.bundle('exec', 'rspec').chdir_root.execute!
97
- end
98
-
99
95
  def generate_static
100
96
  template.child('static').apply(self, root_directory)
101
97
  end
@@ -1,18 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'avm/eac_redmine_base0/core_update'
4
- require 'eac_cli/default_runner'
5
- require 'eac_ruby_utils/console/docopt_runner'
6
- require 'eac_ruby_utils/core_ext'
4
+ require 'eac_cli/core_ext'
7
5
 
8
6
  module Avm
9
7
  module Tools
10
8
  class Runner
11
9
  class EacRedmineBase0 < ::Avm::EacRailsBase1::Runner
12
- class CoreUpdate < ::EacRubyUtils::Console::DocoptRunner
13
- include ::EacCli::DefaultRunner
14
-
15
- runner_definition do
10
+ class CoreUpdate
11
+ runner_with :help do
16
12
  arg_opt '-u', '--url', 'Core\'s package URL.'
17
13
  arg_opt '-v', '--version', 'Core\'s version.'
18
14
  desc 'Update instance\' core.'
@@ -32,7 +28,7 @@ module Avm
32
28
  end
33
29
 
34
30
  def update
35
- ::Avm::EacRedmineBase0::CoreUpdate.new(context(:instance), version, url).run
31
+ ::Avm::EacRedmineBase0::CoreUpdate.new(runner_context.call(:instance), version, url).run
36
32
  end
37
33
 
38
34
  def url
@@ -40,7 +36,7 @@ module Avm
40
36
  end
41
37
 
42
38
  def url_by_version
43
- options.fetch('--version').if_present do |v|
39
+ parsed.version.if_present do |v|
44
40
  "https://www.redmine.org/releases/redmine-#{v}.tar.gz"
45
41
  end
46
42
  end
@@ -52,11 +48,11 @@ module Avm
52
48
  end
53
49
 
54
50
  def version
55
- options.fetch('--version') || version_by_url
51
+ parsed.version || version_by_url
56
52
  end
57
53
 
58
54
  def version_by_url
59
- options.fetch('--url').if_present do |v|
55
+ parsed.url.if_present do |v|
60
56
  /(\d+.\d+.\d+)/.if_match(v, false) { |m| m[1] }
61
57
  end
62
58
  end
@@ -1,8 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'avm/git/auto_commit_path'
4
- require 'avm/files/formatter'
5
3
  require 'eac_cli/core_ext'
4
+ require 'avm/files/formatter'
5
+ require 'avm/git/file_auto_fixup'
6
+ require 'avm/git/auto_commit/rules'
6
7
 
7
8
  module Avm
8
9
  module Tools
@@ -10,54 +11,53 @@ module Avm
10
11
  class Git
11
12
  class AutoCommit
12
13
  runner_with :help do
13
- desc 'Commit with message based in content commited.'
14
+ desc 'Auto fixup files.'
14
15
  bool_opt '-d', '--dirty', 'Select dirty files.'
15
16
  bool_opt '-f', '--format', 'Format files before commit.'
16
- pos_arg 'paths', repeat: true, optional: true
17
+ arg_opt '-r', '--rule', 'Apply a rule in the specified order.', repeat: true
18
+ pos_arg :files, repeat: true, optional: true
17
19
  end
18
20
 
19
21
  def run
20
- clear_stage
21
- banner
22
22
  format_files
23
- run_paths
23
+ files.each do |file|
24
+ ::Avm::Git::FileAutoFixup.new(runner_context.call(:git), file, rules).run
25
+ end
24
26
  end
25
27
 
26
28
  private
27
29
 
28
- def banner
29
- infov 'Paths', paths.count
30
+ def files_uncached
31
+ (files_from_option + dirty_files).sort.uniq
30
32
  end
31
33
 
32
- def clear_stage
33
- infom 'Clearing stage...'
34
- runner_context.call(:git).system!('reset', 'HEAD')
35
- end
36
-
37
- def dirty_paths
38
- return [] unless parsed.dirty?
39
-
40
- runner_context.call(:git).dirty_files.map do |d|
41
- runner_context.call(:git).root_path.join / d.path
42
- end
34
+ def files_from_option
35
+ parsed.files.map { |p| p.to_pathname.expand_path }
43
36
  end
44
37
 
45
38
  def format_files
46
39
  return unless parsed.format?
47
40
 
48
41
  infom 'Formating files...'
49
- ::Avm::Files::Formatter.new(paths.map(&:path),
50
- ::Avm::Files::Formatter::OPTION_APPLY => true).run
42
+ ::Avm::Files::Formatter.new(files, ::Avm::Files::Formatter::OPTION_APPLY => true).run
51
43
  end
52
44
 
53
- def paths_uncached
54
- (parsed.paths.map { |p| p.to_pathname.expand_path } + dirty_paths)
55
- .reject(&:directory?).sort.uniq
56
- .map { |path| ::Avm::Git::AutoCommitPath.new(runner_context.call(:git), path) }
45
+ def dirty_files
46
+ return [] unless parsed.dirty?
47
+
48
+ runner_context.call(:git).dirty_files.map do |file|
49
+ file.path.to_pathname.expand_path(runner_context.call(:git).root_path)
50
+ end
51
+ end
52
+
53
+ def rules
54
+ parsed.rule.map do |rule_string|
55
+ ::Avm::Git::AutoCommit::Rules.parse(rule_string)
56
+ end
57
57
  end
58
58
 
59
- def run_paths
60
- paths.each(&:run)
59
+ def select
60
+ parsed.last? ? 1 : parsed.select
61
61
  end
62
62
  end
63
63
  end
@@ -30,7 +30,7 @@ module Avm
30
30
  local_repos.dirty_files.each do |file|
31
31
  infov ' * Ammending', file.path
32
32
  ::Avm::Git::FileAutoFixup.new(runner_context.call(:git), file.path,
33
- ::Avm::Git::FileAutoFixup::OPTION_UNIQUE => true).run
33
+ [::Avm::Git::AutoCommit::Rules::Unique.new]).run
34
34
  end
35
35
  end
36
36
 
@@ -1,9 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'avm/patches/eac_ruby_gems_utils/gem'
4
- require 'eac_cli/default_runner'
5
- require 'eac_ruby_utils/console/docopt_runner'
6
- require 'eac_ruby_utils/core_ext'
4
+ require 'eac_cli/core_ext'
7
5
 
8
6
  module Avm
9
7
  module Tools
@@ -11,9 +9,7 @@ module Avm
11
9
  class LocalProject
12
10
  class Ruby
13
11
  require_sub __FILE__
14
- include ::EacCli::DefaultRunner
15
-
16
- runner_definition do
12
+ runner_with :help, :subcommands do
17
13
  desc 'Ruby utitilies for local projects.'
18
14
  subcommands
19
15
  end
@@ -1,19 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'eac_cli/default_runner'
4
- require 'eac_ruby_utils/console/docopt_runner'
5
- require 'eac_ruby_utils/core_ext'
3
+ require 'eac_ruby_base0/core_ext'
6
4
 
7
5
  module Avm
8
6
  module Tools
9
7
  class Runner
10
8
  class LocalProject
11
9
  class Ruby
12
- class Bundler < ::EacRubyUtils::Console::DocoptRunner
10
+ class Bundler
13
11
  require_sub __FILE__
14
- include ::EacCli::DefaultRunner
15
-
16
- runner_definition do
12
+ runner_with :help, :subcommands do
17
13
  desc 'Ruby\'s bundler utitilies for local projects.'
18
14
  subcommands
19
15
  end
@@ -1,18 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'eac_cli/default_runner'
4
- require 'eac_ruby_utils/console/docopt_runner'
3
+ require 'eac_ruby_base0/core_ext'
5
4
 
6
5
  module Avm
7
6
  module Tools
8
7
  class Runner
9
8
  class LocalProject
10
9
  class Ruby
11
- class Bundler < ::EacRubyUtils::Console::DocoptRunner
12
- class GemfileLock < ::EacRubyUtils::Console::DocoptRunner
13
- include ::EacCli::DefaultRunner
14
-
15
- runner_definition do
10
+ class Bundler
11
+ class GemfileLock
12
+ runner_with :help do
16
13
  desc 'Manipulage a "Gemfile.lock" file.'
17
14
  bool_opt '-c', '--continue', 'Continue Git rebase/cherry-pick.'
18
15
  bool_opt '-i', '--install', 'Run "bundle install".'
@@ -34,7 +31,7 @@ module Avm
34
31
  private
35
32
 
36
33
  def complete?
37
- !option_or_all?('--recursive') || !conflict?
34
+ !option_or_all?(:recursive) || !conflict?
38
35
  end
39
36
 
40
37
  def rebasing?
@@ -51,21 +48,21 @@ module Avm
51
48
  end
52
49
 
53
50
  def bundle_install
54
- return unless check_capability(__method__, :ruby_gem, '--install')
51
+ return unless check_capability(__method__, :ruby_gem, :install)
55
52
 
56
53
  infom '"bundle install"...'
57
54
  bundle_run('install')
58
55
  end
59
56
 
60
57
  def bundle_update
61
- return unless check_capability(__method__, :ruby_gem, '--update')
58
+ return unless check_capability(__method__, :ruby_gem, :update)
62
59
 
63
60
  infom '"bundle update"...'
64
61
  bundle_run('update')
65
62
  end
66
63
 
67
64
  def git_continue
68
- return unless check_capability(__method__, :git_repo, '--continue')
65
+ return unless check_capability(__method__, :git_repo, :continue)
69
66
 
70
67
  infom "Adding \"#{gemfile_lock}\"..."
71
68
  instance.git_repo.command('add', gemfile_lock).execute!
@@ -115,11 +112,11 @@ module Avm
115
112
  end
116
113
 
117
114
  def option_or_all?(option)
118
- options.fetch(option) || options.fetch('--all')
115
+ parsed[option] || parsed.all?
119
116
  end
120
117
 
121
118
  def instance
122
- context(:instance)
119
+ runner_context.call(:instance)
123
120
  end
124
121
 
125
122
  def check_capability(caller, capability, option)
@@ -0,0 +1,84 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/fs_cache'
4
+ require 'avm/ruby/bundler/incompatible_parser'
5
+ require 'eac_ruby_base0/core_ext'
6
+
7
+ module Avm
8
+ module Tools
9
+ class Runner
10
+ class LocalProject
11
+ class Ruby
12
+ class Bundler
13
+ class Incompatible
14
+ runner_with :help do
15
+ desc 'Identify incompatible gems in a "Gemfile.lock" file.'
16
+ bool_opt '-l', '--last', 'Process the last \"bundle update\" result.'
17
+ end
18
+
19
+ def run
20
+ infov 'Cache path', fs_cache.content_path
21
+ infov 'Cached?', fs_cache.cached?
22
+ parser.gems_in_conflict.each do |gem_in_conflict|
23
+ print_gem_in_conflict(gem_in_conflict)
24
+ end
25
+ end
26
+
27
+ private
28
+
29
+ def bundle_update
30
+ infom 'Running "bundle update"...'
31
+ instance.ruby_gem.bundle('update').execute[:stdout]
32
+ end
33
+
34
+ def content_path
35
+ fs_cache.write(bundle_update) unless fs_cache.cached? && parsed.last?
36
+ fs_cache.content_path
37
+ end
38
+
39
+ def fs_cache_uncached
40
+ ::Avm.fs_cache.child(self.class.name.variableize)
41
+ .child(instance.path.to_s.variableize)
42
+ end
43
+
44
+ def gem_title(gem_in_conflict)
45
+ gem_in_conflict.gem_name
46
+ end
47
+
48
+ def instance
49
+ runner_context.call(:instance)
50
+ end
51
+
52
+ def parser_uncached
53
+ ::Avm::Ruby::Bundler::IncompatibleParser.new(content_path)
54
+ end
55
+
56
+ def print_gem_in_conflict(gem_in_conflict)
57
+ infov 'Gem', gem_title(gem_in_conflict)
58
+ gem_in_conflict.versions_requirements.each do |requirement|
59
+ print_requirement(requirement)
60
+ end
61
+ end
62
+
63
+ def print_requirement(req)
64
+ infov ' ' + requirement_title(req), requirement_value(req)
65
+ end
66
+
67
+ def requirement_stack(req)
68
+ req.stack.map { |d| "#{d.gem_name} (#{d.version})" }.join(' > '.green)
69
+ end
70
+
71
+ def requirement_title(req)
72
+ req.requirements_source.if_present('*')
73
+ end
74
+
75
+ def requirement_value(req)
76
+ requirement_stack(req)
77
+ end
78
+ end
79
+ end
80
+ end
81
+ end
82
+ end
83
+ end
84
+ end