avm-tools 0.99.1 → 0.100.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.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/lib/avm/configs.rb +6 -2
  3. data/lib/avm/instances/entry.rb +1 -1
  4. data/lib/avm/instances/entry_keys.rb +2 -0
  5. data/lib/avm/tools/runner/config.rb +17 -0
  6. data/lib/avm/tools/runner/config/load_path.rb +47 -0
  7. data/lib/avm/tools/version.rb +1 -1
  8. data/vendor/eac_cli/lib/eac_cli/config.rb +19 -0
  9. data/vendor/eac_cli/lib/eac_cli/config/entry.rb +46 -0
  10. data/vendor/eac_cli/lib/eac_cli/config/entry/options.rb +57 -0
  11. data/vendor/eac_cli/lib/eac_cli/config/entry/undefined.rb +26 -0
  12. data/vendor/eac_cli/lib/eac_cli/docopt_runner.rb +3 -8
  13. data/vendor/eac_cli/lib/eac_cli/docopt_runner/context.rb +18 -0
  14. data/vendor/eac_cli/lib/eac_cli/old_configs_bridge.rb +37 -0
  15. data/vendor/eac_cli/lib/eac_cli/version.rb +1 -1
  16. data/vendor/eac_config/lib/eac_config/entry.rb +7 -1
  17. data/vendor/eac_config/lib/eac_config/envvars_node.rb +25 -0
  18. data/vendor/eac_config/lib/eac_config/envvars_node/entry.rb +54 -0
  19. data/vendor/eac_config/lib/eac_config/load_path.rb +5 -13
  20. data/vendor/eac_config/lib/eac_config/node.rb +9 -2
  21. data/vendor/eac_config/lib/eac_config/node_entry.rb +2 -23
  22. data/vendor/eac_config/lib/eac_config/node_uri.rb +38 -0
  23. data/vendor/eac_config/lib/eac_config/old_configs.rb +1 -0
  24. data/vendor/eac_config/lib/eac_config/version.rb +1 -1
  25. data/vendor/eac_config/lib/eac_config/yaml_file_node.rb +9 -2
  26. data/vendor/eac_config/lib/eac_config/yaml_file_node/entry.rb +37 -0
  27. data/vendor/eac_config/spec/lib/eac_config/envvars_node/entry_spec.rb +14 -0
  28. data/vendor/eac_config/spec/lib/eac_config/envvars_node_spec.rb +40 -0
  29. data/vendor/eac_config/spec/lib/eac_config/yaml_file_node_spec_files/storage1.yaml +3 -1
  30. data/vendor/eac_config/spec/lib/eac_config/yaml_file_node_spec_files/storage1_2.yaml +2 -1
  31. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/runner.rb +1 -3
  32. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/version.rb +1 -1
  33. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/version.rb +1 -1
  34. metadata +16 -3
  35. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/contextualizable.rb +0 -16
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ad117874b0eb67142f85a2e4418a5bfc1ffe4b13b9ca5e055669238a1a48dc03
4
- data.tar.gz: fde307fe4e42f7a814ff2cb7d5f81059e60945e55584cfdcfbf0aad95824e7e9
3
+ metadata.gz: acd09c13ca7d0637196f933aadf90bb07ab9946f71a075f14a4f4fcf421f2377
4
+ data.tar.gz: db77e011115f9fcb1eb8bcc8003f1ea4b4055efa3a1996e73fce1b0cf569bf03
5
5
  SHA512:
6
- metadata.gz: c07bc41c85952a91374ca3f54be94ac22f475d798e1bd649162824f643dacf7cc77dfa4ee89c7280e9a515266a4b13432c76939f3bba63e92cc50cfadbe8238b
7
- data.tar.gz: ec10f8a6286610fd7df1cfc105da7b4e6103078fa0f35d19edf8775a2b0b6c26d2457bb9babdfaa5c16e25f071cd6464baceaffe44e28ccf1a453e26989fcc34
6
+ metadata.gz: 3d7954e5f0708686a8096a759fc51ac2f3eff7b539e07d5b35c425dede0f4d9b03fa4f1130f0f01b39e619ceff4c1ff43cf8b6d47d5f31c9e6363007de92ecf9
7
+ data.tar.gz: 2ca9bfaf366021f71954e27c4da9b8bcf6d05270e5120b04a58d30e42d57b142c2b2fec25eabb967638d7d1a6d0e8068f2a639bd916c3152ff50eed3018d9a6b
data/lib/avm/configs.rb CHANGED
@@ -1,13 +1,17 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'eac_cli/old_configs'
3
+ require 'eac_cli/old_configs_bridge'
4
4
 
