avm-tools 0.116.0 → 0.117.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (143) hide show
  1. checksums.yaml +4 -4
  2. data/lib/avm/launcher/instances/settings.rb +7 -3
  3. data/lib/avm/projects/stereotypes.rb +2 -2
  4. data/lib/avm/ruby/bundler/incompatible_parser/depends_on.rb +1 -1
  5. data/lib/avm/ruby/bundler/incompatible_parser/gem_conflict.rb +1 -1
  6. data/lib/avm/ruby/bundler/incompatible_parser/in_gemfile.rb +1 -1
  7. data/lib/avm/ruby/bundler/incompatible_parser/version_requirement.rb +1 -1
  8. data/lib/avm/ruby/bundler/incompatible_parser.rb +1 -1
  9. data/lib/avm/tools/runner/app_src/ruby/bundler/gemfile_lock/git.rb +1 -1
  10. data/lib/avm/tools/runner/app_src/test.rb +2 -2
  11. data/lib/avm/tools/runner/app_src/version_bump.rb +4 -9
  12. data/lib/avm/tools/runner/git/deploy.rb +5 -5
  13. data/lib/avm/tools/runner/git/dirty_files.rb +1 -1
  14. data/lib/avm/tools/runner/git/revisions_test.rb +1 -1
  15. data/lib/avm/tools/runner/ruby/rubocop.rb +2 -2
  16. data/lib/avm/tools/version.rb +1 -1
  17. data/sub/avm/avm.gemspec +3 -3
  18. data/sub/avm/lib/avm/instances/base/auto_values/mailer.rb +2 -2
  19. data/sub/avm/lib/avm/instances/entry_keys.rb +2 -0
  20. data/sub/avm/lib/avm/registry/base.rb +2 -2
  21. data/sub/avm/lib/avm/rspec/shared_examples/not_in_avm_registry.rb +1 -1
  22. data/sub/avm/lib/avm/scms/base.rb +13 -0
  23. data/sub/avm/lib/avm/sources/base/configuration.rb +2 -1
  24. data/sub/avm/lib/avm/sources/base/parent.rb +31 -0
  25. data/sub/avm/lib/avm/sources/base.rb +4 -6
  26. data/sub/avm/lib/avm/sources/configuration/{_locale.rb → locale.rb} +5 -3
  27. data/sub/avm/lib/avm/sources/configuration/rubocop.rb +26 -0
  28. data/sub/avm/lib/avm/sources/configuration/tests.rb +29 -0
  29. data/sub/avm/lib/avm/sources/configuration.rb +5 -1
  30. data/sub/avm/lib/avm/sources/tests/builder.rb +1 -1
  31. data/sub/avm/lib/avm/version.rb +1 -1
  32. data/sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/sources/build/file.rb +1 -1
  33. data/sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/sources/build.rb +2 -2
  34. data/sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/sources/runner/build.rb +1 -1
  35. data/sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/sources/runner.rb +2 -2
  36. data/sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/version.rb +1 -1
  37. data/sub/avm-eac_generic_base0/avm-eac_generic_base0.gemspec +1 -1
  38. data/sub/avm-eac_generic_base0/lib/avm/eac_generic_base0/sources/base/version_bump.rb +35 -0
  39. data/sub/avm-eac_generic_base0/lib/avm/eac_generic_base0/sources/base.rb +4 -1
  40. data/sub/avm-eac_generic_base0/lib/avm/eac_generic_base0/version.rb +1 -1
  41. data/sub/avm-eac_generic_base0/locale/en.yaml +6 -0
  42. data/sub/avm-eac_generic_base0/locale/pt-BR.yaml +6 -0
  43. data/sub/avm-eac_rails_base1/avm-eac_rails_base1.gemspec +1 -1
  44. data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/version.rb +1 -1
  45. data/sub/avm-eac_rails_base1/template/avm/eac_rails_base1/systemd_unit/tasks_scheduler_command.sh +1 -1
  46. data/sub/avm-eac_redmine_base0/avm-eac_redmine_base0.gemspec +1 -1
  47. data/sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/core_update.rb +3 -3
  48. data/sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/instances/docker_image.rb +17 -2
  49. data/sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/version.rb +1 -1
  50. data/sub/avm-eac_redmine_base0/template/avm/eac_redmine_base0/instances/docker_image/Dockerfile.template +2 -8
  51. data/sub/avm-eac_redmine_base0/template/avm/eac_redmine_base0/instances/docker_image/Dockerfile_apache_setup +8 -0
  52. data/sub/avm-eac_redmine_base0/template/avm/eac_redmine_base0/instances/docker_image/start.sh.template +1 -1
  53. data/sub/avm-eac_ruby_base1/avm-eac_ruby_base1.gemspec +2 -2
  54. data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/rubocop/configured.rb +31 -0
  55. data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/rubocop/envvar.rb +17 -0
  56. data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/rubocop/gemfile.rb +41 -0
  57. data/{lib/avm/ruby → sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1}/rubocop.rb +2 -2
  58. data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/base/version_bump.rb +23 -0
  59. data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/base.rb +11 -0
  60. data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/tester.rb +1 -1
  61. data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/update/sub_update.rb +1 -1
  62. data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/update.rb +0 -1
  63. data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/version.rb +1 -1
  64. data/sub/avm-files/avm-files.gemspec +1 -1
  65. data/sub/avm-files/lib/avm/files/appendable.rb +1 -1
  66. data/sub/avm-files/lib/avm/files/formatter/formats/ruby.rb +2 -2
  67. data/sub/avm-files/lib/avm/files/version.rb +1 -1
  68. data/sub/avm-git/lib/avm/git/scms/git_subrepo.rb +1 -3
  69. data/sub/avm-git/lib/avm/git/version.rb +1 -1
  70. data/sub/eac_cli/eac_cli.gemspec +1 -1
  71. data/sub/eac_cli/lib/eac_cli/old_configs/entry_reader.rb +1 -1
  72. data/sub/eac_cli/lib/eac_cli/old_configs/read_entry_options.rb +1 -1
  73. data/sub/eac_cli/lib/eac_cli/parser.rb +2 -2
  74. data/sub/eac_cli/lib/eac_cli/runner_with/help/builder.rb +1 -1
  75. data/sub/eac_cli/lib/eac_cli/runner_with/subcommands.rb +4 -4
  76. data/sub/eac_cli/lib/eac_cli/runner_with_set.rb +2 -2
  77. data/sub/eac_cli/lib/eac_cli/version.rb +1 -1
  78. data/sub/eac_config/eac_config.gemspec +1 -1
  79. data/sub/eac_config/lib/eac_config/entry.rb +1 -1
  80. data/sub/eac_config/lib/eac_config/envvars_node/entry.rb +1 -1
  81. data/sub/eac_config/lib/eac_config/paths_hash/node.rb +1 -1
  82. data/sub/eac_config/lib/eac_config/version.rb +1 -1
  83. data/sub/eac_fs/eac_fs.gemspec +1 -1
  84. data/sub/eac_fs/lib/eac_fs/version.rb +1 -1
  85. data/sub/eac_git/eac_git.gemspec +1 -1
  86. data/sub/eac_git/lib/eac_git/local/remote.rb +2 -2
  87. data/sub/eac_git/lib/eac_git/local.rb +1 -1
  88. data/sub/eac_git/lib/eac_git/version.rb +1 -1
  89. data/sub/eac_rest/eac_rest.gemspec +1 -1
  90. data/sub/eac_rest/lib/eac_rest/api.rb +14 -3
  91. data/sub/eac_rest/lib/eac_rest/request.rb +22 -1
  92. data/sub/eac_rest/lib/eac_rest/response.rb +41 -1
  93. data/sub/eac_rest/lib/eac_rest/version.rb +1 -1
  94. data/sub/eac_ruby_base0/eac_ruby_base0.gemspec +1 -1
  95. data/sub/eac_ruby_base0/lib/eac_ruby_base0/application.rb +2 -2
  96. data/sub/eac_ruby_base0/lib/eac_ruby_base0/version.rb +1 -1
  97. data/sub/eac_ruby_gems_utils/eac_ruby_gems_utils.gemspec +1 -1
  98. data/sub/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/gem/version_file.rb +2 -2
  99. data/sub/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/version.rb +1 -1
  100. data/sub/eac_ruby_utils/eac_ruby_utils.gemspec +1 -1
  101. data/sub/eac_ruby_utils/lib/eac_ruby_utils/core_ext.rb +1 -0
  102. data/sub/eac_ruby_utils/lib/eac_ruby_utils/custom_format.rb +1 -1
  103. data/sub/eac_ruby_utils/lib/eac_ruby_utils/gems_registry/gem.rb +1 -1
  104. data/sub/eac_ruby_utils/lib/eac_ruby_utils/gems_registry.rb +1 -1
  105. data/sub/eac_ruby_utils/lib/eac_ruby_utils/inflector.rb +1 -1
  106. data/sub/eac_ruby_utils/lib/eac_ruby_utils/listable/list.rb +16 -4
  107. data/sub/eac_ruby_utils/lib/eac_ruby_utils/listable/value.rb +12 -2
  108. data/sub/eac_ruby_utils/lib/eac_ruby_utils/local_time_zone.rb +1 -1
  109. data/sub/eac_ruby_utils/lib/eac_ruby_utils/locales/from_all_gems.rb +4 -0
  110. data/sub/eac_ruby_utils/lib/eac_ruby_utils/locales/from_gem.rb +47 -0
  111. data/sub/eac_ruby_utils/lib/eac_ruby_utils/locales/module_i18n_translate.rb +74 -0
  112. data/sub/eac_ruby_utils/lib/eac_ruby_utils/locales.rb +9 -0
  113. data/sub/eac_ruby_utils/lib/eac_ruby_utils/method_class.rb +35 -0
  114. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/module/i18n_translate.rb +2 -25
  115. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/module/method_class.rb +9 -0
  116. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/object/debug.rb +6 -0
  117. data/sub/eac_ruby_utils/lib/eac_ruby_utils/require_sub.rb +86 -33
  118. data/sub/eac_ruby_utils/lib/eac_ruby_utils/ruby/on_clean_environment.rb +1 -1
  119. data/sub/eac_ruby_utils/lib/eac_ruby_utils/version.rb +1 -1
  120. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/fs/temp/{temp_spec.rb → directory_spec.rb} +0 -0
  121. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/fs/temp_spec.rb +4 -4
  122. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/listable_spec.rb +169 -106
  123. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/method_class_spec.rb +46 -0
  124. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/options_consumer_spec.rb +52 -17
  125. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/module/listable_spec.rb +5 -3
  126. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/module/method_class_spec.rb +20 -0
  127. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/module/simple_cache_spec.rb +5 -3
  128. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/require_sub_spec.rb +3 -3
  129. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/settings_provider_spec.rb +21 -18
  130. data/sub/eac_ruby_utils/spec/locales/pt-BR.yml +3 -0
  131. data/sub/eac_templates/eac_templates.gemspec +1 -1
  132. data/sub/eac_templates/lib/eac_templates/directory.rb +1 -1
  133. data/sub/eac_templates/lib/eac_templates/version.rb +1 -1
  134. metadata +42 -20
  135. data/lib/avm/projects/stereotypes/rails_application/update.rb +0 -14
  136. data/lib/avm/projects/stereotypes/ruby_gem/version_bump.rb +0 -60
  137. data/lib/avm/ruby/rubocop/_configured.rb +0 -29
  138. data/lib/avm/ruby/rubocop/_envvar.rb +0 -15
  139. data/lib/avm/ruby/rubocop/_gemfile.rb +0 -39
  140. data/sub/avm/lib/avm/sources/configuration/_rubocop.rb +0 -24
  141. data/sub/avm/lib/avm/sources/configuration/_tests.rb +0 -27
  142. data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/patches/i18n.rb +0 -7
  143. data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/patches.rb +0 -4
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'active_support/inflector'
4
+ require 'active_support/dependencies'
4
5
  require 'eac_ruby_utils/listable'
