eac_config 0.13.0 → 0.14.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6a6f32e20faefd54b3f85d008539d97fd3298cd6fe8b1118f321a8bdd3f0e9c9
4
- data.tar.gz: 75d5c1c5691aacfec07532f102011119bf41e9991997d1a2c86cb201a271894a
3
+ metadata.gz: 7129c57e10676ddf2fd7b418aa21de384634e1ee9a3b1b5086524f62fa2a84fd
4
+ data.tar.gz: 61af2046de4dd5d3325fe1719b7ddb3e62e4134497a20ef0b923ceb5ebabee65
5
5
  SHA512:
6
- metadata.gz: 144d2b6323592b447ef0b89a24845789ec88153c244209a723fa7aa62b3005bb7c8d8d2b5ad34b4f7f539c33cfcc3c06c9f2230ab6e8aa10b8b28bdb75cf347d
7
- data.tar.gz: 3e807e994d32698e4a5ab8ea74a44846cfad0bf71923e15a534d8ae1eeaf2d4c9876fb498c317d12b16496190fe07aae87f8968c0521d352a2bdf3a71629c3e8
6
+ metadata.gz: 6f04f61ae7c90c57ed1fbc492a894ccf525fe8aa47ebbf6dbe665fd0289615d67c66b2f09b3f99f51b5b72c7a2961da7971ec74139a9f25773548bd70a3e2ed7
7
+ data.tar.gz: b4284d78053b22cf34e9134d3d1529b0079d46cfca98ebb3ae7abefd87062f019c1e9acf46ad9173517457e4c3c8a09b0b894237d8d9b9b1d7ac9b6caeec03a8
@@ -56,7 +56,7 @@ module EacConfig
56
56
 
57
57
  # @return [Array<EacConfig::Node>]
58
58
  def self_loaded_nodes
59
- load_path.paths.map { |node_path| load_node(node_path) }
59
+ load_path.paths.flat_map { |node_path| load_nodes(node_path) }
60
60
  end
61
61
 
62
62
  # @return [Array<EacConfig::Node>]
@@ -72,7 +72,9 @@ module EacConfig
72
72
 
73
73
  private
74
74
 
75
- def load_node(node_path)
75
+ # @param node_path [String]
76
+ # @return [Array<EacConfig::Node>]
77
+ def load_nodes(node_path)
76
78
  ::EacConfig::NodeUri.new(node_path, url).instanciate
77
79
  end
78
80
  end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EacConfig
4
+ class NodeUri
5
+ class InstanciateSingle
6
+ acts_as_instance_method
7
+ enable_simple_cache
8
+ common_constructor :node_uri, :instance_uri
9
+
10
+ # @return [Array<Class>]
11
+ def available_node_classes
12
+ require 'eac_config/envvars_node'
13
+ require 'eac_config/yaml_file_node'
14
+ [::EacConfig::EnvvarsNode, ::EacConfig::YamlFileNode]
15
+ end
16
+
17
+ # @return [EacConfig::Node]
18
+ def result
19
+ available_node_classes.lazy.map { |k| k.from_uri(self) }.find(&:present?) ||
20
+ raise("No class mapped for \"#{to_addressable}\"")
21
+ end
22
+
23
+ # @return [Addressable::URI]
24
+ def to_addressable
25
+ instance_uri.to_uri
26
+ end
27
+ end
28
+ end
29
+ end
@@ -5,21 +5,26 @@ module EacConfig
5
5
  enable_simple_cache
6
6
  common_constructor :source, :loader_uri, default: [nil]
7
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
-
8
+ # @return [Array<EacConfig::Node>]
14
9
  def instanciate
15
- available_node_classes.lazy.map { |k| k.from_uri(self) }.find(&:present?) ||
16
- raise("No class mapped for \"#{to_addressable}\"")
10
+ instance_uris.map { |uri| instanciate_single(uri) }
17
11
  end
18
12
 
19
13
  delegate :to_s, to: :to_addressable
20
14
 
21
15
  private
22
16
 
17
+ # @return [Array<Addressable::URI>]
18
+ def instance_uris
19
+ if to_addressable.scheme == 'file'
20
+ ::Pathname.glob(to_addressable.path).map do |found_path|
21
+ ::Addressable::URI.new(scheme: 'file', path: found_path.to_path)
22
+ end
23
+ else
24
+ [to_addressable]
25
+ end
26
+ end
27
+
23
28
  def to_addressable_uncached
24
29
  r = ::Addressable::URI.parse(source)
25
30
  path = r.path.to_pathname
@@ -34,5 +39,7 @@ module EacConfig
34
39
 
35
40
  r.to_pathname.parent
36
41
  end
42
+
43
+ require_sub __FILE__, require_mode: :kernel
37
44
  end
38
45
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacConfig
4
- VERSION = '0.13.0'
4
+ VERSION = '0.14.1'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eac_config
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.0
4
+ version: 0.14.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Put here the authors
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-06-27 00:00:00.000000000 Z
11
+ date: 2023-10-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -19,7 +19,7 @@ dependencies:
19
19
  version: '2.8'
20
20
  - - ">="
21
21
  - !ruby/object:Gem::Version
22
- version: 2.8.4
22
+ version: 2.8.5
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,7 +29,7 @@ dependencies:
29
29
  version: '2.8'
30
30
  - - ">="
31
31
  - !ruby/object:Gem::Version
32
- version: 2.8.4
32
+ version: 2.8.5
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: eac_ruby_utils
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -37,6 +37,9 @@ dependencies:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
39
  version: '0.119'
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: 0.119.2
40
43
  type: :runtime
41
44
  prerelease: false
42
45
  version_requirements: !ruby/object:Gem::Requirement
@@ -44,6 +47,9 @@ dependencies:
44
47
  - - "~>"
45
48
  - !ruby/object:Gem::Version
46
49
  version: '0.119'
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: 0.119.2
47
53
  - !ruby/object:Gem::Dependency
48
54
  name: eac_ruby_gem_support
49
55
  requirement: !ruby/object:Gem::Requirement
@@ -76,6 +82,7 @@ files:
76
82
  - lib/eac_config/node.rb
77
83
  - lib/eac_config/node_entry.rb
78
84
  - lib/eac_config/node_uri.rb
85
+ - lib/eac_config/node_uri/instanciate_single.rb
79
86
  - lib/eac_config/old_configs.rb
80
87
  - lib/eac_config/old_configs/base.rb
81
88
  - lib/eac_config/old_configs/file.rb