avm-tools 0.94.2 → 0.94.3

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 (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
@@ -54,8 +54,9 @@ module EacRubyUtils
54
54
  end
55
55
 
56
56
  def value_validate!(value, error_class = ::StandardError)
57
- value_valid?(value) ||
58
- raise(error_class, "Invalid value: \"#{value}\" (Valid: #{values_to_s})")
57
+ return value if value_valid?(value)
58
+
59
+ raise(error_class, "Invalid value: \"#{value}\" (Valid: #{values_to_s})")
59
60
  end
60
61
 
61
62
  def values_to_s
@@ -2,7 +2,9 @@
2
2
 
3
3
  module Kernel
4
4
  # Raise exception with text "Not yet implemented".
5
- def nyi
6
- raise "Not yet implemented (Called in #{caller.first})"
5
+ def nyi(message = nil)
6
+ s = "Not yet implemented (Called in #{caller.first})"
7
+ s += ": #{message}" if message
8
+ raise s
7
9
  end
8
10
  end
@@ -3,7 +3,9 @@
3
3
  require 'eac_ruby_utils/inflector'
4
4
 
5
5
  class String
6
- def variableize
7
- ::EacRubyUtils::Inflector.variableize(self)
6
+ # Shortcut to `EacRubyUtils::Inflector.variableize(self, ...)`.
7
+ # @see EacRubyUtils::Inflector.variableize
8
+ def variableize(validate = true)
9
+ ::EacRubyUtils::Inflector.variableize(self, validate)
8
10
  end
9
11
  end
@@ -1,15 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'active_support/core_ext/string/inflections'
4
- require 'eac_ruby_utils/options_consumer'
3
+ require 'eac_ruby_utils/require_sub'
5
4
 
6
5
  module EacRubyUtils
7
6
  # Provide a option by constant, method or options object.
8
7
  module SettingsProvider
8
+ ::EacRubyUtils.require_sub __FILE__, base: self
9
+
9
10
  def setting_constant_name(key, fullname = false)
10
- name = key.to_s.underscore.upcase
11
- name = "#{self.class.name}::#{name}" if fullname
12
- name
11
+ setting_value_instance(key).constant_name(fullname)
13
12
  end
14
13
 
15
14
  def setting_search_order
@@ -25,41 +24,23 @@ module EacRubyUtils
25
24
  end
26
25
 
27
26
  def setting_value(key, options = {})
28
- options = parse_setting_value_options(options)
29
- options.order.each do |method|
30
- value = send("setting_value_by_#{method}", key)
31
- return value if value
32
- end
33
- return nil unless options.required
34
-
35
- raise "Setting \"#{key}\" not found. Supply in #{settings_object_name}, implement a " \
36
- "\"#{key}\" method or declare a #{setting_constant_name(key, true)} constant."
27
+ setting_value_instance(key, options).value
37
28
  end
38
29
 
39
30
  def setting_value_by_constant(key)
40
- constant_name = setting_constant_name(key)
41
- begin
42
- self.class.const_get(constant_name)
43
- rescue NameError
44
- nil
45
- end
31
+ setting_value_instance(key).value_by_constant
46
32
  end
47
33
 
48
34
  def setting_value_by_method(key)
49
- respond_to?(key) ? send(key) : nil
35
+ setting_value_instance(key).value_by_method
50
36
  end
51
37
 
52
38
  def setting_value_by_settings_object(key)
53
- settings_object[key.to_s] || settings_object[key.to_sym]
39
+ setting_value_instance(key).value_by_settings_object
54
40
  end
55
41
 
56
- private
57
-
58
- def parse_setting_value_options(options)
59
- r = ::EacRubyUtils::OptionsConsumer.new(options).consume_all(:required, :order, ostruct: true)
60
- r.required = true if r.required.nil?
61
- r.order = setting_search_order if r.order.nil?
62
- r
42
+ def setting_value_instance(key, options = {})
43
+ ::EacRubyUtils::SettingsProvider::SettingValue.new(self, key, options)
63
44
  end
64
45
  end
65
46
  end
@@ -0,0 +1,69 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'active_support/core_ext/string/inflections'
4
+ require 'eac_ruby_utils/listable'
5
+ require 'eac_ruby_utils/simple_cache'
6
+ require 'eac_ruby_utils/struct'
7
+
8
+ module EacRubyUtils
9
+ module SettingsProvider
10
+ class SettingValue
11
+ include ::EacRubyUtils::Listable
12
+ include ::EacRubyUtils::SimpleCache
13
+
14
+ attr_reader :source, :key, :options
15
+ lists.add_symbol :option, :default, :order, :required
16
+
17
+ def initialize(source, key, options)
18
+ @source = source
19
+ @key = key
20
+ @options = options
21
+ end
22
+
23
+ def constant_name(fullname = false)
24
+ name = key.to_s.underscore.upcase
25
+ name = "#{source.class.name}::#{name}" if fullname
26
+ name
27
+ end
28
+
29
+ def value
30
+ parsed_options.order.each do |method|
31
+ value = send("value_by_#{method}")
32
+ return value if value
33
+ end
34
+ return parsed_options.default if parsed_options.respond_to?(OPTION_DEFAULT)
35
+ return nil unless parsed_options.required
36
+
37
+ raise_key_not_found
38
+ end
39
+
40
+ def value_by_constant
41
+ source.class.const_get(constant_name)
42
+ rescue NameError
43
+ nil
44
+ end
45
+
46
+ def value_by_method
47
+ source.respond_to?(key, true) ? source.send(key) : nil
48
+ end
49
+
50
+ def value_by_settings_object
51
+ source.settings_object[key.to_s] || source.settings_object[key.to_sym]
52
+ end
53
+
54
+ private
55
+
56
+ def parsed_options_uncached
57
+ r = self.class.lists.option.hash_keys_validate!(options.symbolize_keys)
58
+ r[:required] = true unless r.key?(OPTION_REQUIRED)
59
+ r[:order] = source.setting_search_order if r[OPTION_ORDER].nil?
60
+ ::EacRubyUtils::Struct.new(r)
61
+ end
62
+
63
+ def raise_key_not_found
64
+ raise "Setting \"#{key}\" not found. Supply in #{source.settings_object_name}, implement "\
65
+ "a \"#{key}\" method or declare a #{constant_name(true)} constant."
66
+ end
67
+ end
68
+ end
69
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacRubyUtils
4
- VERSION = '0.59.0'
4
+ VERSION = '0.62.0'
5
5
  end
@@ -42,5 +42,13 @@ RSpec.describe ::EacRubyUtils::SettingsProvider do
42
42
  it do
43
43
  expect(stub.setting_value('key_e', required: false)).to eq(nil)
44
44
  end
45
+
46
+ it do
47
+ expect(stub.setting_value('key_e', default: nil)).to eq(nil)
48
+ end
49
+
50
+ it do
51
+ expect(stub.setting_value('key_e', default: 'default_e')).to eq('default_e')
52
+ end
45
53
  end
46
54
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: avm-tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.94.2
4
+ version: 0.94.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Esquilo Azul Company
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-02-25 00:00:00.000000000 Z
11
+ date: 2021-04-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aranha-parsers
@@ -354,6 +354,7 @@ files:
354
354
  - lib/avm/eac_webapp_base0/deploy/version.rb
355
355
  - lib/avm/eac_webapp_base0/deploy/write_on_target.rb
356
356
  - lib/avm/eac_webapp_base0/instance.rb
357
+ - lib/avm/eac_webapp_base0/instance/subcommand_parent.rb
357
358
  - lib/avm/eac_webapp_base0/runner.rb
358
359
  - lib/avm/eac_webapp_base0/runner/apache_host.rb
359
360
  - lib/avm/eac_webapp_base0/runner/apache_path.rb
@@ -437,7 +438,6 @@ files:
437
438
  - lib/avm/git/organize/reference_update.rb
438
439
  - lib/avm/git/organize/repository.rb
439
440
  - lib/avm/git/revision_test.rb
440
- - lib/avm/git/spec_helper.rb
441
441
  - lib/avm/git/subrepo_check.rb
442
442
  - lib/avm/git/subrepo_check/parent.rb
443
443
  - lib/avm/git/subrepo_check/remote.rb
@@ -688,7 +688,6 @@ files:
688
688
  - vendor/eac_cli/lib/eac_cli/runner/instance_methods.rb
689
689
  - vendor/eac_cli/lib/eac_cli/runner_with.rb
690
690
  - vendor/eac_cli/lib/eac_cli/runner_with/help.rb
691
- - vendor/eac_cli/lib/eac_cli/runner_with/output_file.rb
692
691
  - vendor/eac_cli/lib/eac_cli/runner_with/subcommands.rb
693
692
  - vendor/eac_cli/lib/eac_cli/runner_with_set.rb
694
693
  - vendor/eac_cli/lib/eac_cli/version.rb
@@ -697,7 +696,6 @@ files:
697
696
  - vendor/eac_cli/spec/lib/eac_cli/parser/alternative_spec.rb
698
697
  - vendor/eac_cli/spec/lib/eac_cli/runner_spec.rb
699
698
  - vendor/eac_cli/spec/lib/eac_cli/runner_with/help_spec.rb
700
- - vendor/eac_cli/spec/lib/eac_cli/runner_with/output_file_spec.rb
701
699
  - vendor/eac_cli/spec/lib/eac_cli/runner_with/subcommands_spec.rb
702
700
  - vendor/eac_cli/spec/rubocop_spec.rb
703
701
  - vendor/eac_cli/spec/spec_helper.rb
@@ -726,14 +724,30 @@ files:
726
724
  - vendor/eac_git/lib/eac_git.rb
727
725
  - vendor/eac_git/lib/eac_git/executables.rb
728
726
  - vendor/eac_git/lib/eac_git/local.rb
727
+ - vendor/eac_git/lib/eac_git/local/commit.rb
728
+ - vendor/eac_git/lib/eac_git/local/commit/changed_file.rb
729
+ - vendor/eac_git/lib/eac_git/local/commit/diff_tree_line.rb
729
730
  - vendor/eac_git/lib/eac_git/local/dirty_files.rb
730
731
  - vendor/eac_git/lib/eac_git/local/subrepo.rb
731
732
  - vendor/eac_git/lib/eac_git/local/subrepo/config.rb
732
733
  - vendor/eac_git/lib/eac_git/remote.rb
733
734
  - vendor/eac_git/lib/eac_git/remote/ls_result.rb
734
735
  - vendor/eac_git/lib/eac_git/rspec.rb
736
+ - vendor/eac_git/lib/eac_git/rspec/stubbed_git_local_repo.rb
735
737
  - vendor/eac_git/lib/eac_git/version.rb
736
738
  - vendor/eac_git/spec/lib/eac_git/executables_spec.rb
739
+ - vendor/eac_git/spec/lib/eac_git/local/commit/diff_tree_line_spec.rb
740
+ - vendor/eac_git/spec/lib/eac_git/local/commit/diff_tree_line_spec_files/add.source.out
741
+ - vendor/eac_git/spec/lib/eac_git/local/commit/diff_tree_line_spec_files/add.target.yaml
742
+ - vendor/eac_git/spec/lib/eac_git/local/commit/diff_tree_line_spec_files/modify.source.out
743
+ - vendor/eac_git/spec/lib/eac_git/local/commit/diff_tree_line_spec_files/modify.target.yaml
744
+ - vendor/eac_git/spec/lib/eac_git/local/commit/diff_tree_line_spec_files/remove.source.out
745
+ - vendor/eac_git/spec/lib/eac_git/local/commit/diff_tree_line_spec_files/remove.target.yaml
746
+ - vendor/eac_git/spec/lib/eac_git/local/commit/diff_tree_line_spec_files/rename.source.out
747
+ - vendor/eac_git/spec/lib/eac_git/local/commit/diff_tree_line_spec_files/rename.target.yaml
748
+ - vendor/eac_git/spec/lib/eac_git/local/commit/diff_tree_line_spec_files/rename_modify.source.out
749
+ - vendor/eac_git/spec/lib/eac_git/local/commit/diff_tree_line_spec_files/rename_modify.target.yaml
750
+ - vendor/eac_git/spec/lib/eac_git/local/commit_spec.rb
737
751
  - vendor/eac_git/spec/rubocop_spec.rb
738
752
  - vendor/eac_git/spec/spec_helper.rb
739
753
  - vendor/eac_git/vendor/git-subrepo/Changes
@@ -937,8 +951,10 @@ files:
937
951
  - vendor/eac_ruby_base0/lib/eac_ruby_base0/runner_with.rb
938
952
  - vendor/eac_ruby_base0/lib/eac_ruby_base0/runner_with/confirmation.rb
939
953
  - vendor/eac_ruby_base0/lib/eac_ruby_base0/runner_with/filesystem_traverser.rb
954
+ - vendor/eac_ruby_base0/lib/eac_ruby_base0/runner_with/output.rb
940
955
  - vendor/eac_ruby_base0/lib/eac_ruby_base0/version.rb
941
956
  - vendor/eac_ruby_base0/spec/lib/eac_ruby_base0/runner_with/confirmation_spec.rb
957
+ - vendor/eac_ruby_base0/spec/lib/eac_ruby_base0/runner_with/output_spec.rb
942
958
  - vendor/eac_ruby_base0/spec/rubocop_spec.rb
943
959
  - vendor/eac_ruby_base0/spec/spec_helper.rb
944
960
  - vendor/eac_ruby_gems_utils/Gemfile
@@ -1028,6 +1044,7 @@ files:
1028
1044
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/fs.rb
1029
1045
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/fs/clearable_directory.rb
1030
1046
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/fs/extname.rb
1047
+ - vendor/eac_ruby_utils/lib/eac_ruby_utils/fs/logs.rb
1031
1048
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/fs/temp.rb
1032
1049
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/fs/temp/directory.rb
1033
1050
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/fs/temp/file.rb
@@ -1108,6 +1125,7 @@ files:
1108
1125
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/ruby/command.rb
1109
1126
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/ruby/on_clean_environment.rb
1110
1127
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/settings_provider.rb
1128
+ - vendor/eac_ruby_utils/lib/eac_ruby_utils/settings_provider/setting_value.rb
1111
1129
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/simple_cache.rb
1112
1130
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/struct.rb
1113
1131
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/templates.rb
@@ -1191,7 +1209,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
1191
1209
  - !ruby/object:Gem::Version
1192
1210
  version: '0'
1193
1211
  requirements: []
1194
- rubygems_version: 3.0.8
1212
+ rubygems_version: 3.0.9
1195
1213
  signing_key:
1196
1214
  specification_version: 4
1197
1215
  summary: Tools for AVM.
@@ -1,30 +0,0 @@
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 EacCli
8
- module RunnerWith
9
- module OutputFile
10
- common_concern do
11
- include ::EacCli::Runner
12
- include ::EacRubyUtils::AbstractMethods
13
-
14
- abstract_methods :output_content
15
-
16
- runner_definition do
17
- arg_opt '-o', '--output-file', 'Output to file.'
18
- end
19
- end
20
-
21
- def run_output
22
- if parsed.output_file.present?
23
- ::File.write(parsed.output_file, output_content)
24
- else
25
- $stdout.write(output_content)
26
- end
27
- end
28
- end
29
- end
30
- end
@@ -1,53 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_cli/runner_with/output_file'
4
- require 'eac_ruby_utils/fs/temp'
5
-
6
- RSpec.describe ::EacCli::RunnerWith::OutputFile 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 root runner.'
14
- pos_arg :input_text
15
- end
16
-
17
- def run
18
- run_output
19
- end
20
-
21
- def output_content
22
- parsed.input_text
23
- end
24
- end
25
- end
26
-
27
- let(:stub_text) { 'STUB_TEXT' }
28
- let(:instance) { runner.create(argv: runner_argv) }
29
-
30
- context 'without --output-file option' do
31
- let(:runner_argv) { [stub_text] }
32
-
33
- it do
34
- expect { instance.run }.to output(stub_text).to_stdout_from_any_process
35
- end
36
- end
37
-
38
- context 'with --output-file option' do
39
- let(:output_file) { ::EacRubyUtils::Fs::Temp.file }
40
- let(:runner_argv) { ['--output-file', output_file.to_path, stub_text] }
41
-
42
- before do
43
- instance.run
44
- end
45
-
46
- after do
47
- output_file.remove
48
- end
49
-
50
- it { expect(output_file).to exist }
51
- it { expect(output_file.read).to eq(stub_text) }
52
- end
53
- end