5
6
 
6
7
  module EacRubyUtils
@@ -11,6 +12,14 @@ module EacRubyUtils
11
12
  end
12
13
 
13
14
  class RequireSub
15
+ INCLUDE_MODULES_MAP = {
16
+ nil => nil,
17
+ false => nil,
18
+ true => :include,
19
+ include: :include,
20
+ prepend: :prepend
21
+ }.freeze
22
+
14
23
  include ::EacRubyUtils::Listable
15
24
  lists.add_symbol :option, :base, :include_modules, :require_dependency
16
25
 
@@ -26,56 +35,100 @@ module EacRubyUtils
26
35
  include_modules
27
36
  end
28
37
 
29
- private
38
+ def base
39
+ options[OPTION_BASE] || raise('Option :base not setted')
40
+ end
30
41
 
31
- def active_support_require(path)
32
- return false unless options[OPTION_REQUIRE_DEPENDENCY]
42
+ def base?
43
+ options[OPTION_BASE] ? true : false
44
+ end
33
45
 
34
- ::Kernel.require_dependency(path)
35
- true
46
+ def include_modules
47
+ sub_files.each(&:include_module)
36
48
  end
37
49
 
38
- def autoload_require(path)
39
- return false unless base?
50
+ def include_or_prepend_method
51
+ return INCLUDE_MODULES_MAP.fetch(options[OPTION_INCLUDE_MODULES]) if
52
+ INCLUDE_MODULES_MAP.key?(options[OPTION_INCLUDE_MODULES])
40
53
 
