avm-tools 0.121.2 → 0.122.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +3 -0
  3. data/lib/avm/tools/runner/app_src/info.rb +19 -0
  4. data/lib/avm/tools/version.rb +1 -1
  5. metadata +2 -38
  6. data/sub/eac_config/Gemfile +0 -5
  7. data/sub/eac_config/eac_config.gemspec +0 -19
  8. data/sub/eac_config/lib/eac_config/entry.rb +0 -53
  9. data/sub/eac_config/lib/eac_config/entry_path.rb +0 -41
  10. data/sub/eac_config/lib/eac_config/envvars_node/entry.rb +0 -54
  11. data/sub/eac_config/lib/eac_config/envvars_node.rb +0 -25
  12. data/sub/eac_config/lib/eac_config/load_nodes_search.rb +0 -39
  13. data/sub/eac_config/lib/eac_config/load_path.rb +0 -28
  14. data/sub/eac_config/lib/eac_config/node.rb +0 -67
  15. data/sub/eac_config/lib/eac_config/node_entry.rb +0 -22
  16. data/sub/eac_config/lib/eac_config/node_uri.rb +0 -38
  17. data/sub/eac_config/lib/eac_config/old_configs/base.rb +0 -43
  18. data/sub/eac_config/lib/eac_config/old_configs/file.rb +0 -47
  19. data/sub/eac_config/lib/eac_config/old_configs.rb +0 -75
  20. data/sub/eac_config/lib/eac_config/paths_hash/entry_key_error.rb +0 -8
  21. data/sub/eac_config/lib/eac_config/paths_hash/node.rb +0 -67
  22. data/sub/eac_config/lib/eac_config/paths_hash/path_search.rb +0 -39
  23. data/sub/eac_config/lib/eac_config/paths_hash.rb +0 -63
  24. data/sub/eac_config/lib/eac_config/rspec/setup.rb +0 -65
  25. data/sub/eac_config/lib/eac_config/rspec.rb +0 -9
  26. data/sub/eac_config/lib/eac_config/version.rb +0 -5
  27. data/sub/eac_config/lib/eac_config/yaml_file_node/entry.rb +0 -36
  28. data/sub/eac_config/lib/eac_config/yaml_file_node.rb +0 -47
  29. data/sub/eac_config/lib/eac_config.rb +0 -7
  30. data/sub/eac_config/spec/lib/eac_config/entry_path_spec.rb +0 -30
  31. data/sub/eac_config/spec/lib/eac_config/envvars_node/entry_spec.rb +0 -14
  32. data/sub/eac_config/spec/lib/eac_config/envvars_node_spec.rb +0 -40
  33. data/sub/eac_config/spec/lib/eac_config/old_configs_spec.rb +0 -46
  34. data/sub/eac_config/spec/lib/eac_config/paths_hash_spec.rb +0 -88
  35. data/sub/eac_config/spec/lib/eac_config/yaml_file_node_spec.rb +0 -52
  36. data/sub/eac_config/spec/lib/eac_config/yaml_file_node_spec_files/storage1.yaml +0 -6
  37. data/sub/eac_config/spec/lib/eac_config/yaml_file_node_spec_files/storage1_1.yaml +0 -2
  38. data/sub/eac_config/spec/lib/eac_config/yaml_file_node_spec_files/storage1_2/storage1_2_1.yaml +0 -2
  39. data/sub/eac_config/spec/lib/eac_config/yaml_file_node_spec_files/storage1_2.yaml +0 -4
  40. data/sub/eac_config/spec/rubocop_spec.rb +0 -3
  41. data/sub/eac_config/spec/spec_helper.rb +0 -4