5
5
  module Avm
6
6
  class << self
7
7
  attr_reader :configs_storage_path
8
8
 
9
9
  def configs
10
- @configs ||= ::EacCli::OldConfigs.new('avm-tools', configs_options)
10
+ @configs ||= ::EacCli::OldConfigsBridge.new('avm-tools', configs_options)
11
+ end
12
+
13
+ def configs_file_path
14
+ configs_storage_path || default_configs_file_path
11
15
  end
12
16
 
13
17
  def configs_options
@@ -46,7 +46,7 @@ module Avm
46
46
  end
47
47
 
48
48
  def write(value)
49
- ::Avm.configs.configs.write_entry(full_path, value)
49
+ ::Avm.configs.sub.entry(full_path).value = value
50
50
  end
51
51
  end
52
52
  end
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'eac_ruby_utils/core_ext'
4
+
3
5
  module Avm
4
6
  module Instances
5
7
  module EntryKeys
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/core_ext'
4
+
5
+ module Avm
6
+ module Tools
7
+ class Runner
8
+ class Config
9
+ require_sub __FILE__
10
+ runner_with :help, :subcommands do
11
+ desc 'Configuration utilities.'
12
+ subcommands
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/self'
4
+ require 'avm/core_ext'
5
+
6
+ module Avm
7
+ module Tools
8
+ class Runner
9
+ class Config
10
+ class LoadPath
11
+ runner_with :help do
12
+ desc 'Manipulate include path.'
13
+ arg_opt '-p', '--push', 'Add a path.'
14
+ end
15
+
16
+ def run
17
+ run_show
18
+ run_add
19
+ end
20
+
21
+ private
22
+
23
+ # @return [[EacCli::OldConfigsBridge]]
24
+ def config_node
25
+ ::Avm.configs.sub
26
+ end
27
+
28
+ def run_add
29
+ parsed.push.if_present do |v|
30
+ infov 'Path to add', v
31
+ config_node.load_path.push(v)
32
+ success 'Path included'
33
+ end
34
+ end
35
+
36
+ def run_show
37
+ infov 'Configuration path', config_node.path
38
+ infov 'Paths included', config_node.self_loaded_nodes.count
39
+ config_node.self_loaded_nodes.each do |loaded_node|
40
+ infov ' * ', loaded_node.url
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Avm
4
4
  module Tools
5
- VERSION = '0.99.1'
5
+ VERSION = '0.100.0'
6
6
  end
7
7
  end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_config/envvars_node'