41
- basename = ::File.basename(path, '.*')
42
- return false if basename.start_with?('_')
54
+ raise ::ArgumentError, "Invalid value for 'options[OPTION_INCLUDE_MODULES]':" \
55
+ " \"#{options[OPTION_INCLUDE_MODULES]}\""
56
+ end
43
57
 
44
- base.autoload ::ActiveSupport::Inflector.camelize(basename), path
45
- true
58
+ def require_sub_files
59
+ sub_files.each(&:require_file)
46
60
  end
47
61
 
48
- def include_modules
49
- return unless options[OPTION_INCLUDE_MODULES]
62
+ def sub_files
63
+ @sub_files ||= Dir["#{File.dirname(file)}/#{::File.basename(file, '.*')}/*.rb"].sort
64
+ .map { |path| SubFile.new(self, path) }
65
+ end
50
66
 
51
- base.constants.each do |constant_name|
52
- constant = base.const_get(constant_name)
53
- next unless constant.is_a?(::Module) && !constant.is_a?(::Class)
67
+ class SubFile
68
+ attr_reader :owner, :path
54
69
 
55
- base.include(constant)
70
+ def initialize(owner, path)
71
+ @owner = owner
72
+ @path = path
56
73
  end
57
- end
58
74
 
59
- def base
60
- options[OPTION_BASE] || raise('Option :base not setted')
61
- end
75
+ def base_constant
76
+ return nil unless owner.base?
62
77
 
63
- def base?
64
- options[OPTION_BASE] ? true : false
65
- end
78
+ owner.base.const_get(constant_name)
79
+ rescue ::NameError
80
+ nil
81
+ end
66
82
 
67
- def kernel_require(path)
68
- ::Kernel.require(path)
69
- end
83
+ def constant_name
84
+ ::ActiveSupport::Inflector.camelize(::File.basename(path, '.rb'))
85
+ end
70
86
 
71
- def require_sub_files
72
- Dir["#{File.dirname(file)}/#{::File.basename(file, '.*')}/*.rb"].sort.each do |path|
73
- require_sub_file(path)
87
+ def include_module
88
+ return unless module?
89
+
90
+ owner.include_or_prepend_method.if_present do |v|
91
+ owner.base.send(v, base_constant)
92
+ end
93
+ end
94
+
95
+ def include_or_prepend_method
96
+ return :include if owner.options[OPTION_INCLUDE_MODULES]
97
+ return :prepend if owner.options[OPTION_PREPEND_MODULES]
98
+
99
+ nil
100
+ end
101
+
102
+ def module?
103
+ base_constant.is_a?(::Module) && !base_constant.is_a?(::Class)
104
+ end
105
+
106
+ def require_file
107
+ active_support_require || autoload_require || kernel_require
108
+ end
109
+
110
+ private
111
+
112
+ def active_support_require
113
+ return false unless owner.options[OPTION_REQUIRE_DEPENDENCY]
114
+
115
+ ::Kernel.require_dependency(path)
116
+ true
74
117
  end
