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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6a6f32e20faefd54b3f85d008539d97fd3298cd6fe8b1118f321a8bdd3f0e9c9
4
- data.tar.gz: 75d5c1c5691aacfec07532f102011119bf41e9991997d1a2c86cb201a271894a
3
+ metadata.gz: 2c50bab43bddae176c5e92caabd8ae79e623401376dc1a5f769c39b5949eaef9
4
+ data.tar.gz: 5b798915ed8a7cf2b36123d6ae802070a5d54708466ad9ebbee8d31f66769840
5
5
  SHA512:
6
- metadata.gz: 144d2b6323592b447ef0b89a24845789ec88153c244209a723fa7aa62b3005bb7c8d8d2b5ad34b4f7f539c33cfcc3c06c9f2230ab6e8aa10b8b28bdb75cf347d
7
- data.tar.gz: 3e807e994d32698e4a5ab8ea74a44846cfad0bf71923e15a534d8ae1eeaf2d4c9876fb498c317d12b16496190fe07aae87f8968c0521d352a2bdf3a71629c3e8
6
+ metadata.gz: 2520e4ec6b82ddd0b7b075566678a36ddbf04970ae3d844321b1335ea48dd170a390c24b5053ccf90d66ad8fc4ae29becf98e923cef7e334072b07c5182cfbc3
7
+ data.tar.gz: 276d69584c163be6c4c128217c25270933a73a65b1c95bef8b451015a571c1cb114b0c18623e833cdd0a11903468b55a7ce2e74c487441997ec029674349c985
@@ -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.0'
5
5
  end
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.13.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