4
+ require 'eac_config/yaml_file_node'
5
+
6
+ module EacCli
7
+ class Config
8
+ require_sub __FILE__
9
+ attr_reader :sub
10
+
11
+ def initialize(sub_node)
12
+ @sub = sub_node
13
+ end
14
+
15
+ def entry(path, options = {})
16
+ ::EacCli::Config::Entry.new(self, path, options)
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_cli/speaker'
4
+ require 'eac_config/entry_path'
5
+ require 'eac_ruby_utils/core_ext'
6
+
7
+ module EacCli
8
+ class Config
9
+ class Entry
10
+ require_sub __FILE__, include_modules: true
11
+ enable_listable
12
+ enable_simple_cache
13
+ include ::EacCli::Speaker
14
+
15
+ common_constructor :config, :path, :options do
16
+ self.path = ::EacConfig::EntryPath.assert(path)
17
+ self.options = ::EacCli::Config::Entry::Options.new(options)
18
+ end
19
+
20
+ def value
21
+ return sub_value_to_return if sub_entry.found?
22
+ return nil unless options.required?
23
+
24
+ puts "|#{sub_entry.path}|"
25
+
26
+ input_value
27
+ end
28
+
29
+ private
30
+
31
+ def sub_value_to_return
32
+ sub_entry.value.presence || ::EacRubyUtils::BlankNotBlank.instance
33
+ end
34
+
35
+ def sub_entry_uncached
36
+ config.sub.entry(path)
37
+ end
38
+
39
+ def input_value_uncached
40
+ r = send("#{options.type}_value")
41
+ sub_entry.value = r if options.store?
42
+ r
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,57 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module EacCli
6
+ class Config
7
+ class Entry
8
+ class Options
9
+ enable_simple_cache
10
+ enable_listable
11
+
12
+ lists.add_symbol :type, :undefined
13
+
14
+ DEFAULT_VALUES = {
15
+ before_input: nil, bool: false, list: false, noecho: false, noenv: false, noinput: false,
16
+ required: true, store: true, type: TYPE_UNDEFINED, validator: nil
17
+ }.freeze
18
+
19
+ lists.add_symbol :option, *DEFAULT_VALUES.keys
20
+
21
+ common_constructor :options do
22
+ self.options = self.class.lists.option.hash_keys_validate!(options)
23
+ end
24
+
25
+ delegate :to_h, to: :options
26
+
27
+ def [](key)
28
+ values.fetch(key.to_sym)
29
+ end
30
+
31
+ def request_input_options
32
+ values.slice(:bool, :list, :noecho)
33
+ end
34
+
35
+ DEFAULT_VALUES.each do |attr, default_value|
36
+ define_method(attr.to_s + ([true, false].include?(default_value) ? '?' : '')) do
37
+ self[attr]
38
+ end
39
+ end
40
+
41
+ private
42
+
43
+ def values_uncached
44
+ consumer = options.to_options_consumer
45
+ r = {}
46
+ DEFAULT_VALUES.each do |key, default_value|
47
+ value = consumer.consume(key)
48
+ value = default_value if value.nil?
49
+ r[key] = value
50
+ end
51
+ consumer.validate
52
+ r
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module EacCli
6
+ class Config
7
+ class Entry
8
+ module Undefined
9
+ private
10
+
11
+ def undefined_value
12
+ loop do
13
+ entry_value = undefined_value_no_loop
14
+ next unless options[:validator].if_present(true) { |v| v.call(entry_value) }
15
+
16
+ return entry_value
17
+ end
18
+ end
19
+
20
+ def undefined_value_no_loop
21
+ request_input("Value for entry \"#{path}\"", options.request_input_options)
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -1,17 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'active_support/core_ext/hash/indifferent_access'
4
- require 'active_support/core_ext/hash/slice'
3
+ require 'eac_ruby_utils/core_ext'
5
4
  require 'docopt'
6
- require 'eac_ruby_utils/contextualizable'
7
- require 'eac_ruby_utils/patches/hash/sym_keys_hash'
8
- Dir["#{__dir__}/#{::File.basename(__FILE__, '.*')}/_*.rb"].sort.each do |partial|
9
- require partial
10
- end
11
5
 
12
6
  module EacCli
13
7
  class DocoptRunner
14
- include ::EacRubyUtils::Contextualizable
8
+ require_sub __FILE__
9
+ include ::EacCli::DocoptRunner::Context
15
10
 
16
11
  class << self