75
- end
76
118
 
77
- def require_sub_file(path)
78
- active_support_require(path) || autoload_require(path) || kernel_require(path)
119
+ def autoload_require
120
+ return false unless owner.base?
121
+
122
+ basename = ::File.basename(path, '.*')
123
+ return false if basename.start_with?('_')
124
+
125
+ owner.base.autoload ::ActiveSupport::Inflector.camelize(basename), path
126
+ true
127
+ end
128
+
129
+ def kernel_require
130
+ ::Kernel.require(path)
131
+ end
79
132
  end
80
133
  end
81
134
  end
@@ -12,7 +12,7 @@ module EacRubyUtils
12
12
 
13
13
  def on_clean_envvars(*start_with_vars)
14
14
  old_values = envvars_starting_with(start_with_vars)
15
- old_values.keys.each { |k| ENV.delete(k) }
15
+ old_values.each_key { |k| ENV.delete(k) }
16
16
  yield
17
17
  ensure
18
18
  old_values&.each { |k, v| ENV[k] = v }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacRubyUtils
4
- VERSION = '0.92.1'
4
+ VERSION = '0.95.0'
5
5
  end
@@ -4,7 +4,7 @@ require 'eac_ruby_utils/fs/temp'
4
4
 
5
5
  RSpec.describe ::EacRubyUtils::Fs::Temp do
6
6
  describe '#on_file' do
7
- it do
7
+ it do # rubocop:disable RSpec/ExampleLength, RSpec/MultipleExpectations
8
8
  temp_path = nil
9
9
  described_class.on_file do |path|
10
10
  temp_path = path
@@ -15,7 +15,7 @@ RSpec.describe ::EacRubyUtils::Fs::Temp do
15
15
  expect(temp_path).not_to exist
16
16
  end
17
17
 
18
- it 'not fail if already removed' do
18
+ it 'not fail if already removed' do # rubocop:disable RSpec/ExampleLength, RSpec/MultipleExpectations
19
19
  temp_path = nil
20
20
  described_class.on_file do |path|
21
21
  temp_path = path
@@ -29,7 +29,7 @@ RSpec.describe ::EacRubyUtils::Fs::Temp do
29
29
  end
30
30
 
31
31
  describe '#on_directory' do
32
- it do
32
+ it do # rubocop:disable RSpec/ExampleLength, RSpec/MultipleExpectations
33
33
  temp_path = nil
34
34
  described_class.on_directory do |path|
35
35
  temp_path = path
@@ -38,7 +38,7 @@ RSpec.describe ::EacRubyUtils::Fs::Temp do
38
38
  expect(temp_path).not_to exist
39
39
  end
40
40
 
41
- it 'not fail if already removed' do
41
+ it 'not fail if already removed' do # rubocop:disable RSpec/ExampleLength, RSpec/MultipleExpectations
42
42
  temp_path = nil
43
43
  described_class.on_directory do |path|
44
44
  temp_path = path
@@ -2,199 +2,262 @@
2
2
 
3
3
  require 'eac_ruby_utils/listable'
4
4
 
5
- class Stub
6
- include ::EacRubyUtils::Listable
7
-
8
- attr_accessor :inteiro, :code, :cadeia, :type
9
-
10
- lists.add_integer :inteiro, :a, :b, :c
11
- lists.add_integer :code, 7 => :a, 13 => :b
12
- lists.add_string :cadeia, :a, :b, :c
13
- lists.add_string :type, 'Namespace::ClazzA' => :a, 'Namespace::ClazzB' => :b
14
- lists.add_symbol :simbolo, :a, :b, :c
15
- lists.add_symbol :tipado, :tipo_aaa => :a, 'tipo_bbb' => :b
16
- end
17
-
18
5
  RSpec.describe ::EacRubyUtils::Listable do
19
- context 'attribute values' do
20
- it { expect(Stub.lists.inteiro.values).to eq([1, 2, 3]) }
21
- it { expect(Stub.lists.code.values).to eq([7, 13]) }
22
- it { expect(Stub.lists.cadeia.values).to eq(%w[a b c]) }
23
- it { expect(Stub.lists.type.values).to eq(%w[Namespace::ClazzA Namespace::ClazzB]) }
24
- it { expect(Stub.lists.simbolo.values).to eq(%i[a b c]) }
25
- it { expect(Stub.lists.tipado.values).to eq(%i[tipo_aaa tipo_bbb]) }
6
+ let(:stub_class) do
7
+ the_described_class = described_class
8
+ ::Class.new do
9
+ class << self
10
+ def name
11
+ 'Stub'
12
+ end
13
+ end
14
+
15
+ include the_described_class
16
+
17
+ attr_accessor :inteiro, :code, :cadeia, :type
18
+
19
+ lists.add_integer :inteiro, :a, :b, :c
20
+ lists.add_integer :code, 7 => :a, 13 => :b
21
+ lists.add_string :cadeia, :a, :b, :c
22
+ lists.add_string :type, 'Namespace::ClazzA' => :a, 'Namespace::ClazzB' => :b
23
+ lists.add_symbol :simbolo, :a, :b, :c
24
+ lists.add_symbol :tipado, :tipo_aaa => :a, 'tipo_bbb' => :b
25
+ end
26
26
  end
27
27
 
