avm 0.19.0 → 0.20.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 60254779c64e435b8f853ab931907a47eefb974428e2298dc82b2f6d308d642a
4
- data.tar.gz: 8c054b755c9882ed5b1faaa0c521031edf3551139d04259e0e11895844b4ef63
3
+ metadata.gz: 4da4c32db86b5e0217282e7954683ff84d63ddc8b34a7413bc8b255090a5d15c
4
+ data.tar.gz: b9c369085dcd50e3787c110c828b702eb44b5a1c28a3c036217e6dae19301da8
5
5
  SHA512:
6
- metadata.gz: 3b7aadec66e69a23688c07dffd62f05d1579a1b14c90f57f2e5e6b2caf460e59b394ac62fe60178428100caf5359ab04ae21fecf958748dd01553129cb7d3304
7
- data.tar.gz: c7eddaff6582abdbbb12d6b09a919b199505c1d4189fc8a6696eec61c39f5c41d3b4670d92278b9d30e049b49a99271b0826cb4d079c1b6ab2190424029d0274
6
+ metadata.gz: 419e7911860b01a11ab6cc5fa901abc5585adbb28d4e2c6cfcf27cb189b4f63abc631e961835ad150b86dada322cc30764996387a92aede230922b6b449e2d5e
7
+ data.tar.gz: 2ee319d2462b5c8611d719b64d8e4c75376fd4c3d6e1752f8a88fcbe858a87cd058a28f7017cda47089c70436a86d2b4374e89a724c2d73201287d8f8405927b
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'eac_config/yaml_file_node'
3
4
  require 'eac_ruby_utils/core_ext'
4
5
  require 'eac_ruby_utils/yaml'
5
6
  require 'shellwords'
@@ -10,21 +11,27 @@ module Avm
10
11
  module Configuration
11
12
  # @return [Array<String>, nil]
12
13
  def read_configuration_as_shell_words(key)
13
- configuration[key].if_present do |v|
14
+ configuration.entry(key).value.if_present do |v|
14
15
  v.is_a?(::Enumerable) ? v.map(&:to_s) : ::Shellwords.split(v.to_s)
15
16
  end
16
17
  end
17
18
 
18
19
  private
19
20
 
20
- # @return [Hash]
21
+ # @return [EacConfig::YamlFileNode]
21
22
  def configuration_uncached
22
23
  ::Avm::Sources::Configuration::FILENAMES.each do |filename|
23
- file_path = path.join(filename)
24
- return ::EacRubyUtils::Yaml.load_file(file_path).with_indifferent_access if
25
- file_path.exist?
24
+ configuration_with_filename(filename, true)
26
25
  end
27
- {}
26
+ configuration_with_filename(::Avm::Sources::Configuration::FILENAMES.first, false)
27
+ end
28
+
29
+ # @return [EacConfig::YamlFileNode, nil]
30
+ def configuration_with_filename(filename, needs_exist)
31
+ file_path = path.join(filename)
32
+ return ::EacConfig::YamlFileNode.new(file_path) if !needs_exist || file_path.exist?
33
+
34
+ nil
28
35
  end
29
36
 
30
37
  # @return [Avm::Sources::Configuration]
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/sources/base/subs_paths'
4
+ require 'eac_ruby_utils/core_ext'
5
+
6
+ module Avm
7
+ module Sources
8
+ class Base
9
+ module Subs
10
+ CONFIGURATION_SUBS_EXCLUDE_PATHS_KEY = 'subs.exclude_path'
11
+ CONFIGURATION_SUBS_INCLUDE_PATHS_KEY = 'subs.include_path'
12
+ SUBS_EXCLUDE_PATHS_DEFAULT = [].freeze
13
+ SUBS_INCLUDE_PATHS_DEFAULT = ['sub/*'].freeze
14
+
15
+ # @return [Enumerable<Avm::Sources::Base>]
16
+ def subs
17
+ subs_paths_to_search
18
+ .map { |sub_path| ::Avm::Registry.sources.detect_optional(sub_path, parent: self) }
19
+ .reject(&:blank?)
20
+ .sort_by { |sub| [sub.path] }
21
+ end
22
+
23
+ def subs_paths_to_search
24
+ subs_include_paths.flat_map do |subs_include_path|
25
+ ::Pathname.glob(path.join(subs_include_path)).reject do |sub_path|
26
+ subs_exclude_paths.any? do |subs_exclude_path|
27
+ sub_path.fnmatch?(path.join(subs_exclude_path).to_path)
28
+ end
29
+ end
30
+ end
31
+ end
32
+
33
+ %i[include exclude].each do |type|
34
+ %i[path paths configured_paths default_paths].each do |method_suffix|
35
+ obj_method_name = "subs_#{type}_path_obj"
36
+
37
+ define_method "subs_#{type}_#{method_suffix}" do
38
+ send(obj_method_name).send(method_suffix)
39
+ end
40
+
41
+ define_method "#{obj_method_name}_uncached" do
42
+ ::Avm::Sources::Base::SubsPaths.new(
43
+ self,
44
+ self.class.const_get("CONFIGURATION_SUBS_#{type}_PATHS_KEY".upcase),
45
+ self.class.const_get("SUBS_#{type}_PATHS_DEFAULT".upcase)
46
+ )
47
+ end
48
+
49
+ private "#{obj_method_name}_uncached" # rubocop:disable Style/AccessModifierDeclarations
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module Sources
7
+ class Base
8
+ class SubsPaths
9
+ SUBS_PATH_SEPARATOR = ':'
10
+
11
+ common_constructor :source, :configuration_key, :default_paths
12
+
13
+ # @return [String]
14
+ def path
15
+ paths.join(SUBS_PATH_SEPARATOR)
16
+ end
17
+
18
+ # @return [Array<String>]
19
+ def paths
20
+ configured_paths || default_paths
21
+ end
22
+
23
+ # @return [Array<String>]
24
+ def configured_paths
25
+ source.configuration.entry(configuration_key).value.if_present do |v|
26
+ v.split(SUBS_PATH_SEPARATOR)
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -33,11 +33,6 @@ module Avm
33
33
  "#{self.class}[#{path}]"
34
34
  end
35
35
 
36
- # @return [Enumerable<Avm::Sources::Base>]
37
- def subs
38
- scm.subs.map { |subrepo| ::Avm::Registry.sources.detect(subrepo.path, parent: self) }
39
- end
40
-
41
36
  private
42
37
 
43
38
  # @return [Avm::Scms::Base]
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.19.0'
4
+ VERSION = '0.20.0'
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.19.0
4
+ version: 0.20.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-06-14 00:00:00.000000000 Z
11
+ date: 2022-06-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: eac_cli
@@ -243,6 +243,8 @@ files:
243
243
  - lib/avm/sources/base/configuration.rb
244
244
  - lib/avm/sources/base/instance.rb
245
245
  - lib/avm/sources/base/parent.rb
246
+ - lib/avm/sources/base/subs.rb
247
+ - lib/avm/sources/base/subs_paths.rb
246
248
  - lib/avm/sources/base/testing.rb
247
249
  - lib/avm/sources/configuration.rb
248
250
  - lib/avm/sources/configuration/locale.rb