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
@@ -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
@@ -101,3 +101,4 @@ end
101
101
 
102
102
  require 'eac_git/rspec'
103
103
  ::EacGit::Rspec.configure
104
+ 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
19
  s.add_development_dependency 'eac_ruby_gem_support', '~> 0.1', '>= 0.1.2'
20
20
  end
@@ -0,0 +1,58 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_cli/runner'
4
+ require 'eac_ruby_utils/core_ext'
5
+ require 'eac_ruby_utils/abstract_methods'
6
+
7
+ module EacRubyBase0
8
+ module RunnerWith
9
+ module Output
10
+ STDOUT_OPTION = '-'
11
+ DEFAULT_FILE_OPTION = '+'
12
+ DEFAULT_DEFAULT_OUTPUT_OPTION = STDOUT_OPTION
13
+ DEFAULT_DEFAULT_FILE_TO_OUTPUT = 'output'
14
+
15
+ common_concern do
16
+ enable_abstract_methods
17
+ enable_settings_provider
18
+ include ::EacCli::Runner
19
+
20
+ abstract_methods :output_content
21
+
22
+ runner_definition do
23
+ arg_opt '-o', '--output', 'Output to file.'
24
+ end
25
+ end
26
+
27
+ def run_output
28
+ file = file_to_output
29
+ if file
30
+ file.to_pathname.write(output_content)
31
+ else
32
+ $stdout.write(output_content)
33
+ end
34
+ end
35
+
36
+ def output_option
37
+ parsed.output || default_output_option_value
38
+ end
39
+
40
+ def file_to_output
41
+ case output_option
42
+ when STDOUT_OPTION then nil
43
+ when DEFAULT_FILE_OPTION then default_file_to_output_value
44
+ else output_option
45
+ end
46
+ end
47
+
48
+ def default_output_option_value
49
+ setting_value(:default_output_option,
50
+ default: DEFAULT_DEFAULT_OUTPUT_OPTION)
51
+ end
52
+
53
+ def default_file_to_output_value
54
+ setting_value(:default_file_to_output, default: DEFAULT_DEFAULT_FILE_TO_OUTPUT)
55
+ end
56
+ end
57
+ end
58
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacRubyBase0
4
- VERSION = '0.5.0'
4
+ VERSION = '0.6.0'
5
5
  end
@@ -0,0 +1,81 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_base0/runner_with/output'
4
+ require 'eac_ruby_utils/fs/temp'
5
+
6
+ RSpec.describe ::EacRubyBase0::RunnerWith::Output do
7
+ let(:runner) do
8
+ the_module = described_class
9
+ Class.new do
10
+ include the_module
11
+
12
+ attr_accessor :temp_dir
13
+
14
+ runner_definition do
15
+ desc 'A stub root runner.'
16
+ pos_arg :input_text
17
+ end
18
+
19
+ def run
20
+ run_output
21
+ end
22
+
23
+ def output_content
24
+ parsed.input_text
25
+ end
26
+
27
+ def default_file_to_output
28
+ temp_dir.join('default_file')
29
+ end
30
+ end
31
+ end
32
+
33
+ let(:stub_text) { 'STUB_TEXT' }
34
+ let(:instance) do
35
+ r = runner.create(argv: runner_argv)
36
+ r.temp_dir = temp_dir
37
+ r
38
+ end
39
+ let(:temp_dir) { ::EacRubyUtils::Fs::Temp.directory }
40
+
41
+ after { temp_dir.remove }
42
+
43
+ context 'without --output option' do
44
+ let(:runner_argv) { [stub_text] }
45
+
46
+ it do
47
+ expect { instance.run }.to output(stub_text).to_stdout_from_any_process
48
+ end
49
+ end
50
+
51
+ context 'without --output option as to stdout' do
52
+ let(:runner_argv) { ['--output', ::EacRubyBase0::RunnerWith::Output::STDOUT_OPTION, stub_text] }
53
+
54
+ it do
55
+ expect { instance.run }.to output(stub_text).to_stdout_from_any_process
56
+ end
57
+ end
58
+
59
+ context 'without --output option as to default file' do
60
+ let(:output_file) { temp_dir.join('default_file') }
61
+ let(:runner_argv) do
62
+ ['--output', ::EacRubyBase0::RunnerWith::Output::DEFAULT_FILE_OPTION,
63
+ stub_text]
64
+ end
65
+
66
+ before { instance.run }
67
+
68
+ it { expect(output_file).to exist }
69
+ it { expect(output_file.read).to eq(stub_text) }
70
+ end
71
+
72
+ context 'with --output option' do
73
+ let(:output_file) { temp_dir.join('a output file') }
74
+ let(:runner_argv) { ['--output', output_file.to_path, stub_text] }
75
+
76
+ before { instance.run }
77
+
78
+ it { expect(output_file).to exist }
79
+ it { expect(output_file.read).to eq(stub_text) }
80
+ end
81
+ end
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'eac_ruby_utils/core_ext'
4
+ require 'eac_ruby_utils/fs/logs'
4
5
  require 'eac_ruby_utils/fs_cache'