28
- context 'value instance options' do
28
+ describe 'attribute values' do
29
+ it { expect(stub_class.lists.inteiro.values).to eq([1, 2, 3]) }
30
+ it { expect(stub_class.lists.code.values).to eq([7, 13]) }
31
+ it { expect(stub_class.lists.cadeia.values).to eq(%w[a b c]) }
32
+ it { expect(stub_class.lists.type.values).to eq(%w[Namespace::ClazzA Namespace::ClazzB]) }
33
+ it { expect(stub_class.lists.simbolo.values).to eq(%i[a b c]) }
34
+ it { expect(stub_class.lists.tipado.values).to eq(%i[tipo_aaa tipo_bbb]) }
35
+ end
36
+
37
+ describe 'value instance options' do
29
38
  it {
30
- expect(Stub.lists.inteiro.options)
39
+ expect(stub_class.lists.inteiro.options)
31
40
  .to eq([['Inteiro A', 1], ['Inteiro BB', 2], ['Inteiro CCC', 3]])
32
41
  }
33
42
 
34
43
  it {
35
- expect(Stub.lists.code.options)
44
+ expect(stub_class.lists.code.options)
36
45
  .to eq([['Código A', 7], ['Código B', 13]])
37
46
  }
38
47
 
39
48
  it {
40
- expect(Stub.lists.cadeia.options)
49
+ expect(stub_class.lists.cadeia.options)
41
50
  .to eq([['Cadeia AAA', 'a'], ['Cadeia BB', 'b'], ['Cadeia C', 'c']])
42
51
  }
43
52
 
44
53
  it {
45
- expect(Stub.lists.type.options)
54
+ expect(stub_class.lists.type.options)
46
55
  .to eq([['Tipo A', 'Namespace::ClazzA'], ['Tipo B', 'Namespace::ClazzB']])
47
56
  }
48
57
 
49
58
  it {
50
- expect(Stub.lists.simbolo.options)
59
+ expect(stub_class.lists.simbolo.options)
51
60
  .to eq([['Simbolo A', :a], ['Simbolo B', :b], ['Simbolo C', :c]])
52
61
  }
53
62
 
54
63
  it {
55
- expect(Stub.lists.tipado.options)
64
+ expect(stub_class.lists.tipado.options)
56
65
  .to eq([['Tipado A', :tipo_aaa], ['Tipado B', :tipo_bbb]])
57
66
  }
58
67
  end
59
68
 
60
- context 'constants' do
61
- it { expect(Stub::INTEIRO_A).to eq(1) }
62
- it { expect(Stub::INTEIRO_B).to eq(2) }
63
- it { expect(Stub::INTEIRO_C).to eq(3) }
64
- it { expect(Stub::CODE_A).to eq(7) }
65
- it { expect(Stub::CODE_B).to eq(13) }
66
- it { expect(Stub::CADEIA_A).to eq('a') }
67
- it { expect(Stub::CADEIA_C).to eq('c') }
68
- it { expect(Stub::TYPE_A).to eq('Namespace::ClazzA') }
69
- it { expect(Stub::TYPE_B).to eq('Namespace::ClazzB') }
70
- it { expect(Stub::SIMBOLO_A).to eq(:a) }
71
- it { expect(Stub::SIMBOLO_B).to eq(:b) }
72
- it { expect(Stub::SIMBOLO_C).to eq(:c) }
73
- it { expect(Stub::TIPADO_A).to eq(:tipo_aaa) }
74
- it { expect(Stub::TIPADO_B).to eq(:tipo_bbb) }
69
+ describe 'constants' do
70
+ it { expect(stub_class::INTEIRO_A).to eq(1) }
71
+ it { expect(stub_class::INTEIRO_B).to eq(2) }
72
+ it { expect(stub_class::INTEIRO_C).to eq(3) }
73
+ it { expect(stub_class::CODE_A).to eq(7) }
74
+ it { expect(stub_class::CODE_B).to eq(13) }
75
+ it { expect(stub_class::CADEIA_A).to eq('a') }
76
+ it { expect(stub_class::CADEIA_C).to eq('c') }
77
+ it { expect(stub_class::TYPE_A).to eq('Namespace::ClazzA') }
78
+ it { expect(stub_class::TYPE_B).to eq('Namespace::ClazzB') }
79
+ it { expect(stub_class::SIMBOLO_A).to eq(:a) }
80
+ it { expect(stub_class::SIMBOLO_B).to eq(:b) }
81
+ it { expect(stub_class::SIMBOLO_C).to eq(:c) }
82
+ it { expect(stub_class::TIPADO_A).to eq(:tipo_aaa) }
83
+ it { expect(stub_class::TIPADO_B).to eq(:tipo_bbb) }
75
84
  end
76
85
 