17
12
  def create(settings = {})
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EacCli
4
+ class DocoptRunner
5
+ # Provides the method context which search and call a method in self and ancestor objects.
6
+ module Context
7
+ def context(method)
8
+ current = self
9
+ while current
10
+ return current.send(method) if current.respond_to?(method)
11
+
12
+ current = current.respond_to?(:parent) ? current.parent : nil
13
+ end
14
+ raise "Context method \"#{method}\" not found for #{self.class}"
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_cli/config'
4
+ require 'eac_ruby_utils/core_ext'
5
+
6
+ module EacCli
7
+ class OldConfigsBridge < ::EacCli::Config
8
+ ENTRY_KEY = 'core.store_passwords'
9
+
10
+ class << self
11
+ def new_configs_path(configs_key, options)
12
+ options[:storage_path] || ::File.join(ENV['HOME'], '.config', configs_key, 'settings.yml')
13
+ end
14
+ end
15
+
16
+ def initialize(configs_key, options = {})
17
+ options.assert_argument(::Hash, 'options')
18
+ envvar_node = ::EacConfig::EnvvarsNode.new
19
+ file_node = ::EacConfig::YamlFileNode.new(self.class.new_configs_path(configs_key, options))
20
+ envvar_node.load_path.push(file_node.url)
21
+ envvar_node.write_node = file_node
22
+ super(envvar_node)
23
+ end
24
+
25
+ def read_entry(entry_key, options = {})
26
+ entry(entry_key, options).value
27
+ end
28
+
29
+ def read_password(entry_key, options = {})
30
+ entry(entry_key, options.merge(noecho: true, store: store_passwords?)).value
31
+ end
32
+
33
+ def store_passwords?
34
+ read_entry(ENTRY_KEY, bool: true)
35
+ end
36
+ end
37
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacCli
4
- VERSION = '0.17.0'
4
+ VERSION = '0.18.0'
5
5
  end
@@ -22,7 +22,13 @@ module EacConfig
22
22
  node_entry.if_present(&:value)
23
23
  end
24
24
 
25
- delegate :value=, to: :root_node
25
+ def value=(a_value)
26
+ write_node.self_entry(path).value = a_value
27
+ end
28
+
29
+ def write_node
30
+ root_node.write_node || root_node
31
+ end
26
32
 
27
33
  private
28
34
 
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'addressable'
4
+ require 'eac_config/node'
5
+ require 'eac_ruby_utils/core_ext'
6
+
7
+ module EacConfig
8
+ # A node that read/write entries from environment variables.
9
+ class EnvvarsNode
10
+ require_sub __FILE__
11
+ include ::EacConfig::Node
12
+
13
+ URI = ::Addressable::URI.parse('self://envvars')
14
+
15
+ class << self
16
+ def from_uri(uri)
17
+ return new if uri == URI
18
+ end
19
+ end
20
+
21
+ def url
22
+ URI
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_config/entry_path'
4
+ require 'eac_config/node_entry'
5
+ require 'eac_ruby_utils/blank_not_blank'
6
+ require 'eac_ruby_utils/core_ext'
7
+ require 'eac_ruby_utils/yaml'
8
+
9
+ module EacConfig
10
+ class EnvvarsNode
11
+ class Entry < ::EacConfig::NodeEntry
12
+ class << self
13
+ def entry_path_to_envvar_name(path)
14
+ ::EacConfig::EntryPath.assert(path).parts.join('_').gsub(/[^a-z0-9_]/i, '')
15
+ .gsub(/\A_+/, '').gsub(/_+\z/, '').gsub(/_{2,}/, '_').upcase
16
+ end
17
+
18
+ def from_value(string)
19
+ return nil if string.nil?
20
+ return ::EacRubyUtils::Yaml.load(string) if string.start_with?('---')
21
+
22
+ string
23
+ end
24
+
25
+ def to_value(object)
26
+ return nil if object.nil?
27
+ return object if object.is_a?(String)
28
+
29
+ ::EacRubyUtils::Yaml.dump(object)
30
+ end
31
+ end
32
+
33
+ enable_simple_cache
34
+
35
+ def found?
36
+ ENV.key?(envvar_name)
37
+ end
38
+
39
+ def value
40
+ self.class.from_value(ENV[envvar_name])
41
+ end
42
+
43
+ def value=(a_value)
44
+ ENV[envvar_name] = self.class.to_value(a_value)
45
+ end
46
+
47
+ private
48
+
49
+ def envvar_name_uncached
50
+ self.class.entry_path_to_envvar_name(path)
51
+ end
52
+ end
53
+ end
54
+ end
@@ -6,17 +6,6 @@ require 'eac_ruby_utils/core_ext'
6
6
  module EacConfig
7
7
  class LoadPath