5
6
  require 'eac_ruby_utils/listable'
6
7
  require 'eac_ruby_utils/on_clean_ruby_environment'
@@ -27,20 +28,16 @@ module EacRubyGemsUtils
27
28
  self.class.name.demodulize.gsub(/Test\z/, '')
28
29
  end
29
30
 
30
- def stdout_cache
31
- root_cache.child('stdout')
32
- end
33
-
34
- def stderr_cache
35
- root_cache.child('stderr')
36
- end
37
-
38
31
  def to_s
39
32
  "#{gem}[#{name}]"
40
33
  end
41
34
 
42
35
  private
43
36
 
37
+ def logs_uncached
38
+ ::EacRubyUtils::Fs::Logs.new.add(:stdout).add(:stderr)
39
+ end
40
+
44
41
  def result_uncached
45
42
  return RESULT_NONEXISTENT unless elegible?
46
43
 
@@ -53,8 +50,8 @@ module EacRubyGemsUtils
53
50
 
54
51
  def exec_run_with_log
55
52
  r = exec_run
56
- stdout_cache.write(r[:stdout])
57
- stderr_cache.write(r[:stderr])
53
+ logs[:stdout].write(r[:stdout])
54
+ logs[:stderr].write(r[:stderr])
58
55
  r[:exit_code].zero?
59
56
  end
60
57
 
@@ -27,6 +27,12 @@ module EacRubyGemsUtils
27
27
  decorated_gems.flat_map(&:tests)
28
28
  end
29
29
 
30
+ def clear_logs
31
+ all_tests.each do |test|
32
+ test.logs.remove_all
33
+ end
34
+ end
35
+
30
36
  def prepare_all_gems
31
37
  infom 'Preparing all gems...'
32
38
  decorated_gems.each(&:prepare)
@@ -47,8 +53,7 @@ module EacRubyGemsUtils
47
53
  warn 'Some test did not pass:'
48
54
  failed_tests.each do |test|
49
55
  infov ' * Test', test
50
- infov ' * STDOUT', test.stdout_cache.content_path
51
- infov ' * STDERR', test.stderr_cache.content_path
56
+ info test.logs.truncate_all
52
57
  end
53
58
  else
54
59
  success 'All tests passed'
@@ -60,6 +65,8 @@ module EacRubyGemsUtils
60
65
  prepare_all_gems
61
66
  test_all_gems
62
67
  final_results_banner
68
+ ensure
69
+ clear_logs
63
70
  end
64
71
 
65
72
  def start_banner
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacRubyGemsUtils
4
- VERSION = '0.8.0'
4
+ VERSION = '0.9.0'
5
5
  end
@@ -19,6 +19,7 @@ Gem::Specification.new do |s|
19
19
  s.add_dependency 'addressable', '~> 2.6'