77
- context 'values instances' do
78
- it { expect(Stub.lists.is_a?(::EacRubyUtils::Listable::Lists)).to eq(true) }
79
- it { expect(Stub.lists.inteiro.value_a.is_a?(::EacRubyUtils::Listable::Value)).to eq(true) }
80
- it { expect(Stub.lists.inteiro.value_b.is_a?(::EacRubyUtils::Listable::Value)).to eq(true) }
81
- it { expect(Stub.lists.inteiro.value_c.is_a?(::EacRubyUtils::Listable::Value)).to eq(true) }
82
- it { expect(Stub.lists.code.value_a.is_a?(::EacRubyUtils::Listable::Value)).to eq(true) }
83
- it { expect(Stub.lists.code.value_b.is_a?(::EacRubyUtils::Listable::Value)).to eq(true) }
84
- it { expect(Stub.lists.cadeia.value_a.is_a?(::EacRubyUtils::Listable::Value)).to eq(true) }
85
- it { expect(Stub.lists.cadeia.value_b.is_a?(::EacRubyUtils::Listable::Value)).to eq(true) }
86
- it { expect(Stub.lists.cadeia.value_c.is_a?(::EacRubyUtils::Listable::Value)).to eq(true) }
87
- it { expect(Stub.lists.type.value_a.is_a?(::EacRubyUtils::Listable::Value)).to eq(true) }
88
- it { expect(Stub.lists.type.value_b.is_a?(::EacRubyUtils::Listable::Value)).to eq(true) }
86
+ describe 'values instances' do
87
+ it { expect(stub_class.lists.is_a?(::EacRubyUtils::Listable::Lists)).to eq(true) }
88
+
89
+ it {
90
+ expect(stub_class.lists.inteiro.value_a.is_a?(::EacRubyUtils::Listable::Value))
91
+ .to eq(true)
92
+ }
93
+
94
+ it {
95
+ expect(stub_class.lists.inteiro.value_b.is_a?(::EacRubyUtils::Listable::Value))
96
+ .to eq(true)
97
+ }
98
+
99
+ it {
100
+ expect(stub_class.lists.inteiro.value_c.is_a?(::EacRubyUtils::Listable::Value))
101
+ .to eq(true)
102
+ }
103
+
104
+ it {
105
+ expect(stub_class.lists.code.value_a.is_a?(::EacRubyUtils::Listable::Value))
106
+ .to eq(true)
107
+ }
108
+
109
+ it {
110
+ expect(stub_class.lists.code.value_b.is_a?(::EacRubyUtils::Listable::Value))
111
+ .to eq(true)
112
+ }
113
+
114
+ it {
115
+ expect(stub_class.lists.cadeia.value_a.is_a?(::EacRubyUtils::Listable::Value))
116
+ .to eq(true)
117
+ }
118
+
119
+ it {
120
+ expect(stub_class.lists.cadeia.value_b.is_a?(::EacRubyUtils::Listable::Value))
121
+ .to eq(true)
122
+ }
123
+
124
+ it {
125
+ expect(stub_class.lists.cadeia.value_c.is_a?(::EacRubyUtils::Listable::Value))
126
+ .to eq(true)
127
+ }
128
+
129
+ it {
130
+ expect(stub_class.lists.type.value_a.is_a?(::EacRubyUtils::Listable::Value))
131
+ .to eq(true)
132
+ }
133
+
134
+ it {
135
+ expect(stub_class.lists.type.value_b.is_a?(::EacRubyUtils::Listable::Value))
136
+ .to eq(true)
137
+ }
89
138
  end
90
139
 
91
- context 'value instance label' do
92
- it { expect(Stub.lists.inteiro.value_a.label).to eq('Inteiro A') }
93
- it { expect(Stub.lists.inteiro.value_b.label).to eq('Inteiro BB') }
94
- it { expect(Stub.lists.inteiro.value_c.label).to eq('Inteiro CCC') }
95
- it { expect(Stub.lists.code.value_a.label).to eq('Código A') }
96
- it { expect(Stub.lists.code.value_b.label).to eq('Código B') }
97
- it { expect(Stub.lists.cadeia.value_a.label).to eq('Cadeia AAA') }
98
- it { expect(Stub.lists.cadeia.value_b.label).to eq('Cadeia BB') }
99
- it { expect(Stub.lists.cadeia.value_c.label).to eq('Cadeia C') }
100
- it { expect(Stub.lists.type.value_a.label).to eq('Tipo A') }
101
- it { expect(Stub.lists.type.value_b.label).to eq('Tipo B') }
140
+ describe 'value instance label' do
141
+ it { expect(stub_class.lists.inteiro.value_a.label).to eq('Inteiro A') }
142
+ it { expect(stub_class.lists.inteiro.value_b.label).to eq('Inteiro BB') }
143
+ it { expect(stub_class.lists.inteiro.value_c.label).to eq('Inteiro CCC') }
144
+ it { expect(stub_class.lists.code.value_a.label).to eq('Código A') }
145
+ it { expect(stub_class.lists.code.value_b.label).to eq('Código B') }
146
+ it { expect(stub_class.lists.cadeia.value_a.label).to eq('Cadeia AAA') }
147
+ it { expect(stub_class.lists.cadeia.value_b.label).to eq('Cadeia BB') }
148
+ it { expect(stub_class.lists.cadeia.value_c.label).to eq('Cadeia C') }
149
+ it { expect(stub_class.lists.type.value_a.label).to eq('Tipo A') }
150
+ it { expect(stub_class.lists.type.value_b.label).to eq('Tipo B') }
102
151
  end
103
152
 
