eac_config 0.13.0 → 0.14.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/eac_config/node.rb +4 -2
- data/lib/eac_config/node_uri/instanciate_single.rb +29 -0
- data/lib/eac_config/node_uri.rb +15 -8
- data/lib/eac_config/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2c50bab43bddae176c5e92caabd8ae79e623401376dc1a5f769c39b5949eaef9
|
4
|
+
data.tar.gz: 5b798915ed8a7cf2b36123d6ae802070a5d54708466ad9ebbee8d31f66769840
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2520e4ec6b82ddd0b7b075566678a36ddbf04970ae3d844321b1335ea48dd170a390c24b5053ccf90d66ad8fc4ae29becf98e923cef7e334072b07c5182cfbc3
|
7
|
+
data.tar.gz: 276d69584c163be6c4c128217c25270933a73a65b1c95bef8b451015a571c1cb114b0c18623e833cdd0a11903468b55a7ce2e74c487441997ec029674349c985
|
data/lib/eac_config/node.rb
CHANGED
@@ -56,7 +56,7 @@ module EacConfig
|
|
56
56
|
|
57
57
|
# @return [Array<EacConfig::Node>]
|
58
58
|
def self_loaded_nodes
|
59
|
-
load_path.paths.
|
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
|
-
|
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
|
data/lib/eac_config/node_uri.rb
CHANGED
@@ -5,21 +5,26 @@ module EacConfig
|
|
5
5
|
enable_simple_cache
|
6
6
|
common_constructor :source, :loader_uri, default: [nil]
|
7
7
|
|
8
|
-
|
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
|
-
|
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
|
data/lib/eac_config/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eac_config
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.14.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Put here the authors
|
@@ -76,6 +76,7 @@ files:
|
|
76
76
|
- lib/eac_config/node.rb
|
77
77
|
- lib/eac_config/node_entry.rb
|
78
78
|
- lib/eac_config/node_uri.rb
|
79
|
+
- lib/eac_config/node_uri/instanciate_single.rb
|
79
80
|
- lib/eac_config/old_configs.rb
|
80
81
|
- lib/eac_config/old_configs/base.rb
|
81
82
|
- lib/eac_config/old_configs/file.rb
|