avm 0.38.0 → 0.39.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dc4f65ada3e6c902df6d77b491ac3a043e6ebb7fc93812873fb6d2d7b0d50624
4
- data.tar.gz: 5dfb61ddeed3edb2c55f98133e281a18aa28f7024e69f2e1942b3fccc03453a1
3
+ metadata.gz: '04283409a229d111fd5dd3959c88cf29639d209a14632cbb770c1f151f12da7f'
4
+ data.tar.gz: b38fdf654a75b21da9bbd8f479fc323e4f157f51a04eca7f4a0c581a789dba5a
5
5
  SHA512:
6
- metadata.gz: 142224b13cfcf3129c0fb24650724af9e66d892247668fb249e526fb9b050df749f0da51c1d0de95106ef85bceae03f563ca93adcf41f2464327cae6153341a0
7
- data.tar.gz: 8968321777cca2c10902856df6bb9654f98d7e4b84a9c5781c741ef2483e9b1ca5283d281288c9351f34de83bb7e22992894c611059985d8359fcf42b1fd92a7
6
+ metadata.gz: fe0ca2eb191f577ed18619c06af5367d6f8885de4ab9c9a7f89790c0722d5f03f1575bed0e61e33865ee12b9ea35d44c0653566428946a8f62c8f6dd4cbff29f
7
+ data.tar.gz: 131dfd01487f969a5bcc2f8f63a2e34a254312055c4b154640783f50e43d58f20c1054a09ea1d99d5a76f1dcfd6b4f66825dba03be3cde028c74b3320b721d28
@@ -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
- common_constructor :entries_provider, :component_entry_path do
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
- if url_entry.context_found?
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
- inherited_entry_value(::Avm::Instances::EntryKeys::INSTALL_ID,
13
- ::Avm::Instances::EntryKeys::INSTALL_GROUPNAME) ||
14
- read_entry_optional(::Avm::Instances::EntryKeys::INSTALL_USERNAME)
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
- define_method "auto_install_#{component}" do
19
- uri_component_entry_value("install.#{component}")
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[data_fs_path fs_path name source_instance_id],
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/lib/avm/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Avm
4
- VERSION = '0.38.0'
4
+ VERSION = '0.39.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: avm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.38.0
4
+ version: 0.39.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eduardo H. Bogoni
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-08-16 00:00:00.000000000 Z
11
+ date: 2022-08-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: eac_cli
@@ -90,14 +90,14 @@ dependencies:
90
90
  requirements:
91
91
  - - "~>"
92
92
  - !ruby/object:Gem::Version
93
- version: '0.100'
93
+ version: '0.101'
94
94
  type: :runtime
95
95
  prerelease: false
96
96
  version_requirements: !ruby/object:Gem::Requirement
97
97
  requirements:
98
98
  - - "~>"
99
99
  - !ruby/object:Gem::Version
100
- version: '0.100'
100
+ version: '0.101'
101
101
  - !ruby/object:Gem::Dependency
102
102
  name: eac_templates
103
103
  requirement: !ruby/object:Gem::Requirement
@@ -230,6 +230,7 @@ files:
230
230
  - lib/avm/entries/auto_values/entry.rb
231
231
  - lib/avm/entries/auto_values/uri_entry.rb
232
232
  - lib/avm/entries/base.rb
233
+ - lib/avm/entries/base/inherited_entry_value.rb
233
234
  - lib/avm/entries/base/uri_component_entry_value.rb
234
235
  - lib/avm/entries/entry.rb
235
236
  - lib/avm/entries/uri_builder.rb