8
8
  ENTRY_PATH = ::EacConfig::EntryPath.assert(%w[load_path])
9
- PATH_SEPARATOR = ':'
10
-
11
- class << self
12
- def paths_to_string(paths)
13
- paths.map(&:to_s).join(PATH_SEPARATOR)
14
- end
15
-
16
- def string_to_paths(string)
17
- string.to_s.split(PATH_SEPARATOR)
18
- end
19
- end
20
9
 
21
10
  common_constructor :node
22
11
 
@@ -26,11 +15,14 @@ module EacConfig
26
15
 
27
16
  # @return [Array<String>]
28
17
  def paths
29
- self.class.string_to_paths(entry.value)
18
+ r = entry.value
19
+ r.is_a?(::Array) ? r : []
30
20
  end
31
21
 
32
22
  def push(new_path)
33
- entry.value = self.class.paths_to_string(paths + [new_path])
23
+ entry.value = paths + [new_path]
34
24
  end
25
+
26
+ delegate :to_s, to: :paths
35
27
  end
36
28
  end
@@ -5,10 +5,13 @@ require 'eac_config/entry_path'
5
5
  require 'eac_config/load_path'
6
6
  require 'eac_config/load_nodes_search'
7
7
  require 'eac_config/node_entry'
8
+ require 'eac_config/node_uri'
8
9
  require 'eac_ruby_utils/core_ext'
9
10
 
10
11
  module EacConfig
11
12
  module Node
13
+ attr_accessor :write_node
14
+
12
15
  common_concern do
13
16
  enable_abstract_methods
14
17
  include ::Comparable
@@ -31,7 +34,11 @@ module EacConfig
31
34
  # Return a entry which search values only in the self node.
32
35
  # @return [EacConfig::NodeEntry]
33
36
  def self_entry(path)
34
- ::EacConfig::NodeEntry.new(self, path)
37
+ self_entry_class.new(self, path)
38
+ end
39
+
40
+ def self_entry_class
41
+ self.class.const_get('Entry')
35
42
  end
36
43
 
37
44
  # @return [Array<EacConfig::Node>]
@@ -47,7 +54,7 @@ module EacConfig
47
54
  private
48
55
 
49
56
  def load_node(node_path)
50
- self.class.new(node_path.to_pathname.expand_path(path.parent))
57
+ ::EacConfig::NodeUri.new(node_path, url).instanciate
51
58
  end
52
59
  end
53
60
  end
@@ -7,33 +7,12 @@ require 'eac_ruby_utils/core_ext'
7
7
  module EacConfig
8
8
  # A entry which search values only in the source node.
9
9
  class NodeEntry
10
+ enable_abstract_methods
10
11
  enable_simple_cache
11
12
  common_constructor :node, :path do
12
13
  self.path = ::EacConfig::EntryPath.assert(path)
13
14
  end
14
15
 
15
- def found?
16
- paths_hash.key?(to_paths_hash_key)
17
- end
18
-
19
- def value
20
- paths_hash[to_paths_hash_key]
21
- end
22
-
23
- def value=(a_value)
24
- paths_hash[to_paths_hash_key] = a_value
25
- node.persist_data(paths_hash.root.to_h)
26
- end
27
-
28
- private
29
-
30
- # @return [EacConfig::PathsHash]
31
- def paths_hash_uncached
32
- ::EacConfig::PathsHash.new(node.data)
33
- end
34
-
35
- def to_paths_hash_key
36
- path.parts.join('.')
37
- end
16
+ abstract_methods :found?, :value, :value=
38
17
  end
39
18
  end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EacConfig
