avm 0.37.0 → 0.39.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '0821a30efc137201d1e73d98cf31b741458bacc8a297495e1d88a6a150d988d3'
4
- data.tar.gz: da4de9f1f24f9638ee5158411a05494c5007ffad292f26c3f19a4c5665389b1c
3
+ metadata.gz: 77d9c5ea0df6745cf1b9e1ee3d47ef031b2bc6caf956de84804dc32490d21776
4
+ data.tar.gz: f564b3b00470ab6643083ac1ec6fbd63c56dd5b65539049520f2aaac0f59a47b
5
5
  SHA512:
6
- metadata.gz: afad52fb0a1801a83d5d295b9e220d7040a8ed09205d9fafd783393abc08bafe750a882e4ce4a28c6bbb5d23d3039a97e843818ef6e75437f4f7b5b5d87f1458
7
- data.tar.gz: b450f642ef1c8692264dd21d60195f669a1d58291cff3256f3c379b5f529bdd589b8b66537f10e19acafa796ec1eb0e4600bb788e31ca6e3712392534dd32b00
6
+ metadata.gz: c31937f1858e5de2462d76a6880358fe8bdfb35faac91ead3d7e52eb881c53f6f2db2dcca071435b0a9aa4034a43fb7468258e52fb25025ce7fbff5131c0d480
7
+ data.tar.gz: 16eb08fcbef7cc5a905b3118af0f690bad53283f63623b7f0662009bb92c70d86098669da89f00124d46f94cd679cd6dcb98a6506ffca93dba23211a507b2790
@@ -15,7 +15,7 @@ module Avm
15
15
 
16
16
  def value
17
17
  ::Avm::Entries::UriBuilder.from_all_fields do |field_name|
18
- entries_provider.entry([suffix, field_name]).value
18
+ entries_provider.entry([suffix, field_name]).optional_value
19
19
  end.to_uri.to_s
20
20
  end
21
21
  end
@@ -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
@@ -0,0 +1,71 @@
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 UriComponentEntryValue
11
+ enable_method_class
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
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
23
+ end
24
+
25
+ def inherited_result
26
+ entries_provider.inherited_entry_value(
27
+ id_entry_path.to_string,
28
+ component_entry_path.to_string,
29
+ &inherited_value_block
30
+ )
31
+ end
32
+
33
+ def inherited_value_block
34
+ options[OPTION_INHERITED_VALUE_BLOCK]
35
+ end
36
+
37
+ # @return [EacConfig::EntryPath]
38
+ def id_entry_path
39
+ root_entry_path + %w[id]
40
+ end
41
+
42
+ # @return [String, nil]
43
+ def result
44
+ url_entry_value || inherited_result || default_value
45
+ end
46
+
47
+ # @return [EacConfig::EntryPath]
48
+ def root_entry_path
49
+ component_entry_path[0..-2]
50
+ end
51
+
52
+ # @return [Avm::Entries::Entry]
53
+ def url_entry
54
+ entries_provider.entry((root_entry_path + %w[url]).to_string)
55
+ end
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
+
64
+ # @return [String]
65
+ def component
66
+ component_entry_path.last
67
+ end
68
+ end
69
+ end
70
+ end
71
+ end
@@ -6,6 +6,8 @@ require 'avm/entries/entry'
6
6
  module Avm
7
7
  module Entries
8
8
  module Base
9
+ require_sub __FILE__, require_dependency: true
10
+
9
11
  def entries_provider_id
10
12
  id
11
13
  end
@@ -32,16 +34,6 @@ module Avm
32
34
  end
33
35
  (path_prefix + entry_suffix).join('.')
34
36
  end
35
-
36
- def inherited_entry_value(source_entry_suffix, target_entry_suffix, &block)
37
- read_entry_optional(source_entry_suffix).if_present do |instance_id|
38
- other_entry_value(instance_id, target_entry_suffix).if_present(&block)
39
- end
40
- end
41
-
42
- def other_entry_value(instance_id, entry_suffix)
43
- ::Avm::Instances::Base.by_id(instance_id).read_entry_optional(entry_suffix)
44
- end
45
37
  end
46
38
  end
47
39
  end
@@ -10,7 +10,16 @@ module Avm
10
10
  common_constructor :parent, :suffix, :options
11
11
 
12
12
  def auto_value
13
- ::Avm::Entries::AutoValues::Entry.new(parent, suffix).value
13
+ auto_value_entry.value
14
+ end
15
+
16
+ def auto_value_entry
17
+ @auto_value_entry ||= ::Avm::Entries::AutoValues::Entry.new(parent, suffix)
18
+ end
19
+
20
+ # @return [Boolean]
21
+ def context_found?
22
+ context_entry.found?
14
23
  end
15
24
 
16
25
  def full_path
@@ -42,6 +42,10 @@ module Avm
42
42
 
43
43
  common_constructor :data, default: [{}]
44
44
 
45
+ def avm_field_get(avm_field)
46
+ field_get(translate_field(avm_field))
47
+ end
48
+
45
49
  def field_get(name)
46
50
  data[name.to_sym].if_present(&:to_s)
47
51
  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
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'avm/entries/uri_builder'
3
4
  require 'avm/instances/entry_keys'
4
5
 
5
6
  module Avm
