avm-tools 0.94.2 → 0.94.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) 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/tools/version.rb +1 -1
  8. data/vendor/eac_cli/lib/eac_cli/definition/base_option.rb +5 -1
  9. data/vendor/eac_cli/lib/eac_cli/runner/context.rb +2 -1
  10. data/vendor/eac_cli/lib/eac_cli/runner/instance_methods.rb +8 -1
  11. data/vendor/eac_cli/lib/eac_cli/version.rb +1 -1
  12. data/vendor/eac_git/eac_git.gemspec +1 -0
  13. data/vendor/eac_git/lib/eac_git/local.rb +4 -0
  14. data/vendor/eac_git/lib/eac_git/local/commit.rb +53 -0
  15. data/vendor/eac_git/lib/eac_git/local/commit/changed_file.rb +46 -0
  16. data/vendor/eac_git/lib/eac_git/local/commit/diff_tree_line.rb +32 -0
  17. data/vendor/eac_git/lib/eac_git/rspec.rb +6 -1
  18. data/{lib/avm/git/spec_helper.rb → vendor/eac_git/lib/eac_git/rspec/stubbed_git_local_repo.rb} +16 -13
  19. data/vendor/eac_git/lib/eac_git/version.rb +1 -1
  20. data/vendor/eac_git/spec/lib/eac_git/local/commit/diff_tree_line_spec.rb +13 -0
  21. data/vendor/eac_git/spec/lib/eac_git/local/commit/diff_tree_line_spec_files/add.source.out +1 -0
  22. data/vendor/eac_git/spec/lib/eac_git/local/commit/diff_tree_line_spec_files/add.target.yaml +7 -0
  23. data/vendor/eac_git/spec/lib/eac_git/local/commit/diff_tree_line_spec_files/modify.source.out +1 -0
  24. data/vendor/eac_git/spec/lib/eac_git/local/commit/diff_tree_line_spec_files/modify.target.yaml +7 -0
  25. data/vendor/eac_git/spec/lib/eac_git/local/commit/diff_tree_line_spec_files/remove.source.out +1 -0
  26. data/vendor/eac_git/spec/lib/eac_git/local/commit/diff_tree_line_spec_files/remove.target.yaml +7 -0
  27. data/vendor/eac_git/spec/lib/eac_git/local/commit/diff_tree_line_spec_files/rename.source.out +2 -0
  28. data/vendor/eac_git/spec/lib/eac_git/local/commit/diff_tree_line_spec_files/rename.target.yaml +13 -0
  29. data/vendor/eac_git/spec/lib/eac_git/local/commit/diff_tree_line_spec_files/rename_modify.source.out +2 -0
  30. data/vendor/eac_git/spec/lib/eac_git/local/commit/diff_tree_line_spec_files/rename_modify.target.yaml +13 -0
  31. data/vendor/eac_git/spec/lib/eac_git/local/commit_spec.rb +58 -0
  32. data/vendor/eac_git/spec/spec_helper.rb +1 -0
  33. data/vendor/eac_ruby_base0/eac_ruby_base0.gemspec +3 -3
  34. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/runner_with/output.rb +58 -0
  35. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/version.rb +1 -1
  36. data/vendor/eac_ruby_base0/spec/lib/eac_ruby_base0/runner_with/output_spec.rb +81 -0
  37. data/vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/tests/base.rb +7 -10
  38. data/vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/tests/multiple.rb +9 -2
  39. data/vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/version.rb +1 -1
  40. data/vendor/eac_ruby_utils/eac_ruby_utils.gemspec +1 -0
  41. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/fs/logs.rb +63 -0
  42. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/inflector.rb +9 -1
  43. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/listable/list.rb +3 -2
  44. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/kernel/nyi.rb +4 -2
  45. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/string/inflector.rb +4 -2
  46. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/settings_provider.rb +10 -29
  47. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/settings_provider/setting_value.rb +69 -0
  48. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/version.rb +1 -1
  49. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/settings_provider_spec.rb +8 -0
  50. metadata +24 -6
  51. data/vendor/eac_cli/lib/eac_cli/runner_with/output_file.rb +0 -30
  52. data/vendor/eac_cli/spec/lib/eac_cli/runner_with/output_file_spec.rb +0 -53
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a418fd7c14cb6599e9c75eeba391a576aefb0897c6ce0f069568495cf0cb9802
4
- data.tar.gz: 9ae79ac488f4fb96331b6d71bb7db9e943947b37577ffb725c3e10241b8b6206
3
+ metadata.gz: 266e7f05ba459608c81b684bb675e5efab20d7be043e59424398a3c810cf1db9
4
+ data.tar.gz: f9b04149ba95fa4cd4b4aba277118918351727999ed1a363b4782f0cd5ffcd96
5
5
  SHA512:
6
- metadata.gz: 4faba2cbbbcdcc77ca7a925373de53056f7e1ef8caaa183f9eb6e8ca56c4de4e77e923cfa0567f8c83995cad400a3d09d698e18a77aa95dfbca98fcf8aa1d320
7
- data.tar.gz: 772e38b1000548d8e37bc44b2ac9380948fbeaca3706b7d7218140895765fd053e589eabe95a23e64d19c931ee7e28cc18ce865931e76536d3f8c5dd83cd0ed5
6
+ metadata.gz: 1b2028e2aa894113dcbcee37742d302d1e12a363fddd5b569da22d84ea6c9e8f49ce87e9675af1bf8cef0b1a5d9e11dc94c969f61e71ff6ab1164371b145e987
7
+ data.tar.gz: 356839265fa90cc3d360af76194562840fa88aea67f0743814f22044263903fa5007b6617878610e19e43763bc5e238c6a37b697c379cccdf376ff61596ce1fa
@@ -9,6 +9,7 @@ require 'avm/eac_webapp_base0/deploy/file_unit'
9
9
  module Avm
10
10
  module EacWebappBase0
11
11
  class Instance < ::Avm::Instances::Base
12
+ require_sub __FILE__
12
13
  include ::Avm::Postgresql::InstanceWith
13
14
 
14
15
  FILES_UNITS = [].freeze
@@ -26,8 +27,10 @@ module Avm
26
27
  end
27
28
 
28
29
  def run_subcommand(subcommand_class, argv)
29
- parent = ::OpenStruct.new(instance: self)
30
- subcommand_class.new(argv: argv, parent: parent).run
30
+ subcommand_class.create(
31
+ argv: argv,
32
+ parent: ::Avm::EacWebappBase0::Instance::SubcommandParent.new(self)
33
+ ).run
31
34
  end
32
35
 
33
36
  def data_package
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module EacWebappBase0
7
+ class Instance < ::Avm::Instances::Base
8
+ class SubcommandParent
9
+ enable_simple_cache
10
+ common_constructor :instance
11
+
12
+ private
13
+
14
+ def runner_context_uncached
15
+ ::EacCli::Runner::Context.new(self, argv: runner_argv)
16
+ end
17
+
18
+ def runner_argv
19
+ [instance.class.name.split('::')[-2].dasherize, instance.id]
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -9,6 +9,7 @@ module Avm
9
9
  require_sub __FILE__
10
10
  runner_with :help, :subcommands do
11
11
  desc 'Data utilities for EacRailsBase0 instances.'
12
+ subcommands
12
13
  end
13
14
  end
14
15
  end
@@ -15,7 +15,7 @@ module Avm
15
15
 
16
16
  runner_with :help do
17
17
  desc 'Dump utility for EacRailsBase instance.'
18
- bool_opt '-w', 'rewrite', 'Forces dump overwrite.'
18
+ bool_opt '-w', '--rewrite', 'Forces dump overwrite.'
19
19
  arg_opt '-p', '--dump-path', 'Set DUMP_PATH variable.'