4
+ class NodeUri
5
+ enable_simple_cache
6
+ common_constructor :source, :loader_uri, default: [nil]
7
+
8
+ def available_node_classes
9
+ require 'eac_config/envvars_node'
10
+ require 'eac_config/yaml_file_node'
11
+ [::EacConfig::EnvvarsNode, ::EacConfig::YamlFileNode]
12
+ end
13
+
14
+ def instanciate
15
+ available_node_classes.lazy.map { |k| k.from_uri(self) }.find(&:present?) ||
16
+ raise("No class mapped for \"#{to_addressable}\"")
17
+ end
18
+
19
+ delegate :to_s, to: :to_addressable
20
+
21
+ private
22
+
23
+ def to_addressable_uncached
24
+ r = ::Addressable::URI.parse(source)
25
+ path = r.path.to_pathname
26
+ r.path = path.expand_path(loader_uri_path_directory).to_path if path.relative?
27
+ r.scheme = 'file' if r.scheme.blank?
28
+ r
29
+ end
30
+
31
+ def loader_uri_path_directory
32
+ r = loader_uri.path
33
+ raise ".loader_uri \"#{loader_uri}\" has no path (Source: \"#{source}\")" if r.blank?
34
+
35
+ r.to_pathname.parent
36
+ end
37
+ end
38
+ end
@@ -8,6 +8,7 @@ require 'eac_config/paths_hash'
8
8
  require 'eac_ruby_utils/simple_cache'
9
9
 
10
10
  module EacConfig
11
+ # @deprecated Use {EacConfig::YamlFileNode} instead.
11
12
  class OldConfigs
12
13
  include ::EacRubyUtils::SimpleCache
13
14
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacConfig
4
- VERSION = '0.3.0'
4
+ VERSION = '0.4.0'
5
5
  end
@@ -7,20 +7,27 @@ require 'eac_ruby_utils/yaml'
7
7
 
8
8
  module EacConfig
9
9
  class YamlFileNode
10
+ require_sub __FILE__
10
11
  include ::EacConfig::Node
11
12
 
13
+ class << self
14
+ def from_uri(uri)
15
+ return new(uri.to_addressable.path) if uri.to_addressable.scheme == 'file'
16
+ end
17
+ end
18
+
12
19
  common_constructor :path do
13
20
  self.path = path.to_pathname
14
21
  end
15
22
 
16
23
  def data
17
- @data ||= ::EacRubyUtils::Yaml.load_file(assert_path)
24
+ @data ||= ::EacRubyUtils::Yaml.load_file(assert_path) || {}
18
25
  end
19
26
 
20
27
  def persist_data(new_data)
21
28
  path.parent.mkpath
22
29
  ::EacRubyUtils::Yaml.dump_file(path, new_data)
23
- reset_cache(:data)
30
+ @data = nil
24
31
  end
25
32
 
26
33
  def url
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_config/entry_path'
4
+ require 'eac_config/node_entry'
5
+ require 'eac_ruby_utils/core_ext'
6
+
7
+ module EacConfig
8
+ class YamlFileNode
9
+ class Entry < ::EacConfig::NodeEntry
10
+ enable_simple_cache
11
+
12
+ def found?
13
+ paths_hash.key?(to_paths_hash_key)
14
+ end
15
+
16
+ def value
17
+ paths_hash[to_paths_hash_key]
18
+ end
19
+
20
+ def value=(a_value)
21
+ paths_hash[to_paths_hash_key] = a_value
22
+ node.persist_data(paths_hash.root.to_h)
23
+ end
24
+
25
+ private
26
+
27
+ # @return [EacConfig::PathsHash]
28
+ def paths_hash_uncached
29
+ ::EacConfig::PathsHash.new(node.data)
30
+ end
31
+
32
+ def to_paths_hash_key
33
+ path.parts.join('.')
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_config/envvars_node/entry'
4
+
5
+ RSpec.describe ::EacConfig::EnvvarsNode::Entry do
6
+ describe '#entry_key_to_envvar_name' do
7
+ {
8
+ 'a.entry.value' => 'A_ENTRY_VALUE',
9
+ 'appli-cation_0.var_one' => 'APPLICATION_0_VAR_ONE'
10
+ }.each do |input, expected_result|
11
+ it { expect(described_class.entry_path_to_envvar_name(input)).to eq(expected_result) }
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_config/envvars_node'
4
+
5
+ RSpec.describe ::EacConfig::EnvvarsNode do
6
+ let(:instance) { described_class.new }
7
+
8
+ before do
9
+ ENV['COMMON'] = 'AAA'
10
+ ENV['BLANK'] = ''
11
+ ENV.delete('NO_EXIST')
12
+ end
13
+
14
+ context 'with common entry' do
15
+ let(:entry) { instance.entry('common') }
16
+
17
+ it { expect(entry).to be_a(::EacConfig::Entry) }
18
+ it { expect(entry.value).to eq('AAA') }
19
+ it { expect(entry.found_node).to eq(instance) }
20
+ it { expect(entry).to be_found }
21
+ end
22
+
23
+ context 'with blank entry' do
24
+ let(:entry) { instance.entry('blank') }
25
+
26
+ it { expect(entry).to be_a(::EacConfig::Entry) }
27
+ it { expect(entry.value).to eq('') }
28
+ it { expect(entry.found_node).to eq(instance) }
29
+ it { expect(entry).to be_found }
30
+ end
31
+
32
+ context 'with not existing entry' do
33
+ let(:entry) { instance.entry('no.exist') }
34
+
35
+ it { expect(entry).to be_a(::EacConfig::Entry) }
36
+ it { expect(entry.value).to eq(nil) }
37
+ it { expect(entry.found_node).to eq(nil) }
38
+ it { expect(entry).not_to be_found }
39
+ end
40
+ end
@@ -1,4 +1,6 @@
1
1
  ---