104
- context 'value instance description' do
105
- it { expect(Stub.lists.inteiro.value_a.description).to eq('Inteiro A Descr.') }
106
- it { expect(Stub.lists.inteiro.value_b.description).to eq('Inteiro BB Descr.') }
107
- it { expect(Stub.lists.inteiro.value_c.description).to eq('Inteiro CCC Descr.') }
108
- it { expect(Stub.lists.code.value_a.description).to eq('Código A Descr.') }
109
- it { expect(Stub.lists.code.value_b.description).to eq('Código B Descr.') }
110
- it { expect(Stub.lists.cadeia.value_a.description).to eq('Cadeia AAA Descr.') }
111
- it { expect(Stub.lists.cadeia.value_b.description).to eq('Cadeia BB Descr.') }
112
- it { expect(Stub.lists.cadeia.value_c.description).to eq('Cadeia C Descr.') }
113
- it { expect(Stub.lists.type.value_a.description).to eq('Tipo A Descr.') }
114
- it { expect(Stub.lists.type.value_b.description).to eq('Tipo B Descr.') }
153
+ describe 'value instance description' do
154
+ it { expect(stub_class.lists.inteiro.value_a.description).to eq('Inteiro A Descr.') }
155
+ it { expect(stub_class.lists.inteiro.value_b.description).to eq('Inteiro BB Descr.') }
156
+ it { expect(stub_class.lists.inteiro.value_c.description).to eq('Inteiro CCC Descr.') }
157
+ it { expect(stub_class.lists.code.value_a.description).to eq('Código A Descr.') }
158
+ it { expect(stub_class.lists.code.value_b.description).to eq('Código B Descr.') }
159
+ it { expect(stub_class.lists.cadeia.value_a.description).to eq('Cadeia AAA Descr.') }
160
+ it { expect(stub_class.lists.cadeia.value_b.description).to eq('Cadeia BB Descr.') }
161
+ it { expect(stub_class.lists.cadeia.value_c.description).to eq('Cadeia C Descr.') }
162
+ it { expect(stub_class.lists.type.value_a.description).to eq('Tipo A Descr.') }
163
+ it { expect(stub_class.lists.type.value_b.description).to eq('Tipo B Descr.') }
115
164
  end
116
165
 
117
- context 'value instance constant name' do
118
- it { expect(Stub.lists.inteiro.value_a.constant_name).to eq('INTEIRO_A') }
119
- it { expect(Stub.lists.inteiro.value_b.constant_name).to eq('INTEIRO_B') }
120
- it { expect(Stub.lists.inteiro.value_c.constant_name).to eq('INTEIRO_C') }
121
- it { expect(Stub.lists.code.value_a.constant_name).to eq('CODE_A') }
122
- it { expect(Stub.lists.code.value_b.constant_name).to eq('CODE_B') }
123
- it { expect(Stub.lists.cadeia.value_a.constant_name).to eq('CADEIA_A') }
124
- it { expect(Stub.lists.cadeia.value_b.constant_name).to eq('CADEIA_B') }
125
- it { expect(Stub.lists.cadeia.value_c.constant_name).to eq('CADEIA_C') }
126
- it { expect(Stub.lists.type.value_a.constant_name).to eq('TYPE_A') }
127
- it { expect(Stub.lists.type.value_b.constant_name).to eq('TYPE_B') }
166
+ describe 'value instance constant name' do
167
+ it { expect(stub_class.lists.inteiro.value_a.constant_name).to eq('INTEIRO_A') }
168
+ it { expect(stub_class.lists.inteiro.value_b.constant_name).to eq('INTEIRO_B') }
169
+ it { expect(stub_class.lists.inteiro.value_c.constant_name).to eq('INTEIRO_C') }
170
+ it { expect(stub_class.lists.code.value_a.constant_name).to eq('CODE_A') }
171
+ it { expect(stub_class.lists.code.value_b.constant_name).to eq('CODE_B') }
172
+ it { expect(stub_class.lists.cadeia.value_a.constant_name).to eq('CADEIA_A') }
173
+ it { expect(stub_class.lists.cadeia.value_b.constant_name).to eq('CADEIA_B') }
174
+ it { expect(stub_class.lists.cadeia.value_c.constant_name).to eq('CADEIA_C') }
175
+ it { expect(stub_class.lists.type.value_a.constant_name).to eq('TYPE_A') }
176
+ it { expect(stub_class.lists.type.value_b.constant_name).to eq('TYPE_B') }
128
177
  end
129
178
 
130
- context 'instance label and descriptions' do
131
- let(:instance) { Stub.new }
179
+ describe 'instance label and descriptions' do
180
+ let(:instance) { stub_class.new }
132
181
 
133
182
  context 'when inteiro value is A' do
134
- before { instance.inteiro = Stub::INTEIRO_A }
183
+ before { instance.inteiro = stub_class::INTEIRO_A }
135
184
 
136
185
  it { expect(instance.inteiro_label).to eq('Inteiro A') }
137
186
  it { expect(instance.inteiro_description).to eq('Inteiro A Descr.') }
138
187
  end
139
188
 
140
- context 'when inteiro value is A' do
141
- before { instance.inteiro = Stub::INTEIRO_B }
189
+ context 'when inteiro value is B' do
190
+ before { instance.inteiro = stub_class::INTEIRO_B }
142
191
 
143
192
  it { expect(instance.inteiro_label).to eq('Inteiro BB') }
144
193
  it { expect(instance.inteiro_description).to eq('Inteiro BB Descr.') }
145
194
  end
146
195
 
147
196
  context 'when inteiro value is C' do
148
- before { instance.inteiro = Stub::INTEIRO_C }
197
+ before { instance.inteiro = stub_class::INTEIRO_C }
149
198
 
150
199
  it { expect(instance.inteiro_label).to eq('Inteiro CCC') }
151
200
  it { expect(instance.inteiro_description).to eq('Inteiro CCC Descr.') }
152
201
  end
153
202
 
203
+ context 'when inteiro value is blank' do
204
+ before { instance.inteiro = nil }
205
+
206
+ it { expect(instance.inteiro_label).to eq('Inteiro em branco') }
207
+ it { expect(instance.inteiro_description).to eq('Inteiro em branco Descr.') }
208
+ end
209
+
154
210
  context 'when code value is A' do
155
- before { instance.code = Stub::CODE_A }
211
+ before { instance.code = stub_class::CODE_A }
156
212
 