20
20
  s.add_dependency 'colorize', '~> 0.8.1'
21
21
  s.add_dependency 'docopt', '~> 0.6.1'
22
+ s.add_dependency 'filesize'
22
23
  s.add_dependency 'net-ssh', '~> 4.2'
23
24
  s.add_development_dependency 'eac_ruby_gem_support', '~> 0.1', '>= 0.1.1'
24
25
  end
@@ -0,0 +1,63 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'active_support/core_ext/string/filters'
4
+ require 'eac_ruby_utils/fs/temp'
5
+ require 'filesize'
6
+
7
+ module EacRubyUtils
8
+ module Fs
9
+ class Logs
10
+ TRUNCATE_DEFAULT_LENGTH = 1000
11
+ TRUNCATE_APPEND_TEXT = '(...) '
12
+
13
+ def [](label)
14
+ log_set.fetch(sanitize_label(label))
15
+ end
16
+
17
+ def add(label)
18
+ log_set[sanitize_label(label)] = ::EacRubyUtils::Fs::Temp.file
19
+
20
+ self
21
+ end
22
+
23
+ def remove_all
24
+ log_set.each_key { |label| remove(label) }
25
+
26
+ self
27
+ end
28
+
29
+ def remove(label)
30
+ log_set.fetch(sanitize_label(label)).remove
31
+ log_set.delete(sanitize_label(label))
32
+ end
33
+
34
+ def truncate(label, length = TRUNCATE_DEFAULT_LENGTH)
35
+ content = self[label].read.strip
36
+ return content if content.length <= TRUNCATE_DEFAULT_LENGTH
37
+
38
+ TRUNCATE_APPEND_TEXT + content[content.length - length + TRUNCATE_APPEND_TEXT.length,
39
+ length - TRUNCATE_APPEND_TEXT.length]
40
+ end
41
+
42
+ def truncate_all(length = TRUNCATE_DEFAULT_LENGTH)
43
+ s = "Files: #{log_set.length}\n"
44
+ log_set.each do |label, path|
45
+ x = truncate(label, length)
46
+ y = [label, path, ::Filesize.from("#{path.size} B").pretty].join(' / ')
47
+ s += x.blank? ? ">>> #{y} (Blank) <<<" : ">>> #{y}\n#{x}\n<<< #{y}\n"
48
+ end
49
+ s
50
+ end
51
+
52
+ private
53
+
54
+ def sanitize_label(label)
55
+ label.to_sym
56
+ end
57
+
58
+ def log_set
59
+ @log_set ||= {}
60
+ end
61
+ end
62
+ end
63
+ end
@@ -7,11 +7,19 @@ module EacRubyUtils
7
7
  class << self
8
8
  VARIABLE_NAME_PATTERN = /[_a-z][_a-z0-9]*/i.freeze
9
9
 
10
- def variableize(string)
10
+ # Convert a string to a variable format: first character as a lowercase letter or underscore
11
+ # and other as a lowercase letter, underscore or numbers.
12
+ # @param string [String] The source string.
13
+ # @param validate [Boolean] Affect the outcome when the result builded is not in a valid
14
+ # variable format. If `true`, it raises a {ArgumentError}. If `false`, return `nil`.
15
+ # @return [String, nil]
16
+ # @raise [ArgumentError]
17
+ def variableize(string, validate = true)
11
18
  r = ::ActiveSupport::Inflector.transliterate(string).gsub(/[^_a-z0-9]/i, '_')
12
19
  .gsub(/_+/, '_').gsub(/_\z/, '').gsub(/\A_/, '').downcase
13
20
  m = VARIABLE_NAME_PATTERN.match(r)
14
21
  return r if m
22
+ return nil unless validate
15
23
 
16
24
  raise ::ArgumentError, "Invalid variable name \"#{r}\" was generated " \
17
25
  "from string \"#{string}\""