2
2
  common: AAA
3
- load_path: storage1_1.yaml:%%STORAGE1_2_ABSOLUTE_PATH%%
3
+ load_path:
4
+ - storage1_1.yaml
5
+ - %%STORAGE1_2_ABSOLUTE_PATH%%
4
6
  storage1: storage1
@@ -1,3 +1,4 @@
1
1
  ---
2
- load_path: ./storage1_2/storage1_2_1.yaml
2
+ load_path:
3
+ - ./storage1_2/storage1_2_1.yaml
3
4
  storage1_2: storage1_2
@@ -1,8 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'eac_cli/runner_with/help'
4
- require 'eac_cli/runner_with/subcommands'
5
- require 'eac_ruby_utils/core_ext'
3
+ require 'eac_cli/core_ext'
6
4
 
7
5
  module EacRubyBase0
8
6
  module Runner
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacRubyBase0
4
- VERSION = '0.7.2'
4
+ VERSION = '0.7.3'
5
5
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacRubyUtils
4
- VERSION = '0.64.0'
4
+ VERSION = '0.65.0'
5
5
  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.99.1
4
+ version: 0.100.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: 2021-05-26 00:00:00.000000000 Z
11
+ date: 2021-06-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aranha-parsers
@@ -612,6 +612,8 @@ files:
612
612
  - lib/avm/tools/runner/app_src/test.rb
613
613
  - lib/avm/tools/runner/app_src/update.rb
614
614
  - lib/avm/tools/runner/app_src/version_bump.rb
615
+ - lib/avm/tools/runner/config.rb
616
+ - lib/avm/tools/runner/config/load_path.rb
615
617
  - lib/avm/tools/runner/eac_asciidoctor_base0.rb
616
618
  - lib/avm/tools/runner/eac_rails_base0.rb
617
619
  - lib/avm/tools/runner/eac_redmine_base0.rb
@@ -704,6 +706,10 @@ files:
704
706
  - vendor/eac_cli/Gemfile
705
707
  - vendor/eac_cli/eac_cli.gemspec
706
708
  - vendor/eac_cli/lib/eac_cli.rb
709
+ - vendor/eac_cli/lib/eac_cli/config.rb
710
+ - vendor/eac_cli/lib/eac_cli/config/entry.rb
711
+ - vendor/eac_cli/lib/eac_cli/config/entry/options.rb
712
+ - vendor/eac_cli/lib/eac_cli/config/entry/undefined.rb
707
713
  - vendor/eac_cli/lib/eac_cli/core_ext.rb
708
714
  - vendor/eac_cli/lib/eac_cli/default_runner.rb
709
715
  - vendor/eac_cli/lib/eac_cli/definition.rb
@@ -723,11 +729,13 @@ files:
723
729
  - vendor/eac_cli/lib/eac_cli/docopt_runner/_doc.rb