157
213
  it { expect(instance.code_label).to eq('Código A') }
158
214
  it { expect(instance.code_description).to eq('Código A Descr.') }
159
215
  end
160
216
 
161
217
  context 'when code value is B' do
162
- before { instance.code = Stub::CODE_B }
218
+ before { instance.code = stub_class::CODE_B }
163
219
 
164
220
  it { expect(instance.code_label).to eq('Código B') }
165
221
  it { expect(instance.code_description).to eq('Código B Descr.') }
166
222
  end
167
223
 
224
+ context 'when code value is blank' do
225
+ before { instance.code = nil }
226
+
227
+ it { expect(instance.code_label).to eq('') }
228
+ it { expect(instance.code_description).to eq('') }
229
+ end
230
+
168
231
  context 'when cadeia value is A' do
169
- before { instance.cadeia = Stub::CADEIA_A }
232
+ before { instance.cadeia = stub_class::CADEIA_A }
170
233
 
171
234
  it { expect(instance.cadeia_label).to eq('Cadeia AAA') }
172
235
  it { expect(instance.cadeia_description).to eq('Cadeia AAA Descr.') }
173
236
  end
174
237
 
175
238
  context 'when cadeia value is B' do
176
- before { instance.cadeia = Stub::CADEIA_B }
239
+ before { instance.cadeia = stub_class::CADEIA_B }
177
240
 
178
241
  it { expect(instance.cadeia_label).to eq('Cadeia BB') }
179
242
  it { expect(instance.cadeia_description).to eq('Cadeia BB Descr.') }
180
243
  end
181
244
 
182
245
  context 'when cadeia value is C' do
183
- before { instance.cadeia = Stub::CADEIA_C }
246
+ before { instance.cadeia = stub_class::CADEIA_C }
184
247
 
185
248
  it { expect(instance.cadeia_label).to eq('Cadeia C') }
186
249
  it { expect(instance.cadeia_description).to eq('Cadeia C Descr.') }
187
250
  end
188
251
 
189
252
  context 'when type value is A' do
190
- before { instance.type = Stub::TYPE_A }
253
+ before { instance.type = stub_class::TYPE_A }
191
254
 
192
255
  it { expect(instance.type_label).to eq('Tipo A') }
193
256
  it { expect(instance.type_description).to eq('Tipo A Descr.') }
194
257
  end
195
258
 
196
259
  context 'when type value is B' do
197
- before { instance.type = Stub::TYPE_B }
260
+ before { instance.type = stub_class::TYPE_B }
198
261
 
199
262
  it { expect(instance.type_label).to eq('Tipo B') }
200
263
  it { expect(instance.type_description).to eq('Tipo B Descr.') }
@@ -202,11 +265,11 @@ RSpec.describe ::EacRubyUtils::Listable do
202
265
  end
203
266
 
204
267
  describe '#value_validate!' do
205
- it { expect { Stub.lists.inteiro.value_validate!(1) }.not_to raise_error }
206
- it { expect { Stub.lists.inteiro.value_validate!('1') }.to raise_error }
207
- it { expect { Stub.lists.inteiro.value_validate!(10) }.to raise_error(::StandardError) }
208
- it { expect { Stub.lists.cadeia.value_validate!(:a) }.to raise_error }
209
- it { expect { Stub.lists.cadeia.value_validate!('a') }.not_to raise_error }
210
- it { expect { Stub.lists.cadeia.value_validate!(:z) }.to raise_error(::StandardError) }
268
+ it { expect { stub_class.lists.inteiro.value_validate!(1) }.not_to raise_error }
269
+ it { expect { stub_class.lists.inteiro.value_validate!('1') }.to raise_error(::StandardError) }
270
+ it { expect { stub_class.lists.inteiro.value_validate!(10) }.to raise_error(::StandardError) }
271
+ it { expect { stub_class.lists.cadeia.value_validate!(:a) }.to raise_error(::StandardError) }
272
+ it { expect { stub_class.lists.cadeia.value_validate!('a') }.not_to raise_error }
273
+ it { expect { stub_class.lists.cadeia.value_validate!(:z) }.to raise_error(::StandardError) }
211
274
  end
212
275
  end
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/method_class'
4
+
5
+ ::RSpec.describe ::EacRubyUtils::MethodClass do
6
+ let(:sender_class) do
7
+ ::Class.new do
8
+ attr_accessor :sender_value
9
+
10
+ def initialize(sender_value)
11
+ self.sender_value = sender_value
12
+ end
13
+ end
14
+ end
15
+
16
+ let(:method_class) do
17
+ the_described_class = described_class
18
+ ::Class.new do
19
+ def self.name
20
+ 'TheSender::PerformX'
21
+ end
22
+
23
+ include the_described_class
24
+ attr_accessor :sender, :method_param
25
+
26
+ def initialize(sender, method_param)
27
+ self.sender = sender
28
+ self.method_param = method_param
29
+ end
30
+
31
+ def result
32
+ "#{sender.sender_value},#{method_param}"
33
+ end
34
+ end
35
+ end
36
+
37
+ let(:sender_instance) { sender_class.new('AAA') }
38
+
39
+ before do
40
+ ::Object.const_set('TheSender', sender_class)
41
+ sender_class.const_set('PerformX', method_class)
42
+ end
43
+
44
+ it { expect(sender_instance).to respond_to(:perform_x) }
45
+ it { expect(sender_instance.perform_x('BBB')).to eq('AAA,BBB') }
46
+ end