20
20
  end
21
21
 
@@ -9,7 +9,7 @@ module Avm
9
9
  class Runner < ::Avm::Instances::Runner
10
10
  class Data
11
11
  class Load
12
- runner_with :ĥelp do
12
+ runner_with :help do
13
13
  desc 'Load utility for EacRailsBase instance.'
14
14
  arg_opt '-S', '--source-instance', 'Informa a instância a ser extraída o dump.'
15
15
  pos_arg :dump_path, optional: true
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Avm
4
4
  module Tools
5
- VERSION = '0.94.2'
5
+ VERSION = '0.94.3'
6
6
  end
7
7
  end
@@ -28,7 +28,11 @@ module EacCli
28
28
  end
29
29
 
30
30
  def identifier
31
- long.to_s.variableize.to_sym
31
+ [long, short].each do |v|
32
+ v.to_s.if_present { |vv| return vv.variableize.to_sym }
33
+ end
34
+
35
+ raise 'No short or long option to build identifier'
32
36
  end
33
37
 
34
38
  def repeat?
@@ -27,8 +27,9 @@ module EacCli
27
27
 
28
28
  def parent_call(method_name, *args)
29
29
  return parent.context(method_name, *args) if parent.respond_to?(:context)
30
+ return parent.runner_context.call(method_name, *args) if parent.respond_to?(:runner_context)
30
31
 
31
- parent.runner_context.call(method_name, *args)
32
+ raise "Parent #{parent} do not respond to .context or .runner_context (Runner: #{runner})"
32
33
  end
33
34
  end
34
35
  end
@@ -3,15 +3,22 @@
3
3
  module EacCli
4
4
  module Runner
5
5
  module InstanceMethods
6
+ PARSER_ERROR_EXIT_CODE = 1
7
+
6
8
  def run_run
7
9
  parsed
8
10
  run_callbacks(:run) { run }
9
11
  rescue ::EacCli::Parser::Error => e
10
- $stderr.write("#{e}\n")
12
+ run_parser_error(e)
11
13
  rescue ::EacCli::Runner::Exit # rubocop:disable Lint/SuppressedException
12
14
  # Do nothing
13
15
  end
14
16
 
17
+ def run_parser_error(error)
18
+ $stderr.write("#{error}\n")
19
+ ::Kernel.exit(PARSER_ERROR_EXIT_CODE)
20
+ end
21
+
15
22
  def runner_context
16
23
  return @runner_context if @runner_context
17
24
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacCli
4
- VERSION = '0.15.1'
4
+ VERSION = '0.16.1'
5
5
  end
@@ -15,5 +15,6 @@ Gem::Specification.new do |s|
15
15
  s.add_dependency 'eac_ruby_utils', '~> 0.37'
16
16
  s.add_dependency 'parseconfig', '~> 1.0', '>= 1.0.8'
17
17
 
18
+ s.add_development_dependency 'aranha-parsers', '~> 0.7'
18
19
  s.add_development_dependency 'eac_ruby_gem_support', '~> 0.1', '>= 0.1.2'
19
20
  end
@@ -12,6 +12,10 @@ module EacGit
12
12
  self.root_path = root_path.to_pathname
13
13
  end
14
14
 
15
+ def commit(ref, required = false)
16
+ rev_parse(ref, required).if_present { |v| ::EacGit::Local::Commit.new(self, v) }
17
+ end
18
+
15
19
  def descendant?(descendant, ancestor)
16
20
  base = merge_base(descendant, ancestor)
17
21
  return false if base.blank?