@@ -7,25 +8,29 @@ module Avm
7
8
  class Base
8
9
  module AutoValues
9
10
  module Install
10
- def auto_install_groupname
11
- inherited_entry_value(::Avm::Instances::EntryKeys::INSTALL_ID,
12
- ::Avm::Instances::EntryKeys::INSTALL_GROUPNAME) ||
13
- read_entry_optional(::Avm::Instances::EntryKeys::INSTALL_USERNAME)
14
- end
15
-
16
- def auto_install_hostname
17
- inherited_entry_value(::Avm::Instances::EntryKeys::INSTALL_ID,
18
- ::Avm::Instances::EntryKeys::INSTALL_HOSTNAME)
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
+ )
19
16
  end
20
17
 
21
- def auto_install_port
22
- inherited_entry_value(::Avm::Instances::EntryKeys::INSTALL_ID,
23
- ::Avm::Instances::EntryKeys::INSTALL_PORT) || 22
18
+ def auto_install_groupname
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
+ )
24
25
  end
25
26
 
26
- def auto_install_username
27
- inherited_entry_value(::Avm::Instances::EntryKeys::INSTALL_ID,
28
- ::Avm::Instances::EntryKeys::INSTALL_USERNAME)
27
+ ::Avm::Entries::UriBuilder::ENTRIES_FIELDS.each do |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
+ )
33
+ end
29
34
  end
30
35
 
31
36
  def auto_install_url
@@ -1,11 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'avm/entries/uri_builder'
3
4
  require 'eac_ruby_utils/core_ext'
4
5
 
5
6
  module Avm
6
7
  module Instances
7
8
  module EntryKeys
8
- URI_FIELDS = %i[fragment hostname password path port query scheme url username].freeze
9
+ URI_FIELDS = ::Avm::Entries::UriBuilder::ENTRIES_FIELDS + %w[url]
9
10
 
10
11
  class << self
11
12
  def all
@@ -44,12 +45,12 @@ module Avm
44
45
  end
45
46
 
46
47
  {
47
- '' => %w[data_fs_path fs_path name source_instance_id],
48
+ '' => %w[fs_path name source_instance_id],
48
49
  admin: URI_FIELDS + %w[api_key],
49
50
  database: URI_FIELDS + %w[id limit name system timeout extra],
50
51
  docker: %w[registry],
51
52
  fs: %w[url],
52
- install: URI_FIELDS + %w[id groupname],
53
+ install: URI_FIELDS + %w[id data_path groupname],
53
54
  mailer: {
54
55
  '' => %w[id from reply_to],
55
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.37.0'
4
+ VERSION = '0.39.1'
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.37.0
4
+ version: 0.39.1
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-14 00:00:00.000000000 Z
11
+ date: 2022-08-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: eac_cli
@@ -36,14 +36,20 @@ dependencies:
36
36
  requirements:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: '0.10'
39
+ version: '0.11'
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: 0.11.1
40
43
  type: :runtime
41
44
  prerelease: false
42
45
  version_requirements: !ruby/object:Gem::Requirement
43
46
  requirements:
44
47
  - - "~>"
45
48
  - !ruby/object:Gem::Version
46
- version: '0.10'
49
+ version: '0.11'
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: 0.11.1
47
53
  - !ruby/object:Gem::Dependency
48
54
  name: eac_docker
49
55
  requirement: !ruby/object:Gem::Requirement
@@ -73,7 +79,7 @@ dependencies:
73
79
  version: '0.12'
74
80
  - - ">="
75
81
  - !ruby/object:Gem::Version
76
- version: 0.12.1
82
+ version: 0.12.2
77
83
  type: :runtime
78
84
  prerelease: false
79
85
  version_requirements: !ruby/object:Gem::Requirement
@@ -83,21 +89,21 @@ dependencies:
83
89
  version: '0.12'
84
90
  - - ">="
85
91
  - !ruby/object:Gem::Version
86
- version: 0.12.1
92
+ version: 0.12.2
87
93
  - !ruby/object:Gem::Dependency
88
94
  name: eac_ruby_utils
89
95
  requirement: !ruby/object:Gem::Requirement
90
96
  requirements:
91
97
  - - "~>"
92
98
  - !ruby/object:Gem::Version
93
- version: '0.98'
99
+ version: '0.102'
94
100
  type: :runtime
95
101
  prerelease: false
96
102
  version_requirements: !ruby/object:Gem::Requirement
97
103
  requirements:
98
104
  - - "~>"
99
105
  - !ruby/object:Gem::Version
100
- version: '0.98'
106
+ version: '0.102'
101
107
  - !ruby/object:Gem::Dependency
102
108
  name: eac_templates
103
109
  requirement: !ruby/object:Gem::Requirement
@@ -230,6 +236,8 @@ files:
230
236
  - lib/avm/entries/auto_values/entry.rb
231
237
  - lib/avm/entries/auto_values/uri_entry.rb
232
238
  - lib/avm/entries/base.rb
239
+ - lib/avm/entries/base/inherited_entry_value.rb
240
+ - lib/avm/entries/base/uri_component_entry_value.rb
233
241
  - lib/avm/entries/entry.rb
234
242
  - lib/avm/entries/uri_builder.rb
235
243
  - lib/avm/executables.rb