avm-tools 0.72.0 → 0.73.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/lib/avm/instances/base/auto_values.rb +2 -1
- data/lib/avm/instances/base/auto_values/mailer.rb +34 -0
- data/lib/avm/instances/entry_keys.rb +4 -0
- data/lib/avm/tools/version.rb +1 -1
- data/template/avm/eac_rails_base0/deploy/config/envvars.d/email.yml.template +11 -0
- data/vendor/eac_ruby_base0/lib/eac_ruby_base0/runner.rb +12 -0
- data/vendor/eac_ruby_base0/lib/eac_ruby_base0/version.rb +1 -1
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/blank_not_blank.rb +19 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/configs/base.rb +43 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/configs/file.rb +12 -31
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs.rb +4 -1
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/paths_hash.rb +21 -58
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/paths_hash/entry_key_error.rb +8 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/paths_hash/node.rb +67 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/paths_hash/path_search.rb +39 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/version.rb +1 -1
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/blank_not_blank_spec.rb +16 -0
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/configs_spec.rb +15 -0
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/paths_hash_spec.rb +52 -13
- metadata +10 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: af0f11c7a0f00c23780d97a299a822c01a7466d5f229d4c0cbe137d11dbce8c5
|
4
|
+
data.tar.gz: 06d5dfc23be320ea36ccdf30af582effae03309c29377912760a23c832f7fac3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e4b9ac7532a83c97b55c32d5655c6ae86d83d8b182eabbd9bc1dff629ca297c36c4190dea0c444b3b51dfb3a436368757b47feaa13e16ca40c8421b83966a25e
|
7
|
+
data.tar.gz: f97b797046e7e73c40b15b6c789982c2fcc095d2a01a0cbd37e4db3f483433319e36b3fc40da872625f4de4c0a636983c31ca1e6dfc95c965324b433be2d3c07
|
@@ -10,7 +10,8 @@ module Avm
|
|
10
10
|
extend ::ActiveSupport::Concern
|
11
11
|
|
12
12
|
included do
|
13
|
-
%w[Access Admin Data Database Filesystem Ruby Source System Web]
|
13
|
+
%w[Access Admin Data Database Filesystem Mailer Ruby Source System Web]
|
14
|
+
.each do |class_name|
|
14
15
|
include const_get(class_name)
|
15
16
|
end
|
16
17
|
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'avm/instances/entry'
|
4
|
+
require 'avm/instances/entry_keys'
|
5
|
+
|
6
|
+
module Avm
|
7
|
+
module Instances
|
8
|
+
class Base
|
9
|
+
module AutoValues
|
10
|
+
module Mailer
|
11
|
+
::Avm::Instances::EntryKeys.all.select { |c| c.to_s.start_with?('mailer.') }
|
12
|
+
.reject { |c| c == ::Avm::Instances::EntryKeys::MAILER_ID }
|
13
|
+
.each do |mailer_key|
|
14
|
+
define_method ::Avm::Instances::Entry.auto_value_method_name(mailer_key) do
|
15
|
+
mailer_auto_common(mailer_key)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def auto_mailer_id
|
20
|
+
inherited_entry_value(::Avm::Instances::EntryKeys::HOST_ID,
|
21
|
+
::Avm::Instances::EntryKeys::MAILER_ID) ||
|
22
|
+
read_entry_optional(::Avm::Instances::EntryKeys::HOST_ID)
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def mailer_auto_common(mailer_key)
|
28
|
+
inherited_entry_value(::Avm::Instances::EntryKeys::MAILER_ID, mailer_key)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -42,6 +42,10 @@ module Avm
|
|
42
42
|
{
|
43
43
|
'' => %w[fs_path host_id source_instance_id],
|
44
44
|
database: %w[id hostname name password port system username],
|
45
|
+
mailer: {
|
46
|
+
'' => %w[id from reply_to],
|
47
|
+
smtp: %w[address port domain username password authentication starttls_auto]
|
48
|
+
},
|
45
49
|
ssh: %w[hostname port url username],
|
46
50
|
web: %w[authority hostname path port scheme url userinfo]
|
47
51
|
}.each { |prefix, suffixes| keys_consts_set(prefix, suffixes) }
|
data/lib/avm/tools/version.rb
CHANGED
@@ -0,0 +1,11 @@
|
|
1
|
+
---
|
2
|
+
action_mailer_smtp_address: '%%MAILER.SMTP.ADDRESS%%'
|
3
|
+
action_mailer_smtp_port: '%%MAILER.SMTP.PORT%%'
|
4
|
+
action_mailer_smtp_domain: '%%MAILER.SMTP.DOMAIN%%'
|
5
|
+
action_mailer_smtp_username: '%%MAILER.SMTP.USERNAME%%'
|
6
|
+
action_mailer_smtp_password: '%%MAILER.SMTP.PASSWORD%%'
|
7
|
+
action_mailer_smtp_authentication: '%%MAILER.SMTP.AUTHENTICATION%%'
|
8
|
+
action_mailer_smtp_enable_starttls_auto: '%%MAILER.SMTP.STARTTLS_AUTO%%'
|
9
|
+
action_mailer_default_options_from: '%%MAILER.FROM%%'
|
10
|
+
action_mailer_default_options_reply_to: '%%MAILER.REPLY_TO%%'
|
11
|
+
action_mailer_default_url_host: '%%WEB.URL%%'
|
@@ -10,6 +10,7 @@ module EacRubyBase0
|
|
10
10
|
include ::EacCli::DefaultRunner
|
11
11
|
runner_definition do
|
12
12
|
bool_opt '-q', '--quiet', 'Quiet mode.'
|
13
|
+
bool_opt '-I', '--no-input', 'Fail if a input is requested.'
|
13
14
|
subcommands
|
14
15
|
alt do
|
15
16
|
bool_opt '-V', '--version', 'Show version.'
|
@@ -20,6 +21,7 @@ module EacRubyBase0
|
|
20
21
|
def run
|
21
22
|
on_speaker_node do |node|
|
22
23
|
node.stderr = ::StringIO.new if options.fetch('--quiet')
|
24
|
+
node.stdin = FailIfRequestInput.new if options.fetch('--no-input')
|
23
25
|
if options.fetch('--version')
|
24
26
|
show_version
|
25
27
|
else
|
@@ -35,5 +37,15 @@ module EacRubyBase0
|
|
35
37
|
def show_version
|
36
38
|
out("#{application_version}\n")
|
37
39
|
end
|
40
|
+
|
41
|
+
class FailIfRequestInput
|
42
|
+
enable_console_speaker
|
43
|
+
|
44
|
+
%w[gets noecho].each do |method|
|
45
|
+
define_method(method) do
|
46
|
+
raise "Input method requested (\"#{method}\") and option --no-input is set"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
38
50
|
end
|
39
51
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'active_support/core_ext/object/blank'
|
4
|
+
require 'singleton'
|
5
|
+
|
6
|
+
module EacRubyUtils
|
7
|
+
# A blank string which returns +false+ for +blank?+ method.
|
8
|
+
class BlankNotBlank < String
|
9
|
+
include ::Singleton
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
super('')
|
13
|
+
end
|
14
|
+
|
15
|
+
def blank?
|
16
|
+
false
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/blank_not_blank'
|
4
|
+
require 'eac_ruby_utils/core_ext'
|
5
|
+
require 'eac_ruby_utils/paths_hash'
|
6
|
+
|
7
|
+
module EacRubyUtils
|
8
|
+
class Configs
|
9
|
+
class Base
|
10
|
+
enable_simple_cache
|
11
|
+
|
12
|
+
common_constructor :data, default: [{}] do
|
13
|
+
self.data = ::EacRubyUtils::PathsHash.new(data)
|
14
|
+
end
|
15
|
+
|
16
|
+
def []=(entry_key, entry_value)
|
17
|
+
write(entry_key, entry_value)
|
18
|
+
end
|
19
|
+
|
20
|
+
def [](entry_key)
|
21
|
+
read(entry_key)
|
22
|
+
end
|
23
|
+
|
24
|
+
def clear
|
25
|
+
replace({})
|
26
|
+
end
|
27
|
+
|
28
|
+
def read(entry_key)
|
29
|
+
return nil unless data.key?(entry_key)
|
30
|
+
|
31
|
+
data.fetch(entry_key).if_present(::EacRubyUtils::BlankNotBlank.instance)
|
32
|
+
end
|
33
|
+
|
34
|
+
def replace(new_data)
|
35
|
+
self.data = ::EacRubyUtils::PathsHash.new(new_data)
|
36
|
+
end
|
37
|
+
|
38
|
+
def write(entry_key, entry_value)
|
39
|
+
data[entry_key] = entry_value
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -1,27 +1,18 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require '
|
3
|
+
require 'eac_ruby_utils/configs/base'
|
4
4
|
require 'yaml'
|
5
|
-
require 'eac_ruby_utils/patches/hash/sym_keys_hash'
|
6
|
-
require 'eac_ruby_utils/paths_hash'
|
7
|
-
require 'eac_ruby_utils/simple_cache'
|
8
5
|
|
9
6
|
module EacRubyUtils
|
10
7
|
class Configs
|
11
|
-
class File
|
12
|
-
include ::EacRubyUtils::SimpleCache
|
13
|
-
|
8
|
+
class File < ::EacRubyUtils::Configs::Base
|
14
9
|
attr_reader :path, :options
|
15
10
|
|
16
11
|
# Valid options: [:autosave]
|
17
12
|
def initialize(path, options = {})
|
18
13
|
@path = path
|
19
14
|
@options = options.to_sym_keys_hash.freeze
|
20
|
-
|
21
|
-
end
|
22
|
-
|
23
|
-
def clear
|
24
|
-
self.data = ::EacRubyUtils::PathsHash.new({})
|
15
|
+
super(raw_data_from_file)
|
25
16
|
end
|
26
17
|
|
27
18
|
def save
|
@@ -30,37 +21,27 @@ module EacRubyUtils
|
|
30
21
|
end
|
31
22
|
|
32
23
|
def load
|
33
|
-
|
34
|
-
::EacRubyUtils::PathsHash.new(YAML.load_file(path))
|
35
|
-
else
|
36
|
-
{}
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
def []=(entry_key, entry_value)
|
41
|
-
write(entry_key, entry_value)
|
24
|
+
replace(raw_data_from_file)
|
42
25
|
end
|
43
26
|
|
44
27
|
def write(entry_key, entry_value)
|
45
|
-
|
28
|
+
super
|
46
29
|
save if autosave?
|
47
30
|
end
|
48
31
|
|
49
|
-
def [](entry_key)
|
50
|
-
read(entry_key)
|
51
|
-
end
|
52
|
-
|
53
|
-
def read(entry_key)
|
54
|
-
data[entry_key]
|
55
|
-
end
|
56
|
-
|
57
32
|
def autosave?
|
58
33
|
options[:autosave] ? true : false
|
59
34
|
end
|
60
35
|
|
61
36
|
private
|
62
37
|
|
63
|
-
|
38
|
+
def raw_data_from_file
|
39
|
+
if ::File.exist?(path) && ::File.size(path).positive?
|
40
|
+
::YAML.load_file(path)
|
41
|
+
else
|
42
|
+
{}
|
43
|
+
end
|
44
|
+
end
|
64
45
|
end
|
65
46
|
end
|
66
47
|
end
|
@@ -66,7 +66,10 @@ module EacRubyUtils
|
|
66
66
|
protected
|
67
67
|
|
68
68
|
def envvar_read_entry(entry_key)
|
69
|
-
|
69
|
+
env_entry_key = self.class.entry_key_to_envvar_name(entry_key)
|
70
|
+
return nil unless ENV.key?(env_entry_key)
|
71
|
+
|
72
|
+
ENV.fetch(env_entry_key).if_present(::EacRubyUtils::BlankNotBlank.instance)
|
70
73
|
end
|
71
74
|
|
72
75
|
def read_entry_from_console(entry_key, options)
|
@@ -1,21 +1,25 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require '
|
4
|
-
require 'eac_ruby_utils/patches/object/asserts'
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
5
4
|
|
6
5
|
module EacRubyUtils
|
7
6
|
class PathsHash
|
7
|
+
require_sub __FILE__
|
8
|
+
|
8
9
|
class << self
|
9
10
|
def parse_entry_key(entry_key)
|
10
11
|
r = entry_key.to_s.strip
|
11
|
-
raise EntryKeyError, 'Entry key cannot start or end with dot' if
|
12
|
+
raise ::EacRubyUtils::PathsHash::EntryKeyError, 'Entry key cannot start or end with dot' if
|
12
13
|
r.start_with?('.') || r.end_with?('.')
|
13
14
|
|
14
15
|
r = r.split('.').map(&:strip)
|
15
|
-
|
16
|
+
if r.empty?
|
17
|
+
raise ::EacRubyUtils::PathsHash::EntryKeyError, "Entry key \"#{entry_key}\" is empty"
|
18
|
+
end
|
16
19
|
return r.map(&:to_sym) unless r.any?(&:blank?)
|
17
20
|
|
18
|
-
raise EntryKeyError,
|
21
|
+
raise ::EacRubyUtils::PathsHash::EntryKeyError,
|
22
|
+
"Entry key \"#{entry_key}\" has at least one blank part"
|
19
23
|
end
|
20
24
|
end
|
21
25
|
|
@@ -26,68 +30,27 @@ module EacRubyUtils
|
|
26
30
|
end
|
27
31
|
|
28
32
|
def [](entry_key)
|
29
|
-
root.read_entry(
|
33
|
+
root.read_entry(::EacRubyUtils::PathsHash::PathSearch.parse_entry_key(entry_key))
|
30
34
|
end
|
31
35
|
|
32
36
|
def []=(entry_key, entry_value)
|
33
|
-
root.write_entry(
|
37
|
+
root.write_entry(
|
38
|
+
::EacRubyUtils::PathsHash::PathSearch.parse_entry_key(entry_key), entry_value
|
39
|
+
)
|
34
40
|
end
|
35
41
|
|
36
|
-
|
37
|
-
|
38
|
-
private
|
39
|
-
|
40
|
-
attr_reader :data
|
41
|
-
|
42
|
-
class EntryKeyError < StandardError
|
42
|
+
def fetch(entry_key)
|
43
|
+
root.fetch(::EacRubyUtils::PathsHash::PathSearch.parse_entry_key(entry_key))
|
43
44
|
end
|
44
45
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
@data = source_hash.map { |k, v| [k.to_sym, v.is_a?(Hash) ? Node.new(v) : v] }.to_h
|
49
|
-
end
|
50
|
-
|
51
|
-
def to_h
|
52
|
-
data.map { |k, v| [k, v.is_a?(Node) ? v.to_h : v] }.to_h
|
53
|
-
end
|
54
|
-
|
55
|
-
def read_entry(path, current)
|
56
|
-
validate_path(path, current)
|
57
|
-
node_key = path.shift
|
58
|
-
node = data[node_key]
|
59
|
-
return (node.is_a?(Node) ? node.to_h : node) if path.empty?
|
60
|
-
return nil if node.blank?
|
61
|
-
return node.read_entry(path, current + [node_key]) if node.is_a?(Node)
|
62
|
-
|
63
|
-
raise(EntryKeyError,
|
64
|
-
"Path #{current.join(',')} is not a Node and path continues (#{current + path})")
|
65
|
-
end
|
66
|
-
|
67
|
-
def write_entry(path, value, current)
|
68
|
-
validate_path(path, current)
|
69
|
-
node_key = path.shift
|
70
|
-
write_entry_value(path, node_key, value, current)
|
71
|
-
end
|
72
|
-
|
73
|
-
private
|
46
|
+
def key?(entry_key)
|
47
|
+
root.entry?(::EacRubyUtils::PathsHash::PathSearch.parse_entry_key(entry_key))
|
48
|
+
end
|
74
49
|
|
75
|
-
|
76
|
-
if path.empty?
|
77
|
-
data[node_key] = value.is_a?(Hash) ? Node.new(value) : value
|
78
|
-
else
|
79
|
-
data[node_key] = Node.new({}) unless data[node_key].is_a?(Node)
|
80
|
-
data[node_key].write_entry(path, value, current + [node_key])
|
81
|
-
end
|
82
|
-
end
|
50
|
+
delegate :to_h, to: :root
|
83
51
|
|
84
|
-
|
85
|
-
path.assert_argument(Array, 'path')
|
86
|
-
current.assert_argument(Array, 'current')
|
87
|
-
raise EntryKeyError, 'Path is empty' if path.empty?
|
88
|
-
end
|
52
|
+
private
|
89
53
|
|
90
|
-
|
91
|
-
end
|
54
|
+
attr_reader :data
|
92
55
|
end
|
93
56
|
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
require 'eac_ruby_utils/paths_hash/entry_key_error'
|
5
|
+
|
6
|
+
module EacRubyUtils
|
7
|
+
class PathsHash
|
8
|
+
class Node
|
9
|
+
PATH_SEARCH_UNENDED_ERROR_MESSAGE = 'Path search is not a Node and is not ended'
|
10
|
+
|
11
|
+
def initialize(source_hash)
|
12
|
+
source_hash.assert_argument(Hash, 'source_hash')
|
13
|
+
@data = source_hash.map { |k, v| [k.to_sym, v.is_a?(Hash) ? Node.new(v) : v] }.to_h
|
14
|
+
end
|
15
|
+
|
16
|
+
def entry?(path_search)
|
17
|
+
return false unless data.key?(path_search.cursor)
|
18
|
+
return true if path_search.ended?
|
19
|
+
return data.fetch(path_search.cursor).entry?(path_search.succeeding) if
|
20
|
+
data.fetch(path_search.cursor).is_a?(Node)
|
21
|
+
|
22
|
+
false # Paths continue and there is not available nodes
|
23
|
+
end
|
24
|
+
|
25
|
+
def fetch(path_search)
|
26
|
+
if data.key?(path_search.cursor)
|
27
|
+
node = data.fetch(path_search.cursor)
|
28
|
+
return (node.is_a?(Node) ? node.to_h : node) if path_search.ended?
|
29
|
+
return nil if node.blank?
|
30
|
+
return node.fetch(path_search.succeeding) if node.is_a?(Node)
|
31
|
+
end
|
32
|
+
|
33
|
+
path_search.raise_error(PATH_SEARCH_UNENDED_ERROR_MESSAGE)
|
34
|
+
end
|
35
|
+
|
36
|
+
def to_h
|
37
|
+
data.map { |k, v| [k, v.is_a?(Node) ? v.to_h : v] }.to_h
|
38
|
+
end
|
39
|
+
|
40
|
+
def read_entry(path_search)
|
41
|
+
node = data[path_search.cursor]
|
42
|
+
return (node.is_a?(Node) ? node.to_h : node) if path_search.ended?
|
43
|
+
return nil if node.blank?
|
44
|
+
return node.read_entry(path_search.succeeding) if node.is_a?(Node)
|
45
|
+
|
46
|
+
path_search.raise_error(PATH_SEARCH_UNENDED_ERROR_MESSAGE)
|
47
|
+
end
|
48
|
+
|
49
|
+
def write_entry(path_search, value)
|
50
|
+
if path_search.ended?
|
51
|
+
data[path_search.cursor] = value.is_a?(Hash) ? self.class.new(value) : value
|
52
|
+
else
|
53
|
+
assert_data_node(path_search.cursor).write_entry(path_search.succeeding, value)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
private
|
58
|
+
|
59
|
+
attr_reader :data
|
60
|
+
|
61
|
+
def assert_data_node(key)
|
62
|
+
data[key] = self.class.new({}) unless data[key].is_a?(Node)
|
63
|
+
data[key]
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module EacRubyUtils
|
4
|
+
class PathsHash
|
5
|
+
class PathSearch
|
6
|
+
class << self
|
7
|
+
def parse_entry_key(string)
|
8
|
+
new(::EacRubyUtils::PathsHash.parse_entry_key(string), [])
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
common_constructor :current, :previous do
|
13
|
+
self.current = current.assert_argument(Array, 'current').freeze
|
14
|
+
self.previous = previous.assert_argument(Array, 'previous')
|
15
|
+
raise ::EacRubyUtils::PathsHash::EntryKeyError, 'Current is empty' if current.empty?
|
16
|
+
end
|
17
|
+
|
18
|
+
def cursor
|
19
|
+
current.first
|
20
|
+
end
|
21
|
+
|
22
|
+
def ended?
|
23
|
+
current.count <= 1
|
24
|
+
end
|
25
|
+
|
26
|
+
def raise_error(message)
|
27
|
+
raise ::EacRubyUtils::PathsHash::EntryKeyError, "#{message} (#{self})"
|
28
|
+
end
|
29
|
+
|
30
|
+
def succeeding
|
31
|
+
self.class.new(current[1..-1], previous + [cursor])
|
32
|
+
end
|
33
|
+
|
34
|
+
def to_s
|
35
|
+
"#{self.class}[Current: #{current}, Previous: #{previous}]"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/blank_not_blank'
|
4
|
+
|
5
|
+
RSpec.describe ::EacRubyUtils::BlankNotBlank do
|
6
|
+
let(:instance) { described_class.instance }
|
7
|
+
|
8
|
+
it do
|
9
|
+
expect { described_class.new }.to raise_error(::NoMethodError)
|
10
|
+
end
|
11
|
+
|
12
|
+
it { expect(instance).to be_present }
|
13
|
+
it { expect(instance).not_to be_blank }
|
14
|
+
it { expect(instance).to be_truthy }
|
15
|
+
it { expect(instance).to eq('') }
|
16
|
+
end
|
@@ -28,4 +28,19 @@ RSpec.describe ::EacRubyUtils::Configs do
|
|
28
28
|
|
29
29
|
it { expect(::YAML.load_file(storage_path)).to eq(parent: { child: 'value1' }) }
|
30
30
|
end
|
31
|
+
|
32
|
+
describe '#read' do
|
33
|
+
let(:present_key) { 'a.present.key' }
|
34
|
+
let(:blank_key) { 'a.blank.key' }
|
35
|
+
|
36
|
+
before do
|
37
|
+
instance[present_key] = 'A value'
|
38
|
+
instance[blank_key] = ''
|
39
|
+
instance.save
|
40
|
+
instance.load
|
41
|
+
end
|
42
|
+
|
43
|
+
it { expect(instance[present_key]).to be_present }
|
44
|
+
it { expect(instance[blank_key]).to be_present }
|
45
|
+
end
|
31
46
|
end
|
@@ -3,20 +3,20 @@
|
|
3
3
|
require 'eac_ruby_utils/paths_hash'
|
4
4
|
|
5
5
|
RSpec.describe ::EacRubyUtils::PathsHash do
|
6
|
-
|
7
|
-
|
8
|
-
{
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
child2: 'v2'
|
15
|
-
}
|
6
|
+
let(:source_hash) do
|
7
|
+
{
|
8
|
+
parent: {
|
9
|
+
child1: {
|
10
|
+
child1_1: 'v1_1',
|
11
|
+
child1_2: 'v1_2'
|
12
|
+
},
|
13
|
+
child2: 'v2'
|
16
14
|
}
|
17
|
-
|
18
|
-
|
15
|
+
}
|
16
|
+
end
|
17
|
+
let(:instance) { described_class.new(source_hash) }
|
19
18
|
|
19
|
+
describe '#[]' do
|
20
20
|
{
|
21
21
|
'parent.child1.child1_1' => 'v1_1',
|
22
22
|
'parent.child1.child1_2' => 'v1_2',
|
@@ -38,7 +38,7 @@ RSpec.describe ::EacRubyUtils::PathsHash do
|
|
38
38
|
end
|
39
39
|
|
40
40
|
describe '#[]=' do
|
41
|
-
let(:
|
41
|
+
let(:source_hash) { {} }
|
42
42
|
|
43
43
|
before do
|
44
44
|
instance['a.b.c'] = '123'
|
@@ -46,4 +46,43 @@ RSpec.describe ::EacRubyUtils::PathsHash do
|
|
46
46
|
|
47
47
|
it { expect(instance.to_h).to eq(a: { b: { c: '123' } }) }
|
48
48
|
end
|
49
|
+
|
50
|
+
describe '#fetch' do
|
51
|
+
{
|
52
|
+
'parent.child1.child1_1' => 'v1_1',
|
53
|
+
'parent.child1.child1_2' => 'v1_2',
|
54
|
+
'parent.child1.child1_2.no_exist' => ::EacRubyUtils::PathsHash::EntryKeyError,
|
55
|
+
'parent.child1.child1_3' => ::EacRubyUtils::PathsHash::EntryKeyError,
|
56
|
+
'parent.child2' => 'v2',
|
57
|
+
'no_exist' => ::EacRubyUtils::PathsHash::EntryKeyError,
|
58
|
+
'parent.child1' => {
|
59
|
+
child1_1: 'v1_1',
|
60
|
+
child1_2: 'v1_2'
|
61
|
+
}
|
62
|
+
}.each do |entry_key, expected_value|
|
63
|
+
if expected_value.is_a?(::Class) && expected_value < ::Exception
|
64
|
+
it "raise error #{expected_value}" do
|
65
|
+
expect { instance.fetch(entry_key) }.to raise_error(expected_value)
|
66
|
+
end
|
67
|
+
else
|
68
|
+
it "\#fetch return \"#{expected_value}\"" do
|
69
|
+
expect(instance.fetch(entry_key)).to eq(expected_value)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
describe '#key?' do
|
76
|
+
{
|
77
|
+
'parent.child1.child1_1' => true,
|
78
|
+
'parent.child1.child1_2' => true,
|
79
|
+
'parent.child1.child1_2.no_exist' => false,
|
80
|
+
'parent.child1.child1_3' => false,
|
81
|
+
'parent.child2' => true,
|
82
|
+
'no_exist' => false,
|
83
|
+
'parent.child1' => true
|
84
|
+
}.each do |entry_key, expected_value|
|
85
|
+
it { expect(instance.key?(entry_key)).to eq(expected_value) }
|
86
|
+
end
|
87
|
+
end
|
49
88
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: avm-tools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.73.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Esquilo Azul Company
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-10-
|
11
|
+
date: 2020-10-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aranha-parsers
|
@@ -374,6 +374,7 @@ files:
|
|
374
374
|
- lib/avm/instances/base/auto_values/data.rb
|
375
375
|
- lib/avm/instances/base/auto_values/database.rb
|
376
376
|
- lib/avm/instances/base/auto_values/filesystem.rb
|
377
|
+
- lib/avm/instances/base/auto_values/mailer.rb
|
377
378
|
- lib/avm/instances/base/auto_values/ruby.rb
|
378
379
|
- lib/avm/instances/base/auto_values/source.rb
|
379
380
|
- lib/avm/instances/base/auto_values/system.rb
|
@@ -551,6 +552,7 @@ files:
|
|
551
552
|
- lib/eac_launcher/version.rb
|
552
553
|
- template/avm/eac_rails_base0/apache_path/default.conf
|
553
554
|
- template/avm/eac_rails_base0/deploy/config/database.yml.template
|
555
|
+
- template/avm/eac_rails_base0/deploy/config/envvars.d/email.yml.template
|
554
556
|
- template/avm/eac_redmine_base0/deploy/config/install.sh.template
|
555
557
|
- template/avm/eac_redmine_base0/deploy/config/secrets.yml
|
556
558
|
- template/avm/eac_webapp_base0/apache_host/no_ssl.conf
|
@@ -857,11 +859,13 @@ files:
|
|
857
859
|
- vendor/eac_ruby_utils/eac_ruby_utils.gemspec
|
858
860
|
- vendor/eac_ruby_utils/lib/eac_ruby_utils.rb
|
859
861
|
- vendor/eac_ruby_utils/lib/eac_ruby_utils/arguments_consumer.rb
|
862
|
+
- vendor/eac_ruby_utils/lib/eac_ruby_utils/blank_not_blank.rb
|
860
863
|
- vendor/eac_ruby_utils/lib/eac_ruby_utils/boolean.rb
|
861
864
|
- vendor/eac_ruby_utils/lib/eac_ruby_utils/by_reference.rb
|
862
865
|
- vendor/eac_ruby_utils/lib/eac_ruby_utils/common_concern.rb
|
863
866
|
- vendor/eac_ruby_utils/lib/eac_ruby_utils/common_constructor.rb
|
864
867
|
- vendor/eac_ruby_utils/lib/eac_ruby_utils/configs.rb
|
868
|
+
- vendor/eac_ruby_utils/lib/eac_ruby_utils/configs/base.rb
|
865
869
|
- vendor/eac_ruby_utils/lib/eac_ruby_utils/configs/file.rb
|
866
870
|
- vendor/eac_ruby_utils/lib/eac_ruby_utils/console.rb
|
867
871
|
- vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs.rb
|
@@ -954,6 +958,9 @@ files:
|
|
954
958
|
- vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/time/default_time_zone_set.rb
|
955
959
|
- vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/time/local_time_zone.rb
|
956
960
|
- vendor/eac_ruby_utils/lib/eac_ruby_utils/paths_hash.rb
|
961
|
+
- vendor/eac_ruby_utils/lib/eac_ruby_utils/paths_hash/entry_key_error.rb
|
962
|
+
- vendor/eac_ruby_utils/lib/eac_ruby_utils/paths_hash/node.rb
|
963
|
+
- vendor/eac_ruby_utils/lib/eac_ruby_utils/paths_hash/path_search.rb
|
957
964
|
- vendor/eac_ruby_utils/lib/eac_ruby_utils/require_sub.rb
|
958
965
|
- vendor/eac_ruby_utils/lib/eac_ruby_utils/rspec.rb
|
959
966
|
- vendor/eac_ruby_utils/lib/eac_ruby_utils/rspec/conditional.rb
|
@@ -977,6 +984,7 @@ files:
|
|
977
984
|
- vendor/eac_ruby_utils/lib/eac_ruby_utils/version.rb
|
978
985
|
- vendor/eac_ruby_utils/lib/eac_ruby_utils/yaml.rb
|
979
986
|
- vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/arguments_consumer_spec.rb
|
987
|
+
- vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/blank_not_blank_spec.rb
|
980
988
|
- vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/common_concern_spec.rb
|
981
989
|
- vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/common_constructor_spec.rb
|
982
990
|
- vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/configs_spec.rb
|