@@ -0,0 +1,53 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module EacGit
6
+ class Local
7
+ class Commit
8
+ require_sub __FILE__, include_modules: true
9
+ enable_simple_cache
10
+
11
+ FIELDS = {
12
+ author_name: '%an', author_email: '%ae', author_date: '%ai',
13
+ subject: '%s',
14
+ author_all: '%an <%ae>, %ai',
15
+ commiter_name: '%cn', commiter_email: '%ce', commiter_date: '%ci',
16
+ commiter_all: '%cn <%ce>, %ci'
17
+ }.freeze
18
+
19
+ common_constructor :repo, :hash
20
+
21
+ def format(format)
22
+ repo.command('--no-pager', 'log', '-1', "--pretty=format:#{format}", hash).execute!.strip
23
+ end
24
+
25
+ FIELDS.each do |field, format|
26
+ define_method(field) { format(format) }
27
+ end
28
+
29
+ def changed_files_uncached
30
+ diff_tree_execute.each_line.map do |line|
31
+ ::EacGit::Local::Commit::ChangedFile.new(self, line)
32
+ end
33
+ end
34
+
35
+ def changed_files_size_uncached
36
+ changed_files.inject(0) { |a, e| a + e.dst_size }
37
+ end
38
+
39
+ def root_child?
40
+ format('%P').blank?
41
+ end
42
+
43
+ private
44
+
45
+ def diff_tree_execute
46
+ args = []
47
+ args << '--root' if root_child?
48
+ args << hash
49
+ repo.command(*::EacGit::Local::Commit::DiffTreeLine::GIT_COMMAND_ARGS, *args).execute!
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+ require 'eac_git/local/commit/diff_tree_line'
5
+
6
+ module EacGit
7
+ class Local
8
+ class Commit
9
+ class ChangedFile
10
+ enable_simple_cache
11
+
12
+ attr_reader :commit, :diff_tree
13
+
14
+ # @param commit [EacGit::Local::Commit]
15
+ # @param diff_tree_line [String] A line from command "repo diff-tree --no-commit-id -r
16
+ # --full-index"'s output.
17
+ def initialize(commit, diff_tree_line)
18
+ @commit = commit
19
+ @diff_tree = ::EacGit::Local::Commit::DiffTreeLine.new(diff_tree_line)
20
+ end
21
+
22
+ delegate(*::EacGit::Local::Commit::DiffTreeLine::FIELDS, to: :diff_tree)
23
+
24
+ def to_s
25
+ "#{path}|#{status}"
26
+ end
27
+
28
+ def src_size_uncached
29
+ size(src_sha1)
30
+ end
31
+
32
+ def dst_size_uncached
33
+ size(dst_sha1)
34
+ end
35
+
36
+ private
37
+
38
+ def size(id)
39
+ return 0 if /\A0+\z/.match(id)
40
+
41
+ commit.repo.command('cat-file', '-s', id).execute!.strip.to_i
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EacGit
4
+ class Local
5
+ class Commit
6
+ class DiffTreeLine
7
+ DIFF_TREE_PATTERN = /\A:(\d{6}) (\d{6}) (\S+) (\S+) (\S+)\t(\S.*)\z/.freeze
8
+ FIELDS = %w[src_mode dst_mode src_sha1 dst_sha1 status path].freeze
9
+ GIT_COMMAND_ARGS = %w[-c core.quotepath=off diff-tree --no-commit-id -r --full-index].freeze
10
+
11
+ attr_reader(*FIELDS)
12
+
13
+ # line: a line of command "git [GIT_COMMAND_ARGS]"'s output.
14
+ # Reference: https://git-scm.com/docs/git-diff-tree
15
+ def initialize(line)
16
+ m = DIFF_TREE_PATTERN.match(line.strip)
17
+ raise "\"#{line}\" did not match pattern" unless m
18
+
19
+ FIELDS.count.times { |i| send("#{FIELDS[i]}=", m[i + 1]) }
20
+ end
21
+
22
+ def fields
23
+ FIELDS.map { |field| [field, send(field)] }.to_h
24
+ end
25
+
26
+ private
27
+
28
+ attr_writer(*FIELDS)
29
+ end
30
+ end
31
+ end
32
+ end
@@ -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.3'
4
+ VERSION = '0.4.1'
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