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.
- checksums.yaml +4 -4
- data/lib/avm/launcher/instances/settings.rb +7 -3
- data/lib/avm/projects/stereotypes.rb +2 -2
- data/lib/avm/ruby/bundler/incompatible_parser/depends_on.rb +1 -1
- data/lib/avm/ruby/bundler/incompatible_parser/gem_conflict.rb +1 -1
- data/lib/avm/ruby/bundler/incompatible_parser/in_gemfile.rb +1 -1
- data/lib/avm/ruby/bundler/incompatible_parser/version_requirement.rb +1 -1
- data/lib/avm/ruby/bundler/incompatible_parser.rb +1 -1
- data/lib/avm/tools/runner/app_src/ruby/bundler/gemfile_lock/git.rb +1 -1
- data/lib/avm/tools/runner/app_src/test.rb +2 -2
- data/lib/avm/tools/runner/app_src/version_bump.rb +4 -9
- data/lib/avm/tools/runner/git/deploy.rb +5 -5
- data/lib/avm/tools/runner/git/dirty_files.rb +1 -1
- data/lib/avm/tools/runner/git/revisions_test.rb +1 -1
- data/lib/avm/tools/runner/ruby/rubocop.rb +2 -2
- data/lib/avm/tools/version.rb +1 -1
- data/sub/avm/avm.gemspec +3 -3
- data/sub/avm/lib/avm/instances/base/auto_values/mailer.rb +2 -2
- data/sub/avm/lib/avm/instances/entry_keys.rb +2 -0
- data/sub/avm/lib/avm/registry/base.rb +2 -2
- data/sub/avm/lib/avm/rspec/shared_examples/not_in_avm_registry.rb +1 -1
- data/sub/avm/lib/avm/scms/base.rb +13 -0
- data/sub/avm/lib/avm/sources/base/configuration.rb +2 -1
- data/sub/avm/lib/avm/sources/base/parent.rb +31 -0
- data/sub/avm/lib/avm/sources/base.rb +4 -6
- data/sub/avm/lib/avm/sources/configuration/{_locale.rb → locale.rb} +5 -3
- data/sub/avm/lib/avm/sources/configuration/rubocop.rb +26 -0
- data/sub/avm/lib/avm/sources/configuration/tests.rb +29 -0
- data/sub/avm/lib/avm/sources/configuration.rb +5 -1
- data/sub/avm/lib/avm/sources/tests/builder.rb +1 -1
- data/sub/avm/lib/avm/version.rb +1 -1
- data/sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/sources/build/file.rb +1 -1
- data/sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/sources/build.rb +2 -2
- data/sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/sources/runner/build.rb +1 -1
- data/sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/sources/runner.rb +2 -2
- data/sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/version.rb +1 -1
- data/sub/avm-eac_generic_base0/avm-eac_generic_base0.gemspec +1 -1
- data/sub/avm-eac_generic_base0/lib/avm/eac_generic_base0/sources/base/version_bump.rb +35 -0
- data/sub/avm-eac_generic_base0/lib/avm/eac_generic_base0/sources/base.rb +4 -1
- data/sub/avm-eac_generic_base0/lib/avm/eac_generic_base0/version.rb +1 -1
- data/sub/avm-eac_generic_base0/locale/en.yaml +6 -0
- data/sub/avm-eac_generic_base0/locale/pt-BR.yaml +6 -0
- data/sub/avm-eac_rails_base1/avm-eac_rails_base1.gemspec +1 -1
- data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/version.rb +1 -1
- data/sub/avm-eac_rails_base1/template/avm/eac_rails_base1/systemd_unit/tasks_scheduler_command.sh +1 -1
- data/sub/avm-eac_redmine_base0/avm-eac_redmine_base0.gemspec +1 -1
- data/sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/core_update.rb +3 -3
- data/sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/instances/docker_image.rb +17 -2
- data/sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/version.rb +1 -1
- data/sub/avm-eac_redmine_base0/template/avm/eac_redmine_base0/instances/docker_image/Dockerfile.template +2 -8
- data/sub/avm-eac_redmine_base0/template/avm/eac_redmine_base0/instances/docker_image/Dockerfile_apache_setup +8 -0
- data/sub/avm-eac_redmine_base0/template/avm/eac_redmine_base0/instances/docker_image/start.sh.template +1 -1
- data/sub/avm-eac_ruby_base1/avm-eac_ruby_base1.gemspec +2 -2
- data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/rubocop/configured.rb +31 -0
- data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/rubocop/envvar.rb +17 -0
- data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/rubocop/gemfile.rb +41 -0
- data/{lib/avm/ruby → sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1}/rubocop.rb +2 -2
- data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/base/version_bump.rb +23 -0
- data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/base.rb +11 -0
- data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/tester.rb +1 -1
- data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/update/sub_update.rb +1 -1
- data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/update.rb +0 -1
- data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/version.rb +1 -1
- data/sub/avm-files/avm-files.gemspec +1 -1
- data/sub/avm-files/lib/avm/files/appendable.rb +1 -1
- data/sub/avm-files/lib/avm/files/formatter/formats/ruby.rb +2 -2
- data/sub/avm-files/lib/avm/files/version.rb +1 -1
- data/sub/avm-git/lib/avm/git/scms/git_subrepo.rb +1 -3
- data/sub/avm-git/lib/avm/git/version.rb +1 -1
- data/sub/eac_cli/eac_cli.gemspec +1 -1
- data/sub/eac_cli/lib/eac_cli/old_configs/entry_reader.rb +1 -1
- data/sub/eac_cli/lib/eac_cli/old_configs/read_entry_options.rb +1 -1
- data/sub/eac_cli/lib/eac_cli/parser.rb +2 -2
- data/sub/eac_cli/lib/eac_cli/runner_with/help/builder.rb +1 -1
- data/sub/eac_cli/lib/eac_cli/runner_with/subcommands.rb +4 -4
- data/sub/eac_cli/lib/eac_cli/runner_with_set.rb +2 -2
- data/sub/eac_cli/lib/eac_cli/version.rb +1 -1
- data/sub/eac_config/eac_config.gemspec +1 -1
- data/sub/eac_config/lib/eac_config/entry.rb +1 -1
- data/sub/eac_config/lib/eac_config/envvars_node/entry.rb +1 -1
- data/sub/eac_config/lib/eac_config/paths_hash/node.rb +1 -1
- data/sub/eac_config/lib/eac_config/version.rb +1 -1
- data/sub/eac_fs/eac_fs.gemspec +1 -1
- data/sub/eac_fs/lib/eac_fs/version.rb +1 -1
- data/sub/eac_git/eac_git.gemspec +1 -1
- data/sub/eac_git/lib/eac_git/local/remote.rb +2 -2
- data/sub/eac_git/lib/eac_git/local.rb +1 -1
- data/sub/eac_git/lib/eac_git/version.rb +1 -1
- data/sub/eac_rest/eac_rest.gemspec +1 -1
- data/sub/eac_rest/lib/eac_rest/api.rb +14 -3
- data/sub/eac_rest/lib/eac_rest/request.rb +22 -1
- data/sub/eac_rest/lib/eac_rest/response.rb +41 -1
- data/sub/eac_rest/lib/eac_rest/version.rb +1 -1
- data/sub/eac_ruby_base0/eac_ruby_base0.gemspec +1 -1
- data/sub/eac_ruby_base0/lib/eac_ruby_base0/application.rb +2 -2
- data/sub/eac_ruby_base0/lib/eac_ruby_base0/version.rb +1 -1
- data/sub/eac_ruby_gems_utils/eac_ruby_gems_utils.gemspec +1 -1
- data/sub/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/gem/version_file.rb +2 -2
- data/sub/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/version.rb +1 -1
- data/sub/eac_ruby_utils/eac_ruby_utils.gemspec +1 -1
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/core_ext.rb +1 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/custom_format.rb +1 -1
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/gems_registry/gem.rb +1 -1
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/gems_registry.rb +1 -1
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/inflector.rb +1 -1
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/listable/list.rb +16 -4
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/listable/value.rb +12 -2
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/local_time_zone.rb +1 -1
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/locales/from_all_gems.rb +4 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/locales/from_gem.rb +47 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/locales/module_i18n_translate.rb +74 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/locales.rb +9 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/method_class.rb +35 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/module/i18n_translate.rb +2 -25
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/module/method_class.rb +9 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/object/debug.rb +6 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/require_sub.rb +86 -33
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/ruby/on_clean_environment.rb +1 -1
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/version.rb +1 -1
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/fs/temp/{temp_spec.rb → directory_spec.rb} +0 -0
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/fs/temp_spec.rb +4 -4
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/listable_spec.rb +169 -106
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/method_class_spec.rb +46 -0
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/options_consumer_spec.rb +52 -17
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/module/listable_spec.rb +5 -3
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/module/method_class_spec.rb +20 -0
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/module/simple_cache_spec.rb +5 -3
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/require_sub_spec.rb +3 -3
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/settings_provider_spec.rb +21 -18
- data/sub/eac_ruby_utils/spec/locales/pt-BR.yml +3 -0
- data/sub/eac_templates/eac_templates.gemspec +1 -1
- data/sub/eac_templates/lib/eac_templates/directory.rb +1 -1
- data/sub/eac_templates/lib/eac_templates/version.rb +1 -1
- metadata +42 -20
- data/lib/avm/projects/stereotypes/rails_application/update.rb +0 -14
- data/lib/avm/projects/stereotypes/ruby_gem/version_bump.rb +0 -60
- data/lib/avm/ruby/rubocop/_configured.rb +0 -29
- data/lib/avm/ruby/rubocop/_envvar.rb +0 -15
- data/lib/avm/ruby/rubocop/_gemfile.rb +0 -39
- data/sub/avm/lib/avm/sources/configuration/_rubocop.rb +0 -24
- data/sub/avm/lib/avm/sources/configuration/_tests.rb +0 -27
- data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/patches/i18n.rb +0 -7
- 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
|
-
|
38
|
+
def base
|
39
|
+
options[OPTION_BASE] || raise('Option :base not setted')
|
40
|
+
end
|
30
41
|
|
31
|
-
def
|
32
|
-
|
42
|
+
def base?
|
43
|
+
options[OPTION_BASE] ? true : false
|
44
|
+
end
|
33
45
|
|
34
|
-
|
35
|
-
|
46
|
+
def include_modules
|
47
|
+
sub_files.each(&:include_module)
|
36
48
|
end
|
37
49
|
|
38
|
-
def
|
39
|
-
return
|
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
|
-
|
42
|
-
|
54
|
+
raise ::ArgumentError, "Invalid value for 'options[OPTION_INCLUDE_MODULES]':" \
|
55
|
+
" \"#{options[OPTION_INCLUDE_MODULES]}\""
|
56
|
+
end
|
43
57
|
|
44
|
-
|
45
|
-
|
58
|
+
def require_sub_files
|
59
|
+
sub_files.each(&:require_file)
|
46
60
|
end
|
47
61
|
|
48
|
-
def
|
49
|
-
|
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
|
-
|
52
|
-
|
53
|
-
next unless constant.is_a?(::Module) && !constant.is_a?(::Class)
|
67
|
+
class SubFile
|
68
|
+
attr_reader :owner, :path
|
54
69
|
|
55
|
-
|
70
|
+
def initialize(owner, path)
|
71
|
+
@owner = owner
|
72
|
+
@path = path
|
56
73
|
end
|
57
|
-
end
|
58
74
|
|
59
|
-
|
60
|
-
|
61
|
-
end
|
75
|
+
def base_constant
|
76
|
+
return nil unless owner.base?
|
62
77
|
|
63
|
-
|
64
|
-
|
65
|
-
|
78
|
+
owner.base.const_get(constant_name)
|
79
|
+
rescue ::NameError
|
80
|
+
nil
|
81
|
+
end
|
66
82
|
|
67
|
-
|
68
|
-
|
69
|
-
|
83
|
+
def constant_name
|
84
|
+
::ActiveSupport::Inflector.camelize(::File.basename(path, '.rb'))
|
85
|
+
end
|
70
86
|
|
71
|
-
|
72
|
-
|
73
|
-
|
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
|
-
|
78
|
-
|
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.
|
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 }
|
File without changes
|
@@ -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
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
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
|
-
|
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(
|
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(
|
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(
|
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(
|
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(
|
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(
|
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
|
-
|
61
|
-
it { expect(
|
62
|
-
it { expect(
|
63
|
-
it { expect(
|
64
|
-
it { expect(
|
65
|
-
it { expect(
|
66
|
-
it { expect(
|
67
|
-
it { expect(
|
68
|
-
it { expect(
|
69
|
-
it { expect(
|
70
|
-
it { expect(
|
71
|
-
it { expect(
|
72
|
-
it { expect(
|
73
|
-
it { expect(
|
74
|
-
it { expect(
|
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
|
-
|
78
|
-
it { expect(
|
79
|
-
|
80
|
-
it {
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
it {
|
86
|
-
|
87
|
-
|
88
|
-
|
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
|
-
|
92
|
-
it { expect(
|
93
|
-
it { expect(
|
94
|
-
it { expect(
|
95
|
-
it { expect(
|
96
|
-
it { expect(
|
97
|
-
it { expect(
|
98
|
-
it { expect(
|
99
|
-
it { expect(
|
100
|
-
it { expect(
|
101
|
-
it { expect(
|
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
|
-
|
105
|
-
it { expect(
|
106
|
-
it { expect(
|
107
|
-
it { expect(
|
108
|
-
it { expect(
|
109
|
-
it { expect(
|
110
|
-
it { expect(
|
111
|
-
it { expect(
|
112
|
-
it { expect(
|
113
|
-
it { expect(
|
114
|
-
it { expect(
|
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
|
-
|
118
|
-
it { expect(
|
119
|
-
it { expect(
|
120
|
-
it { expect(
|
121
|
-
it { expect(
|
122
|
-
it { expect(
|
123
|
-
it { expect(
|
124
|
-
it { expect(
|
125
|
-
it { expect(
|
126
|
-
it { expect(
|
127
|
-
it { expect(
|
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
|
-
|
131
|
-
let(:instance) {
|
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 =
|
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
|
141
|
-
before { instance.inteiro =
|
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 =
|
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 =
|
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 =
|
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 =
|
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 =
|
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 =
|
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 =
|
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 =
|
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 {
|
206
|
-
it { expect {
|
207
|
-
it { expect {
|
208
|
-
it { expect {
|
209
|
-
it { expect {
|
210
|
-
it { expect {
|
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
|