@@ -1,75 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'active_support/core_ext/string'
4
- require 'yaml'
5
- require 'eac_config/old_configs/file'
6
- require 'eac_ruby_utils/patches/hash/sym_keys_hash'
7
- require 'eac_config/paths_hash'
8
- require 'eac_ruby_utils/simple_cache'
9
-
10
- module EacConfig
11
- # @deprecated Use {EacConfig::YamlFileNode} instead.
12
- class OldConfigs
13
- include ::EacRubyUtils::SimpleCache
14
-
15
- attr_reader :configs_key, :options
16
-
17
- # Valid options: [:storage_path]
18
- def initialize(configs_key, options = {})
19
- @configs_key = configs_key
20
- @options = options.to_sym_keys_hash.freeze
21
- load
22
- end
23
-
24
- delegate :clear, to: :file
25
-
26
- delegate :save, to: :file
27
-
28
- delegate :load, to: :file
29
-
30
- def []=(entry_key, entry_value)
31
- write_entry(entry_key, entry_value)
32
- end
33
-
34
- def write_entry(entry_key, entry_value)
35
- file.write(entry_key, entry_value)
36
- end
37
-
38
- def [](entry_key)
39
- read_entry(entry_key)
40
- end
41
-
42
- def read_entry(entry_key)
43
- file.read(entry_key)
44
- end
45
-
46
- delegate :autosave?, to: :file
47
-
48
- private
49
-
50
- attr_accessor :data
51
-
52
- def file_uncached
53
- ::EacConfig::OldConfigs::File.new(
54
- storage_path, options
55
- )
56
- end
57
-
58
- def storage_path_uncached
59
- path = options_storage_path || default_storage_path
60
- return path if ::File.exist?(path) && ::File.size(path).positive?
61
-
62
- ::FileUtils.mkdir_p(::File.dirname(path))
63
- ::File.write(path, {}.to_yaml)
64
- path
65
- end
66
-
67
- def options_storage_path
68
- options[:storage_path]
69
- end
70
-
71
- def default_storage_path
72
- ::File.join(ENV['HOME'], '.config', configs_key, 'settings.yml')
73
- end
74
- end
75
- end
@@ -1,8 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module EacConfig
4
- class PathsHash
5
- class EntryKeyError < StandardError
6
- end
7
- end
8
- end
@@ -1,67 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_ruby_utils/core_ext'
4
- require 'eac_config/paths_hash/entry_key_error'
5
-
6
- module EacConfig
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.transform_values { |v| v.is_a?(Node) ? v.to_h : v }
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
@@ -1,39 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module EacConfig
4
- class PathsHash
5
- class PathSearch
6
- class << self
7
- def parse_entry_key(string)
8
- new(::EacConfig::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 ::EacConfig::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 ::EacConfig::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
@@ -1,63 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_ruby_utils/core_ext'
4
-
5
- module EacConfig
6
- class PathsHash
7
- require_sub __FILE__
8
-
9
- class << self
10
- def parse_entry_key(entry_key)
11
- r = entry_key.to_s.strip
12
- raise ::EacConfig::PathsHash::EntryKeyError, 'Entry key cannot start or end with dot' if
13
- r.start_with?('.') || r.end_with?('.')
14
-
15
- r = r.split('.').map(&:strip)
16
- if r.empty?
17
- raise ::EacConfig::PathsHash::EntryKeyError, "Entry key \"#{entry_key}\" is empty"
18
- end
19
- return r.map(&:to_sym) unless r.any?(&:blank?)
20
-
21
- raise ::EacConfig::PathsHash::EntryKeyError,
22
- "Entry key \"#{entry_key}\" has at least one blank part"
23
- end
24
- end
25
-
26
- attr_reader :root
27
-
28
- def initialize(source_hash = {})
29
- @root = Node.new(source_hash)
30
- end
31
-
32
- def [](entry_key)
33
- root.read_entry(::EacConfig::PathsHash::PathSearch.parse_entry_key(entry_key))
34
- end
35
-
36
- def []=(entry_key, entry_value)
37
- root.write_entry(
38
- ::EacConfig::PathsHash::PathSearch.parse_entry_key(entry_key), entry_value
39
- )
40
- end
41
-
42
- def fetch(entry_key)
43
- root.fetch(::EacConfig::PathsHash::PathSearch.parse_entry_key(entry_key))
44
- end
45
-
46
- def key?(entry_key)
47
- root.entry?(::EacConfig::PathsHash::PathSearch.parse_entry_key(entry_key))
48
- end
49
-
50
- delegate :to_h, to: :root
51
-
52
- # @return [EacConfig::PathsHash
53
- def write(entry_key, entry_value)
54
- self[entry_key] = entry_value
55
-
56
- self
57
- end
58
-
59
- private
60
-
61
- attr_reader :data
62
- end
63
- end
@@ -1,65 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_ruby_utils/core_ext'
4
- require 'eac_ruby_utils/fs/temp'
5
- require 'eac_config/envvars_node'
6
- require 'eac_config/node'
7
- require 'eac_config/yaml_file_node'
8
-
9
- module EacConfig
10
- module Rspec
11
- module Setup
12
- def self.extended(obj)
13
- obj.rspec_config.around do |example|
14
- obj.on_envvars_load_path_clean(example)
15
- end
16
- end
17
-
18
- def on_envvars_load_path_clean(example)
19
- old_value = envvars_load_path_entry.value
20
- begin
21
- envvars_load_path_entry.value = old_value = []
22
- example.run
23
- ensure
24
- envvars_load_path_entry.value = old_value
25
- end
26
- end
27
-
28
- def envvars_load_path_entry
29
- ::EacConfig::EnvvarsNode.new.load_path.entry
30
- end
31
-
32
- # Wraps a RSpec example in a EacConfig node using a alternative file.
33
- #
34
- # @param target_example [RSpec::Core::ExampleGroup] The example to wrap. If not provided,
35
- # it is applied to all examples.
36
- # @param target_file [Pathname] The file used by the EacConfig node. If not provided, a
37
- # temporary file is used.
38
- # @param node_builder [Proc] Should return the desired EacConfig node. If not provided, a
39
- # EacConfig::YamlFileNode is created.
40
- def stub_eac_config_node(target_example = nil, target_file = nil, &node_builder)
41
- parent_self = self
42
- (target_example || rspec_config).around do |example|
43
- parent_self.stub_eac_config_node_on_file(target_file) do |file|
44
- ::EacConfig::Node
45
- .context.on(parent_self.stub_eac_config_node_build(file, &node_builder)) do
46
- example.run
47
- end
48
- end
49
- end
50
- end
51
-
52
- def stub_eac_config_node_build(file, &node_builder)
53
- node_builder.present? ? node_builder.call(file) : ::EacConfig::YamlFileNode.new(file)
54
- end
55
-
56
- def stub_eac_config_node_on_file(target_file)
57
- if target_file
58
- yield(target_file.to_pathname)
59
- else
60
- ::EacRubyUtils::Fs::Temp.on_file { |file| yield(file) }
61
- end
62
- end
63
- end
64
- end
65
- end
@@ -1,9 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_ruby_utils/core_exts'
4
-
5
- module EacConfig
6
- module Rspec
7
- require_sub __FILE__
8
- end
9
- end
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module EacConfig
4
- VERSION = '0.8.1'
5
- end
@@ -1,36 +0,0 @@
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
- node.persist_data(paths_hash.write(to_paths_hash_key, a_value).root.to_h)
22
- end
23
-
24
- private
25
-
26
- # @return [EacConfig::PathsHash]
27
- def paths_hash
28
- ::EacConfig::PathsHash.new(node.data)
29
- end
30
-
31
- def to_paths_hash_key
32
- path.parts.join('.')
33
- end
34
- end
35
- end
36
- end
@@ -1,47 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'addressable'
4
- require 'eac_config/node'
5
- require 'eac_ruby_utils/core_ext'
6
- require 'eac_ruby_utils/yaml'
7
-
8
- module EacConfig
9
- class YamlFileNode
10
- require_sub __FILE__
11
- include ::EacConfig::Node
12
- enable_simple_cache
13
-
14
- class << self
15
- def from_uri(uri)
16
- return new(uri.to_addressable.path) if uri.to_addressable.scheme == 'file'
17
- end
18
- end
19
-
20
- common_constructor :path do
21
- self.path = path.to_pathname
22
- end
23
-
24
- def persist_data(new_data)
25
- path.parent.mkpath
26
- ::EacRubyUtils::Yaml.dump_file(path, new_data)
27
- reset_cache(:data)
28
- end
29
-
30
- def url
31
- ::Addressable::URI.parse("file://#{path.expand_path}")
32
- end
33
-
34
- private
35
-
36
- def data_uncached
37
- r = nil
38
- if path.file?
39
- r = ::EacRubyUtils::Yaml.load_file(path)
40
- elsif path.exist?
41
- raise("\"#{path}\" is a not a file")
42
- end
43
-
44
- r.is_a?(::Hash) ? r : {}
45
- end
46
- end
47
- end
@@ -1,7 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_ruby_utils/core_ext'
4
-
5
- module EacConfig
6
- require_sub __FILE__
7
- end
@@ -1,30 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_config/entry_path'
4
-
5
- RSpec.describe ::EacConfig::EntryPath do
6
- describe '#assert' do
7
- {
8
- ['a.b.c'] => %w[a b c],
9
- [['a', 1], 'b', []] => %w[a 1 b],
10
- ['a', 'b', ['c', 1.2], 'd', 'e.f'] => %w[a b c 1 2 d e f]
11
- }.each do |data|
12
- source = data[0]
13
- expected_parts = data[1]
14
-
15
- context "when source is #{source}" do
16
- let(:instance) { described_class.assert(source) }
17
-
18
- it { expect(instance.parts).to eq(expected_parts) }
19
- end
20
- end
21
-
22
- [['a..c'], ['a', ' ']].each do |source|
23
- context "when invalid source is #{source}" do
24
- it do
25
- expect { described_class.assert(source) }.to raise_error(::ArgumentError)
26
- end
27
- end
28
- end
29
- end
30
- end
@@ -1,14 +0,0 @@
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
@@ -1,40 +0,0 @@
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,46 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'tempfile'
4
- require 'eac_config/old_configs'
5
-
6
- RSpec.describe ::EacConfig::OldConfigs do
7
- let(:configs_key) { 'configsspec' }
8
- let(:storage_path) do
9
- file = ::Tempfile.new(configs_key)
10
- path = file.path
11
- file.close
12
- file.unlink
13
- path
14
- end
15
- let(:instance) { described_class.new(configs_key, storage_path: storage_path) }
16
-
17
- describe '#storage_path' do
18
- it { expect(instance.storage_path).to eq(storage_path) }
19
- end
20
-
21
- describe '#write' do
22
- let(:entry_key) { 'parent.child' }
23
-
24
- before do
25
- instance[entry_key] = 'value1'
26
- instance.save
27
- end
28
-
29
- it { expect(::YAML.load_file(storage_path)).to eq(parent: { child: 'value1' }) }
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
46
- end
@@ -1,88 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_config/paths_hash'
4
-
5
- RSpec.describe ::EacConfig::PathsHash do
6
- let(:source_hash) do
7
- {
8
- parent: {
9
- child1: {
10
- child1_1: 'v1_1',
11
- child1_2: 'v1_2'
12
- },
13
- child2: 'v2'
14
- }
15
- }
16
- end
17
- let(:instance) { described_class.new(source_hash) }
18
-
19
- describe '#[]' do
20
- {
21
- 'parent.child1.child1_1' => 'v1_1',
22
- 'parent.child1.child1_2' => 'v1_2',
23
- 'parent.child2' => 'v2',
24
- 'no_exist' => nil,
25
- 'parent.child1' => {
26
- child1_1: 'v1_1',
27
- child1_2: 'v1_2'
28
- }
29
- }.each do |entry_key, expected_value|
30
- it { expect(instance[entry_key]).to eq(expected_value) }
31
- end
32
-
33
- ['.only_suffix', '', '.', 'only_prefx.', 'empty..part'].each do |entry_key|
34
- it "invalid entry key \"#{entry_key}\" raises EntryKeyError" do
35
- expect { instance[entry_key] }.to raise_error(::EacConfig::PathsHash::EntryKeyError)
36
- end
37
- end
38
- end
39
-
40
- describe '#[]=' do
41
- let(:source_hash) { {} }
42
-
43
- before do
44
- instance['a.b.c'] = '123'
45
- end
46
-
47
- it { expect(instance.to_h).to eq(a: { b: { c: '123' } }) }
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' => ::EacConfig::PathsHash::EntryKeyError,
55
- 'parent.child1.child1_3' => ::EacConfig::PathsHash::EntryKeyError,
56
- 'parent.child2' => 'v2',
57
- 'no_exist' => ::EacConfig::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
88
- end