eac_tools 0.24.1 → 0.25.0
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.
- checksums.yaml +4 -4
- data/Gemfile.lock +10 -10
- data/lib/eac_tools/version.rb +1 -1
- data/sub/avm/avm.gemspec +1 -1
- data/sub/avm/lib/avm/entries/base/inherited_entry_value.rb +31 -0
- data/sub/avm/lib/avm/entries/base/uri_component_entry_value.rb +24 -8
- data/sub/avm/lib/avm/entries/base.rb +0 -10
- data/sub/avm/lib/avm/instances/base/auto_values/filesystem.rb +0 -5
- data/sub/avm/lib/avm/instances/base/auto_values/install.rb +18 -5
- data/sub/avm/lib/avm/instances/entry_keys.rb +2 -2
- data/sub/avm/lib/avm/version.rb +1 -1
- data/sub/avm/spec/lib/avm/instances/base_spec.rb +1 -1
- data/sub/avm/spec/lib/avm/instances/base_spec_configs_storage.yml +1 -1
- data/sub/avm-eac_webapp_base0/avm-eac_webapp_base0.gemspec +2 -2
- data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/deploy/file_unit.rb +1 -1
- data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/version.rb +1 -1
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/common_constructor/class_accessors.rb +36 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/common_constructor/class_initialize.rb +14 -4
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/common_constructor/instance_initialize.rb +15 -4
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/common_constructor.rb +20 -15
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/version.rb +1 -1
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/common_constructor_spec.rb +26 -0
- metadata +14 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b50382fd923923ea176726318a5adeed1194cdc1aac56b3d70c2211a030d2e86
|
|
4
|
+
data.tar.gz: f35a6fe715fc7d265f046e3692201a8edbab95e16cc324942956ab31804bff0d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8495da6e5565b3b03901d8c11a4f5bfe1d08fbe02cfafed82d59c4d33c69e92a43f8042e78e29ac32416eeed25250ab46088e9ca21193e0a912db82c2987c3ef
|
|
7
|
+
data.tar.gz: 81f4b76062b762acd52c63f9b4ec03bbb8e7d599032d7235ea24f2f291001664c3674fbb4db74d0e8f31783e36760f7a59427e1893d38ad087eaa34b24d87b29
|
data/Gemfile.lock
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
eac_tools (0.
|
|
5
|
-
avm (~> 0.
|
|
4
|
+
eac_tools (0.25.0)
|
|
5
|
+
avm (~> 0.39)
|
|
6
6
|
avm-eac_asciidoctor_base0 (~> 0.5)
|
|
7
7
|
avm-eac_generic_base0 (~> 0.5)
|
|
8
8
|
avm-eac_latex_base0 (~> 0.1, >= 0.1.2)
|
|
@@ -11,10 +11,10 @@ PATH
|
|
|
11
11
|
avm-eac_redmine_base0 (~> 0.12)
|
|
12
12
|
avm-eac_redmine_plugin_base0 (~> 0.3)
|
|
13
13
|
avm-eac_ruby_base1 (~> 0.19, >= 0.19.1)
|
|
14
|
-
avm-eac_webapp_base0 (~> 0.4)
|
|
14
|
+
avm-eac_webapp_base0 (~> 0.4, >= 0.4.1)
|
|
15
15
|
avm-eac_wordpress_base0 (~> 0.1, >= 0.1.2)
|
|
16
16
|
avm-tools (~> 0.133)
|
|
17
|
-
eac_ruby_utils (~> 0.
|
|
17
|
+
eac_ruby_utils (~> 0.101)
|
|
18
18
|
|
|
19
19
|
PATH
|
|
20
20
|
remote: sub/avm-eac_asciidoctor_base0
|
|
@@ -88,12 +88,12 @@ PATH
|
|
|
88
88
|
PATH
|
|
89
89
|
remote: sub/avm-eac_webapp_base0
|
|
90
90
|
specs:
|
|
91
|
-
avm-eac_webapp_base0 (0.4.
|
|
92
|
-
avm (~> 0.
|
|
91
|
+
avm-eac_webapp_base0 (0.4.1)
|
|
92
|
+
avm (~> 0.39)
|
|
93
93
|
avm-eac_generic_base0 (~> 0.5)
|
|
94
94
|
avm-eac_postgresql_base0 (~> 0.2)
|
|
95
95
|
avm-eac_ubuntu_base0 (~> 0.3)
|
|
96
|
-
eac_ruby_utils (~> 0.
|
|
96
|
+
eac_ruby_utils (~> 0.101)
|
|
97
97
|
|
|
98
98
|
PATH
|
|
99
99
|
remote: sub/avm-eac_wordpress_base0
|
|
@@ -124,12 +124,12 @@ PATH
|
|
|
124
124
|
PATH
|
|
125
125
|
remote: sub/avm
|
|
126
126
|
specs:
|
|
127
|
-
avm (0.
|
|
127
|
+
avm (0.39.0)
|
|
128
128
|
eac_cli (~> 0.27, >= 0.27.8)
|
|
129
129
|
eac_config (~> 0.11)
|
|
130
130
|
eac_docker (~> 0.4, >= 0.4.2)
|
|
131
131
|
eac_git (~> 0.12, >= 0.12.2)
|
|
132
|
-
eac_ruby_utils (~> 0.
|
|
132
|
+
eac_ruby_utils (~> 0.101)
|
|
133
133
|
eac_templates (~> 0.3, >= 0.3.1)
|
|
134
134
|
filesize (~> 0.2)
|
|
135
135
|
htmlbeautifier (~> 1.4, >= 1.4.2)
|
|
@@ -177,7 +177,7 @@ PATH
|
|
|
177
177
|
PATH
|
|
178
178
|
remote: sub/eac_ruby_utils
|
|
179
179
|
specs:
|
|
180
|
-
eac_ruby_utils (0.
|
|
180
|
+
eac_ruby_utils (0.101.0)
|
|
181
181
|
activesupport (>= 4, < 7)
|
|
182
182
|
addressable (~> 2.6)
|
|
183
183
|
bundler
|
data/lib/eac_tools/version.rb
CHANGED
data/sub/avm/avm.gemspec
CHANGED
|
@@ -16,7 +16,7 @@ Gem::Specification.new do |s|
|
|
|
16
16
|
s.add_dependency 'eac_config', '~> 0.11'
|
|
17
17
|
s.add_dependency 'eac_docker', '~> 0.4', '>= 0.4.2'
|
|
18
18
|
s.add_dependency 'eac_git', '~> 0.12', '>= 0.12.2'
|
|
19
|
-
s.add_dependency 'eac_ruby_utils', '~> 0.
|
|
19
|
+
s.add_dependency 'eac_ruby_utils', '~> 0.101'
|
|
20
20
|
s.add_dependency 'eac_templates', '~> 0.3', '>= 0.3.1'
|
|
21
21
|
s.add_dependency 'filesize', '~> 0.2'
|
|
22
22
|
s.add_dependency 'htmlbeautifier', '~> 1.4', '>= 1.4.2'
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'avm/entries/uri_builder'
|
|
4
|
+
require 'eac_config/entry_path'
|
|
5
|
+
require 'eac_ruby_utils/core_ext'
|
|
6
|
+
|
|
7
|
+
module Avm
|
|
8
|
+
module Entries
|
|
9
|
+
module Base
|
|
10
|
+
class InheritedEntryValue
|
|
11
|
+
enable_method_class
|
|
12
|
+
common_constructor :entries_provider, :source_entry_suffix, :target_entry_suffix, :block,
|
|
13
|
+
block_arg: true
|
|
14
|
+
|
|
15
|
+
def result
|
|
16
|
+
self_entry_value.if_present do |instance_id|
|
|
17
|
+
other_entry_value(instance_id).if_present(&block)
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def other_entry_value(instance_id)
|
|
22
|
+
::Avm::Instances::Base.by_id(instance_id).read_entry_optional(target_entry_suffix)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def self_entry_value
|
|
26
|
+
entries_provider.read_entry_optional(source_entry_suffix)
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -9,17 +9,31 @@ module Avm
|
|
|
9
9
|
module Base
|
|
10
10
|
class UriComponentEntryValue
|
|
11
11
|
enable_method_class
|
|
12
|
-
|
|
12
|
+
|
|
13
|
+
enable_listable
|
|
14
|
+
lists.add_symbol :option, :default_value, :inherited_value_block
|
|
15
|
+
|
|
16
|
+
common_constructor :entries_provider, :component_entry_path, :options, default: [{}] do
|
|
13
17
|
self.component_entry_path = ::EacConfig::EntryPath.assert(component_entry_path)
|
|
18
|
+
self.options = self.class.lists.option.hash_keys_validate!(options)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def default_value
|
|
22
|
+
options[OPTION_DEFAULT_VALUE].call_if_proc
|
|
14
23
|
end
|
|
15
24
|
|
|
16
25
|
def inherited_result
|
|
17
26
|
entries_provider.inherited_entry_value(
|
|
18
27
|
id_entry_path.to_string,
|
|
19
|
-
component_entry_path.to_string
|
|
28
|
+
component_entry_path.to_string,
|
|
29
|
+
&inherited_value_block
|
|
20
30
|
)
|
|
21
31
|
end
|
|
22
32
|
|
|
33
|
+
def inherited_value_block
|
|
34
|
+
options[OPTION_INHERITED_VALUE_BLOCK]
|
|
35
|
+
end
|
|
36
|
+
|
|
23
37
|
# @return [EacConfig::EntryPath]
|
|
24
38
|
def id_entry_path
|
|
25
39
|
root_entry_path + %w[id]
|
|
@@ -27,12 +41,7 @@ module Avm
|
|
|
27
41
|
|
|
28
42
|
# @return [String, nil]
|
|
29
43
|
def result
|
|
30
|
-
|
|
31
|
-
return ::Avm::Entries::UriBuilder.from_source(url_entry.value.to_uri)
|
|
32
|
-
.avm_field_get(component)
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
inherited_result
|
|
44
|
+
url_entry_value || inherited_result || default_value
|
|
36
45
|
end
|
|
37
46
|
|
|
38
47
|
# @return [EacConfig::EntryPath]
|
|
@@ -45,6 +54,13 @@ module Avm
|
|
|
45
54
|
entries_provider.entry((root_entry_path + %w[url]).to_string)
|
|
46
55
|
end
|
|
47
56
|
|
|
57
|
+
def url_entry_value
|
|
58
|
+
return unless url_entry.context_found?
|
|
59
|
+
|
|
60
|
+
::Avm::Entries::UriBuilder.from_source(url_entry.value.to_uri)
|
|
61
|
+
.avm_field_get(component)
|
|
62
|
+
end
|
|
63
|
+
|
|
48
64
|
# @return [String]
|
|
49
65
|
def component
|
|
50
66
|
component_entry_path.last
|
|
@@ -34,16 +34,6 @@ module Avm
|
|
|
34
34
|
end
|
|
35
35
|
(path_prefix + entry_suffix).join('.')
|
|
36
36
|
end
|
|
37
|
-
|
|
38
|
-
def inherited_entry_value(source_entry_suffix, target_entry_suffix, &block)
|
|
39
|
-
read_entry_optional(source_entry_suffix).if_present do |instance_id|
|
|
40
|
-
other_entry_value(instance_id, target_entry_suffix).if_present(&block)
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
def other_entry_value(instance_id, entry_suffix)
|
|
45
|
-
::Avm::Instances::Base.by_id(instance_id).read_entry_optional(entry_suffix)
|
|
46
|
-
end
|
|
47
37
|
end
|
|
48
38
|
end
|
|
49
39
|
end
|
|
@@ -12,11 +12,6 @@ module Avm
|
|
|
12
12
|
::Avm::Instances::EntryKeys::FS_PATH) { |v| v + '/' + id }
|
|
13
13
|
end
|
|
14
14
|
|
|
15
|
-
def auto_data_fs_path
|
|
16
|
-
inherited_entry_value(::Avm::Instances::EntryKeys::INSTALL_ID,
|
|
17
|
-
::Avm::Instances::EntryKeys::DATA_FS_PATH) { |v| v + '/' + id }
|
|
18
|
-
end
|
|
19
|
-
|
|
20
15
|
def auto_fs_url
|
|
21
16
|
auto_fs_url_with_install || auto_fs_url_without_install
|
|
22
17
|
end
|
|
@@ -8,15 +8,28 @@ module Avm
|
|
|
8
8
|
class Base
|
|
9
9
|
module AutoValues
|
|
10
10
|
module Install
|
|
11
|
+
def auto_install_data_path
|
|
12
|
+
uri_component_entry_value(
|
|
13
|
+
::Avm::Instances::EntryKeys::INSTALL_DATA_PATH,
|
|
14
|
+
inherited_value_block: ->(v) { v + '/' + id }
|
|
15
|
+
)
|
|
16
|
+
end
|
|
17
|
+
|
|
11
18
|
def auto_install_groupname
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
19
|
+
uri_component_entry_value(
|
|
20
|
+
::Avm::Instances::EntryKeys::INSTALL_GROUPNAME,
|
|
21
|
+
default_value: lambda do
|
|
22
|
+
read_entry_optional(::Avm::Instances::EntryKeys::INSTALL_USERNAME)
|
|
23
|
+
end
|
|
24
|
+
)
|
|
15
25
|
end
|
|
16
26
|
|
|
17
27
|
::Avm::Entries::UriBuilder::ENTRIES_FIELDS.each do |component|
|
|
18
|
-
|
|
19
|
-
|
|
28
|
+
method_suffix = "install_#{component}"
|
|
29
|
+
define_method "auto_#{method_suffix}" do
|
|
30
|
+
uri_component_entry_value(
|
|
31
|
+
::Avm::Instances::EntryKeys.const_get(method_suffix.underscore.upcase)
|
|
32
|
+
)
|
|
20
33
|
end
|
|
21
34
|
end
|
|
22
35
|
|
|
@@ -45,12 +45,12 @@ module Avm
|
|
|
45
45
|
end
|
|
46
46
|
|
|
47
47
|
{
|
|
48
|
-
'' => %w[
|
|
48
|
+
'' => %w[fs_path name source_instance_id],
|
|
49
49
|
admin: URI_FIELDS + %w[api_key],
|
|
50
50
|
database: URI_FIELDS + %w[id limit name system timeout extra],
|
|
51
51
|
docker: %w[registry],
|
|
52
52
|
fs: %w[url],
|
|
53
|
-
install: URI_FIELDS + %w[id groupname],
|
|
53
|
+
install: URI_FIELDS + %w[id data_path groupname],
|
|
54
54
|
mailer: {
|
|
55
55
|
'' => %w[id from reply_to],
|
|
56
56
|
smtp: URI_FIELDS + %w[address domain authentication openssl_verify_mode starttls_auto tls]
|
data/sub/avm/lib/avm/version.rb
CHANGED
|
@@ -16,7 +16,7 @@ RSpec.describe ::Avm::Instances::Base do
|
|
|
16
16
|
{
|
|
17
17
|
'app_0' => {
|
|
18
18
|
fs_path: '/fs_root/app_0',
|
|
19
|
-
|
|
19
|
+
::Avm::Instances::EntryKeys::INSTALL_DATA_PATH => '/data_fs_root/app_0',
|
|
20
20
|
::Avm::Instances::EntryKeys::DATABASE_NAME => 'app_0',
|
|
21
21
|
::Avm::Instances::EntryKeys::DATABASE_USERNAME => 'user1',
|
|
22
22
|
::Avm::Instances::EntryKeys::DATABASE_PASSWORD => 'pass1',
|
|
@@ -12,11 +12,11 @@ Gem::Specification.new do |s|
|
|
|
12
12
|
|
|
13
13
|
s.files = Dir['{lib,template}/**/*']
|
|
14
14
|
|
|
15
|
-
s.add_dependency 'avm', '~> 0.
|
|
15
|
+
s.add_dependency 'avm', '~> 0.39'
|
|
16
16
|
s.add_dependency 'avm-eac_generic_base0', '~> 0.5'
|
|
17
17
|
s.add_dependency 'avm-eac_postgresql_base0', '~> 0.2'
|
|
18
18
|
s.add_dependency 'avm-eac_ubuntu_base0', '~> 0.3'
|
|
19
|
-
s.add_dependency 'eac_ruby_utils', '~> 0.
|
|
19
|
+
s.add_dependency 'eac_ruby_utils', '~> 0.101'
|
|
20
20
|
|
|
21
21
|
s.add_development_dependency 'eac_ruby_gem_support', '~> 0.2'
|
|
22
22
|
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'eac_ruby_utils/common_constructor/instance_initialize'
|
|
4
|
+
require 'eac_ruby_utils/common_constructor/super_args'
|
|
5
|
+
|
|
6
|
+
module EacRubyUtils
|
|
7
|
+
class CommonConstructor
|
|
8
|
+
class ClassAccessors
|
|
9
|
+
attr_reader :common_constructor, :klass
|
|
10
|
+
|
|
11
|
+
def initialize(common_constructor, klass)
|
|
12
|
+
@common_constructor = common_constructor
|
|
13
|
+
@klass = klass
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def args
|
|
17
|
+
common_constructor.all_args
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def perform
|
|
21
|
+
setup_class_attr_readers
|
|
22
|
+
setup_class_attr_writers
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def setup_class_attr_readers
|
|
26
|
+
klass.send(:attr_reader, *args)
|
|
27
|
+
klass.send(:public, *args) if args.any?
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def setup_class_attr_writers
|
|
31
|
+
klass.send(:attr_writer, *args)
|
|
32
|
+
klass.send(:private, *args.map { |a| "#{a}=" }) if args.any?
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -13,17 +13,27 @@ module EacRubyUtils
|
|
|
13
13
|
@klass = klass
|
|
14
14
|
end
|
|
15
15
|
|
|
16
|
-
def
|
|
16
|
+
def define_initialize_callbacks
|
|
17
|
+
klass.include(::ActiveSupport::Callbacks)
|
|
18
|
+
klass.define_callbacks :initialize
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def define_initialize_method
|
|
17
22
|
class_initialize = self
|
|
18
|
-
klass.send(:define_method, :initialize) do |*args|
|
|
23
|
+
klass.send(:define_method, :initialize) do |*args, &block|
|
|
19
24
|
::EacRubyUtils::CommonConstructor::InstanceInitialize.new(
|
|
20
|
-
class_initialize.common_constructor, args, self
|
|
21
|
-
).
|
|
25
|
+
class_initialize.common_constructor, args, self, block
|
|
26
|
+
).perform
|
|
22
27
|
super(*::EacRubyUtils::CommonConstructor::SuperArgs.new(
|
|
23
28
|
class_initialize, args, self
|
|
24
29
|
).result)
|
|
25
30
|
end
|
|
26
31
|
end
|
|
32
|
+
|
|
33
|
+
def perform
|
|
34
|
+
define_initialize_callbacks
|
|
35
|
+
define_initialize_method
|
|
36
|
+
end
|
|
27
37
|
end
|
|
28
38
|
end
|
|
29
39
|
end
|
|
@@ -3,18 +3,20 @@
|
|
|
3
3
|
module EacRubyUtils
|
|
4
4
|
class CommonConstructor
|
|
5
5
|
class InstanceInitialize
|
|
6
|
-
attr_reader :common_constructor, :args, :object
|
|
6
|
+
attr_reader :common_constructor, :args, :object, :block
|
|
7
7
|
|
|
8
|
-
def initialize(common_constructor, args, object)
|
|
8
|
+
def initialize(common_constructor, args, object, block)
|
|
9
9
|
@common_constructor = common_constructor
|
|
10
10
|
@args = args
|
|
11
11
|
@object = object
|
|
12
|
+
@block = block
|
|
12
13
|
end
|
|
13
14
|
|
|
14
|
-
def
|
|
15
|
+
def perform
|
|
15
16
|
validate_args_count
|
|
16
17
|
object.run_callbacks :initialize do
|
|
17
18
|
object_attributes_set
|
|
19
|
+
object_block_set
|
|
18
20
|
object_after_callback
|
|
19
21
|
end
|
|
20
22
|
end
|
|
@@ -36,12 +38,21 @@ module EacRubyUtils
|
|
|
36
38
|
object.instance_eval(&common_constructor.after_set_block)
|
|
37
39
|
end
|
|
38
40
|
|
|
41
|
+
def object_attribute_set(attr_name, attr_value)
|
|
42
|
+
object.send("#{attr_name}=", attr_value)
|
|
43
|
+
end
|
|
44
|
+
|
|
39
45
|
def object_attributes_set
|
|
40
46
|
common_constructor.args.each do |arg_name|
|
|
41
|
-
|
|
47
|
+
object_attribute_set(arg_name, arg_value(arg_name))
|
|
42
48
|
end
|
|
43
49
|
end
|
|
44
50
|
|
|
51
|
+
def object_block_set
|
|
52
|
+
block_arg = common_constructor.block_arg
|
|
53
|
+
object_attribute_set(block_arg, block) if block_arg
|
|
54
|
+
end
|
|
55
|
+
|
|
45
56
|
def validate_args_count
|
|
46
57
|
return if common_constructor.args_count.include?(args.count)
|
|
47
58
|
|
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
require 'active_support/callbacks'
|
|
4
4
|
require 'eac_ruby_utils/arguments_consumer'
|
|
5
|
+
require 'eac_ruby_utils/common_constructor/class_accessors'
|
|
5
6
|
require 'eac_ruby_utils/common_constructor/class_initialize'
|
|
6
7
|
require 'ostruct'
|
|
7
8
|
|
|
8
9
|
module EacRubyUtils
|
|
9
10
|
class CommonConstructor
|
|
10
|
-
attr_reader :
|
|
11
|
+
attr_reader :all_args, :options, :after_set_block
|
|
11
12
|
|
|
12
13
|
class << self
|
|
13
14
|
def parse_args_options(args)
|
|
@@ -37,11 +38,15 @@ module EacRubyUtils
|
|
|
37
38
|
|
|
38
39
|
def initialize(*args, &after_set_block)
|
|
39
40
|
args_processed = self.class.parse_args_options(args)
|
|
40
|
-
@
|
|
41
|
+
@all_args = args_processed.args
|
|
41
42
|
@options = args_processed.options
|
|
42
43
|
@after_set_block = after_set_block
|
|
43
44
|
end
|
|
44
45
|
|
|
46
|
+
def args
|
|
47
|
+
block_arg? ? all_args[0..-2] : all_args
|
|
48
|
+
end
|
|
49
|
+
|
|
45
50
|
def args_count
|
|
46
51
|
(args_count_min..args_count_max)
|
|
47
52
|
end
|
|
@@ -54,32 +59,32 @@ module EacRubyUtils
|
|
|
54
59
|
args.count
|
|
55
60
|
end
|
|
56
61
|
|
|
62
|
+
def block_arg
|
|
63
|
+
block_arg? ? all_args.last : nil
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def block_arg?
|
|
67
|
+
options[:block_arg] || false
|
|
68
|
+
end
|
|
69
|
+
|
|
57
70
|
def default_values
|
|
58
71
|
options[:default] || []
|
|
59
72
|
end
|
|
60
73
|
|
|
61
74
|
def setup_class(klass)
|
|
62
|
-
|
|
63
|
-
|
|
75
|
+
setup_class_accessors(klass)
|
|
76
|
+
|
|
64
77
|
setup_class_initialize(klass)
|
|
65
78
|
|
|
66
79
|
klass
|
|
67
80
|
end
|
|
68
81
|
|
|
69
|
-
def
|
|
70
|
-
|
|
71
|
-
klass.send(:public, *args) if args.any?
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
def setup_class_attr_writers(klass)
|
|
75
|
-
klass.send(:attr_writer, *args)
|
|
76
|
-
klass.send(:private, *args.map { |a| "#{a}=" }) if args.any?
|
|
82
|
+
def setup_class_accessors(klass)
|
|
83
|
+
::EacRubyUtils::CommonConstructor::ClassAccessors.new(self, klass).perform
|
|
77
84
|
end
|
|
78
85
|
|
|
79
86
|
def setup_class_initialize(klass)
|
|
80
|
-
|
|
81
|
-
klass.define_callbacks :initialize
|
|
82
|
-
::EacRubyUtils::CommonConstructor::ClassInitialize.new(self, klass).run
|
|
87
|
+
::EacRubyUtils::CommonConstructor::ClassInitialize.new(self, klass).perform
|
|
83
88
|
end
|
|
84
89
|
|
|
85
90
|
def super_args
|
|
@@ -93,6 +93,32 @@ RSpec.describe ::EacRubyUtils::CommonConstructor do
|
|
|
93
93
|
end
|
|
94
94
|
end
|
|
95
95
|
|
|
96
|
+
context 'with block argument' do
|
|
97
|
+
let(:instance) do
|
|
98
|
+
described_class.new(:first, :second, :last, block_arg: true, default: ['second'])
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
let(:block) do
|
|
102
|
+
::Proc.new { first + second }
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
let(:a_class) do
|
|
106
|
+
::Class.new do
|
|
107
|
+
def result
|
|
108
|
+
last.run
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
let(:a_class_instance) { a_class.new('first') { 'last' } }
|
|
114
|
+
|
|
115
|
+
it { expect(a_class_instance.last).to be_a(::Proc) }
|
|
116
|
+
it { expect(a_class_instance.last.call).to eq('last') }
|
|
117
|
+
|
|
118
|
+
it { expect(a_class_instance.first).to eq('first') }
|
|
119
|
+
it { expect(a_class_instance.second).to eq('second') }
|
|
120
|
+
end
|
|
121
|
+
|
|
96
122
|
context 'with class hierarchy mixed with and without common_constructor' do
|
|
97
123
|
let(:klass_0) do
|
|
98
124
|
described_class.new(:a_param).setup_class(::Class.new)
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: eac_tools
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.25.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Put here the authors
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2022-08-
|
|
11
|
+
date: 2022-08-17 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: avm
|
|
@@ -16,14 +16,14 @@ dependencies:
|
|
|
16
16
|
requirements:
|
|
17
17
|
- - "~>"
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: '0.
|
|
19
|
+
version: '0.39'
|
|
20
20
|
type: :runtime
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
24
|
- - "~>"
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: '0.
|
|
26
|
+
version: '0.39'
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: avm-eac_asciidoctor_base0
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -155,6 +155,9 @@ dependencies:
|
|
|
155
155
|
- - "~>"
|
|
156
156
|
- !ruby/object:Gem::Version
|
|
157
157
|
version: '0.4'
|
|
158
|
+
- - ">="
|
|
159
|
+
- !ruby/object:Gem::Version
|
|
160
|
+
version: 0.4.1
|
|
158
161
|
type: :runtime
|
|
159
162
|
prerelease: false
|
|
160
163
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -162,6 +165,9 @@ dependencies:
|
|
|
162
165
|
- - "~>"
|
|
163
166
|
- !ruby/object:Gem::Version
|
|
164
167
|
version: '0.4'
|
|
168
|
+
- - ">="
|
|
169
|
+
- !ruby/object:Gem::Version
|
|
170
|
+
version: 0.4.1
|
|
165
171
|
- !ruby/object:Gem::Dependency
|
|
166
172
|
name: avm-eac_wordpress_base0
|
|
167
173
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -202,14 +208,14 @@ dependencies:
|
|
|
202
208
|
requirements:
|
|
203
209
|
- - "~>"
|
|
204
210
|
- !ruby/object:Gem::Version
|
|
205
|
-
version: '0.
|
|
211
|
+
version: '0.101'
|
|
206
212
|
type: :runtime
|
|
207
213
|
prerelease: false
|
|
208
214
|
version_requirements: !ruby/object:Gem::Requirement
|
|
209
215
|
requirements:
|
|
210
216
|
- - "~>"
|
|
211
217
|
- !ruby/object:Gem::Version
|
|
212
|
-
version: '0.
|
|
218
|
+
version: '0.101'
|
|
213
219
|
- !ruby/object:Gem::Dependency
|
|
214
220
|
name: eac_ruby_gem_support
|
|
215
221
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -772,6 +778,7 @@ files:
|
|
|
772
778
|
- sub/avm/lib/avm/entries/auto_values/entry.rb
|
|
773
779
|
- sub/avm/lib/avm/entries/auto_values/uri_entry.rb
|
|
774
780
|
- sub/avm/lib/avm/entries/base.rb
|
|
781
|
+
- sub/avm/lib/avm/entries/base/inherited_entry_value.rb
|
|
775
782
|
- sub/avm/lib/avm/entries/base/uri_component_entry_value.rb
|
|
776
783
|
- sub/avm/lib/avm/entries/entry.rb
|
|
777
784
|
- sub/avm/lib/avm/entries/uri_builder.rb
|
|
@@ -1053,6 +1060,7 @@ files:
|
|
|
1053
1060
|
- sub/eac_ruby_utils/lib/eac_ruby_utils/common_concern/class_setup.rb
|
|
1054
1061
|
- sub/eac_ruby_utils/lib/eac_ruby_utils/common_concern/module_setup.rb
|
|
1055
1062
|
- sub/eac_ruby_utils/lib/eac_ruby_utils/common_constructor.rb
|
|
1063
|
+
- sub/eac_ruby_utils/lib/eac_ruby_utils/common_constructor/class_accessors.rb
|
|
1056
1064
|
- sub/eac_ruby_utils/lib/eac_ruby_utils/common_constructor/class_initialize.rb
|
|
1057
1065
|
- sub/eac_ruby_utils/lib/eac_ruby_utils/common_constructor/instance_initialize.rb
|
|
1058
1066
|
- sub/eac_ruby_utils/lib/eac_ruby_utils/common_constructor/super_args.rb
|