724
730
  - vendor/eac_cli/lib/eac_cli/docopt_runner/_settings.rb
725
731
  - vendor/eac_cli/lib/eac_cli/docopt_runner/_subcommands.rb
732
+ - vendor/eac_cli/lib/eac_cli/docopt_runner/context.rb
726
733
  - vendor/eac_cli/lib/eac_cli/old_configs.rb
727
734
  - vendor/eac_cli/lib/eac_cli/old_configs/entry_reader.rb
728
735
  - vendor/eac_cli/lib/eac_cli/old_configs/password_entry_reader.rb
729
736
  - vendor/eac_cli/lib/eac_cli/old_configs/read_entry_options.rb
730
737
  - vendor/eac_cli/lib/eac_cli/old_configs/store_passwords_entry_reader.rb
738
+ - vendor/eac_cli/lib/eac_cli/old_configs_bridge.rb
731
739
  - vendor/eac_cli/lib/eac_cli/parser.rb
732
740
  - vendor/eac_cli/lib/eac_cli/parser/alternative.rb
733
741
  - vendor/eac_cli/lib/eac_cli/parser/alternative/argv.rb
@@ -777,10 +785,13 @@ files:
777
785
  - vendor/eac_config/lib/eac_config.rb
778
786
  - vendor/eac_config/lib/eac_config/entry.rb
779
787
  - vendor/eac_config/lib/eac_config/entry_path.rb
788
+ - vendor/eac_config/lib/eac_config/envvars_node.rb
789
+ - vendor/eac_config/lib/eac_config/envvars_node/entry.rb
780
790
  - vendor/eac_config/lib/eac_config/load_nodes_search.rb
781
791
  - vendor/eac_config/lib/eac_config/load_path.rb
782
792
  - vendor/eac_config/lib/eac_config/node.rb
783
793
  - vendor/eac_config/lib/eac_config/node_entry.rb
794
+ - vendor/eac_config/lib/eac_config/node_uri.rb
784
795
  - vendor/eac_config/lib/eac_config/old_configs.rb
785
796
  - vendor/eac_config/lib/eac_config/old_configs/base.rb
786
797
  - vendor/eac_config/lib/eac_config/old_configs/file.rb
@@ -790,7 +801,10 @@ files:
790
801
  - vendor/eac_config/lib/eac_config/paths_hash/path_search.rb
791
802
  - vendor/eac_config/lib/eac_config/version.rb
792
803
  - vendor/eac_config/lib/eac_config/yaml_file_node.rb
804
+ - vendor/eac_config/lib/eac_config/yaml_file_node/entry.rb
793
805
  - vendor/eac_config/spec/lib/eac_config/entry_path_spec.rb
806
+ - vendor/eac_config/spec/lib/eac_config/envvars_node/entry_spec.rb
807
+ - vendor/eac_config/spec/lib/eac_config/envvars_node_spec.rb
794
808
  - vendor/eac_config/spec/lib/eac_config/old_configs_spec.rb
795
809
  - vendor/eac_config/spec/lib/eac_config/paths_hash_spec.rb
796
810
  - vendor/eac_config/spec/lib/eac_config/yaml_file_node_spec.rb
@@ -1104,7 +1118,6 @@ files:
1104
1118
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/common_constructor/class_initialize.rb
1105
1119
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/common_constructor/instance_initialize.rb
1106
1120
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/common_constructor/super_args.rb
1107
- - vendor/eac_ruby_utils/lib/eac_ruby_utils/contextualizable.rb
1108
1121
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/core_ext.rb
1109
1122
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/custom_format.rb
1110
1123
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/envs.rb
@@ -1,16 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module EacRubyUtils
4
- # Provides the method context which search and call a method in self and ancestor objects.
5
- module Contextualizable
6
- def context(method)
7
- current = self
8
- while current
9
- return current.send(method) if current.respond_to?(method)
10
-
11
- current = current.respond_to?(:parent) ? current.parent : nil
12
- end
13
- raise "Context method \"#{method}\" not found for #{self.class}"
14
- end
15
- end
16
- end