avm 0.25.0 → 0.26.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/registry/with_path/cache.rb +31 -0
- data/lib/avm/registry/with_path.rb +25 -5
- data/lib/avm/sources/base/configuration.rb +23 -2
- data/lib/avm/sources/base/locale.rb +1 -1
- data/lib/avm/sources/base/parent.rb +8 -11
- data/lib/avm/sources/base/subs_paths.rb +1 -1
- data/lib/avm/sources/base/testing.rb +4 -4
- data/lib/avm/sources/tests/builder.rb +5 -10
- data/lib/avm/version.rb +1 -1
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 409db17d04ee296956e9770e61a5f65919fbf2b0c8bea4efae0ed68fb169572a
|
4
|
+
data.tar.gz: 3c7e6ea386a2527ed86c3bb9ef8a71b1767d17a204d48b1ecc3b74c015772328
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 302b99ff7495bf6c3f4624432e63f1f2668f8b5d2a2ac91bc721f3206baf9595520c192fa4ead326ad7ce3c646253ca7f1a71a48ee1b11080e1898efe4fef5f8
|
7
|
+
data.tar.gz: 7b85ae2c2a03f3abfeed96924ab6e0180d17709ec422cd3b0638f7075cc750c25a8118d7654554ecfe80519fdeb505da9aa720f2109fdf7bcacfdf7bf884d141
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'avm/registry/base'
|
4
|
+
require 'eac_ruby_utils/core_ext'
|
5
|
+
|
6
|
+
module Avm
|
7
|
+
module Registry
|
8
|
+
class WithPath < ::Avm::Registry::Base
|
9
|
+
class Cache
|
10
|
+
enable_simple_cache
|
11
|
+
common_constructor :owner
|
12
|
+
|
13
|
+
def detect_optional(path)
|
14
|
+
return nil if path.root?
|
15
|
+
return cached_paths.fetch(path) if cached_paths.key?(path)
|
16
|
+
|
17
|
+
detected = owner.detect_optional(path)
|
18
|
+
detected = detect_optional(path.parent) if detected.blank?
|
19
|
+
cached_paths[path] = detected
|
20
|
+
detected
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def cached_paths_uncached
|
26
|
+
{}
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -6,17 +6,37 @@ require 'eac_ruby_utils/core_ext'
|
|
6
6
|
module Avm
|
7
7
|
module Registry
|
8
8
|
class WithPath < ::Avm::Registry::Base
|
9
|
+
require_sub __FILE__
|
10
|
+
|
9
11
|
def detect_by_path(path)
|
10
12
|
detect_by_path_optional(path) || raise_not_found(path)
|
11
13
|
end
|
12
14
|
|
13
15
|
def detect_by_path_optional(path)
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
16
|
+
on_cache do
|
17
|
+
cache.detect_optional(path)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
attr_accessor :cache
|
24
|
+
|
25
|
+
def on_cache(&block)
|
26
|
+
cache.present? ? on_cache_with_cache(&block) : on_cache_with_no_cache(&block)
|
27
|
+
end
|
28
|
+
|
29
|
+
def on_cache_with_cache(&block)
|
30
|
+
block.call
|
31
|
+
end
|
32
|
+
|
33
|
+
def on_cache_with_no_cache(&block)
|
34
|
+
self.cache = ::Avm::Registry::WithPath::Cache.new(self)
|
35
|
+
begin
|
36
|
+
block.call
|
37
|
+
ensure
|
38
|
+
self.cache = nil
|
18
39
|
end
|
19
|
-
nil
|
20
40
|
end
|
21
41
|
end
|
22
42
|
end
|
@@ -9,8 +9,19 @@ module Avm
|
|
9
9
|
module Sources
|
10
10
|
class Base
|
11
11
|
module Configuration
|
12
|
+
PARENT_CONFIGURATION_SUFFIX = %w[subs at].freeze
|
12
13
|
CONFIGURATION_FILENAMES = %w[.avm.yml .avm.yaml].freeze
|
13
14
|
|
15
|
+
# @return [EacConfig::NodeEntry]
|
16
|
+
def configuration_entry(*entry_args)
|
17
|
+
parent_configuration.if_present do |v|
|
18
|
+
parent_entry = v.entry(*entry_args)
|
19
|
+
return parent_entry if parent_entry.found?
|
20
|
+
end
|
21
|
+
|
22
|
+
configuration.entry(*entry_args)
|
23
|
+
end
|
24
|
+
|
14
25
|
# @return [EacRubyUtils::Envs::Command, nil]
|
15
26
|
def configuration_value_to_env_command(value)
|
16
27
|
configuration_value_to_shell_words(value).if_present { |v| env.command(v).chdir(path) }
|
@@ -25,13 +36,13 @@ module Avm
|
|
25
36
|
|
26
37
|
# @return [Array<String>, nil]
|
27
38
|
def read_configuration_as_shell_words(key)
|
28
|
-
configuration_value_to_shell_words(
|
39
|
+
configuration_value_to_shell_words(configuration_entry(key).value)
|
29
40
|
end
|
30
41
|
|
31
42
|
# Utility to read a configuration as a [EacRubyUtils::Envs::Command].
|
32
43
|
# @return [EacRubyUtils::Envs::Command]
|
33
44
|
def read_configuration_as_env_command(key)
|
34
|
-
configuration_value_to_env_command(
|
45
|
+
configuration_value_to_env_command(configuration_entry(key).value)
|
35
46
|
end
|
36
47
|
|
37
48
|
private
|
@@ -44,6 +55,16 @@ module Avm
|
|
44
55
|
configuration_with_filename(CONFIGURATION_FILENAMES.first, false)
|
45
56
|
end
|
46
57
|
|
58
|
+
# @return [String]
|
59
|
+
def parent_configuration_prefix
|
60
|
+
PARENT_CONFIGURATION_SUFFIX + [relative_path]
|
61
|
+
end
|
62
|
+
|
63
|
+
# @return [EacConfig::PrefixedPathNode]
|
64
|
+
def parent_configuration_uncached
|
65
|
+
parent.if_present { |v| v.configuration.with_prefix(parent_configuration_prefix) }
|
66
|
+
end
|
67
|
+
|
47
68
|
# @return [EacConfig::YamlFileNode, nil]
|
48
69
|
def configuration_with_filename(filename, needs_exist)
|
49
70
|
file_path = path.join(filename)
|
@@ -6,11 +6,6 @@ module Avm
|
|
6
6
|
module Sources
|
7
7
|
class Base
|
8
8
|
module Parent
|
9
|
-
# @return [Avm::Sources::Base]
|
10
|
-
def parent
|
11
|
-
parent_by_option || parent_by_search
|
12
|
-
end
|
13
|
-
|
14
9
|
# @return [Avm::Sources::Base]
|
15
10
|
def parent_by_option
|
16
11
|
options[OPTION_PARENT]
|
@@ -18,12 +13,14 @@ module Avm
|
|
18
13
|
|
19
14
|
# @return [Avm::Sources::Base]
|
20
15
|
def parent_by_search
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
16
|
+
::Avm::Registry.sources.detect_by_path_optional(path.parent)
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
# @return [Avm::Sources::Base]
|
22
|
+
def parent_uncached
|
23
|
+
parent_by_option || parent_by_search
|
27
24
|
end
|
28
25
|
end
|
29
26
|
end
|
@@ -18,12 +18,12 @@ module Avm
|
|
18
18
|
|
19
19
|
# @return [Hash<String, EacRubyUtils::Envs::Command>, nil]
|
20
20
|
def configured_test_commands
|
21
|
-
configured_value_as_test_commands(
|
21
|
+
configured_value_as_test_commands(configuration_entry(TEST_COMMANDS_KEY).value)
|
22
22
|
end
|
23
23
|
|
24
24
|
# @return [Hash<String, EacRubyUtils::Envs::Command>, nil]
|
25
25
|
def configured_value_as_test_commands(value)
|
26
|
-
return nil if value.
|
26
|
+
return nil if value.nil?
|
27
27
|
|
28
28
|
[::EacRubyUtils::Envs::Command, ::Hash, ::Enumerable].each do |type|
|
29
29
|
next unless value.is_a?(type)
|
@@ -45,8 +45,8 @@ module Avm
|
|
45
45
|
# @return [Enumerable<EacRubyUtils::Envs::Command>]
|
46
46
|
def test_commands
|
47
47
|
configured_test_commands ||
|
48
|
-
configured_value_as_test_commands(configured_test_command)
|
49
|
-
|
48
|
+
configured_value_as_test_commands(configured_test_command) ||
|
49
|
+
default_test_commands
|
50
50
|
end
|
51
51
|
|
52
52
|
protected
|
@@ -35,7 +35,7 @@ module Avm
|
|
35
35
|
# @return [Array<Avm::Sources::Tests::Single>]
|
36
36
|
def available_units
|
37
37
|
@available_units ||= ([main_source] + main_source.subs)
|
38
|
-
.
|
38
|
+
.flat_map { |a_source| create_source_units(a_source) }
|
39
39
|
end
|
40
40
|
|
41
41
|
def available_units_from_main
|
@@ -62,20 +62,15 @@ module Avm
|
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
65
|
-
# @return [Avm::Sources::Tests::Single]
|
66
|
-
def create_unit(source)
|
67
|
-
::Avm::Sources::Tests::Single.new(self, source)
|
68
|
-
end
|
69
|
-
|
70
65
|
# @return [Array<Avm::Sources::Tests::Single>]
|
71
66
|
def create_units(sources)
|
72
67
|
sources.flat_map { |a_source| create_source_units(a_source) }
|
73
68
|
end
|
74
69
|
|
75
70
|
# @return [Avm::Sources::Tests::Single]
|
76
|
-
def
|
77
|
-
r = available_units.
|
78
|
-
return r if r
|
71
|
+
def create_units_by_id(source_id)
|
72
|
+
r = available_units.select { |unit| unit.source.relative_path.to_path == source_id.to_s }
|
73
|
+
return r if r.any?
|
79
74
|
|
80
75
|
raise ::ArgumentError, "Source not found with ID=#{source_id}" \
|
81
76
|
"(Available: #{available_units.map(&:id).join(', ')})"
|
@@ -83,7 +78,7 @@ module Avm
|
|
83
78
|
|
84
79
|
# @return [Array<Avm::Sources::Tests::Single>]
|
85
80
|
def select_units_from_ids
|
86
|
-
include_ids.
|
81
|
+
include_ids.flat_map { |source_id| create_units_by_id(source_id) }
|
87
82
|
end
|
88
83
|
|
89
84
|
# @return [Array<Avm::Sources::Tests::Single>]
|
data/lib/avm/version.rb
CHANGED
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.
|
4
|
+
version: 0.26.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-07-
|
11
|
+
date: 2022-07-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: eac_cli
|
@@ -30,6 +30,20 @@ dependencies:
|
|
30
30
|
- - ">="
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: 0.27.6
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: eac_config
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0.9'
|
40
|
+
type: :runtime
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - "~>"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0.9'
|
33
47
|
- !ruby/object:Gem::Dependency
|
34
48
|
name: eac_docker
|
35
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -227,6 +241,7 @@ files:
|
|
227
241
|
- lib/avm/registry.rb
|
228
242
|
- lib/avm/registry/base.rb
|
229
243
|
- lib/avm/registry/with_path.rb
|
244
|
+
- lib/avm/registry/with_path/cache.rb
|
230
245
|
- lib/avm/result.rb
|
231
246
|
- lib/avm/rspec.rb
|
232
247
|
- lib/avm/rspec/setup.rb
|