eac_config 0.8.0 → 0.10.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: 1a03da4e24715d7384e6de3cd61bb33bf9d1668234675059be4afb39355d82e1
4
- data.tar.gz: 0f97dd63aae43cb52748f17ce8bc15488a11eaaa0ff65ccf2b15b0ee0ef0b16e
3
+ metadata.gz: 56ebf531215de271f91995d402e92d678ada38c3b77b4327da838c2be2753bcb
4
+ data.tar.gz: 828abd016c72c90dacd8e527f68974e75e793b9ee3fd4d163ffb4b737c73950b
5
5
  SHA512:
6
- metadata.gz: 91b13a3a78a6fc3029584d1942d4977beea8d7c213ac9a56721cd3aae15a8492c3491bd9d7a33f095049f8389d165322949750121c70dffdc114af8a753b540d
7
- data.tar.gz: 060bd6ef9c82bfc29418e16ea2985bc120a5e2759e7ae2dc787b683d6d912818207417694bdb26b345e5a1298a8915006a6541f8fa51c70c437be7de48770d3e
6
+ metadata.gz: aa7d28cd6728e76ee1cce56ba932da17da490b98de85b478781f37cd1c4b5f2c3262f9b10da286102683a017bf88397f222b7e4a5ab322b2325f0a217c524a9b
7
+ data.tar.gz: 392269382c259368c8b568af52ec19ae848b38cd019f425e07def1b35ee3c06f310c2a0a7209d47ffb70dc23ad75ea704e9cbc4c50b1c258d1c587a50ba543ad
@@ -42,7 +42,7 @@ module EacConfig
42
42
 
43
43
  def node_entry_from_load_path_uncached
44
44
  root_node.recursive_loaded_nodes.lazy.map { |loaded_node| loaded_node.self_entry(path) }
45
- .find(&:found?)
45
+ .find(&:found?)
46
46
  end
47
47
 
48
48
  def node_entry_from_root_uncached
@@ -28,10 +28,26 @@ module EacConfig
28
28
  end
29
29
  end
30
30
 
31
- attr_reader :parts
31
+ common_constructor :parts, default: [[]] do
32
+ self.parts = ::Array.new(parts).freeze
33
+ end
34
+
35
+ compare_by :parts
36
+ delegate :any?, :count, :each, :each_value, :each_with_index, :empty?, :fetch, :first, :index,
37
+ :inject, :last, :map, :size, to: :parts
38
+
39
+ # @return [EacConfig::EntryPath]
40
+ def +(other)
41
+ self.class.new(parts + self.class.assert(other).parts)
42
+ end
43
+
44
+ def [](*args)
45
+ slice(*args)
46
+ end
32
47
 
33
- def initialize(parts)
34
- @parts = parts.to_a.freeze
48
+ def slice(*args)
49
+ r = parts.slice(*args)
50
+ r.is_a?(::Enumerable) ? self.class.new(r) : r
35
51
  end
36
52
 
37
53
  def to_s
@@ -12,7 +12,7 @@ module EacConfig
12
12
  class << self
13
13
  def entry_path_to_envvar_name(path)
14
14
  ::EacConfig::EntryPath.assert(path).parts.join('_').gsub(/[^a-z0-9_]/i, '')
15
- .gsub(/\A_+/, '').gsub(/_+\z/, '').gsub(/_{2,}/, '_').upcase
15
+ .gsub(/\A_+/, '').gsub(/_+\z/, '').gsub(/_{2,}/, '_').upcase
16
16
  end
17
17
 
18
18
  def from_value(string)
@@ -58,6 +58,12 @@ module EacConfig
58
58
  ::EacConfig::LoadNodesSearch.new(self).result
59
59
  end
60
60
 
61
+ # @return [EacConfig::PrefixedPathNode]
62
+ def with_prefix(path_prefix)
63
+ require 'eac_config/prefixed_path_node'
64
+ ::EacConfig::PrefixedPathNode.new(self, path_prefix)
65
+ end
66
+
61
67
  private
62
68
 
63
69
  def load_node(node_path)
@@ -34,7 +34,7 @@ module EacConfig
34
34
  end
35
35
 
36
36
  def to_h
37
- data.map { |k, v| [k, v.is_a?(Node) ? v.to_h : v] }.to_h
37
+ data.transform_values { |v| v.is_a?(Node) ? v.to_h : v }
38
38
  end
39
39
 
40
40
  def read_entry(path_search)
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_config/node_entry'
4
+ require 'eac_ruby_utils/core_ext'
5
+
6
+ module EacConfig
7
+ class PrefixedPathNode
8
+ class Entry < ::EacConfig::NodeEntry
9
+ enable_simple_cache
10
+ delegate :found?, :found_node, :secret_value, :value, :value=, :writ_node, to: :full_entry
11
+
12
+ # @return [EacConfig::EntryPath]
13
+ def full_path
14
+ node.path_prefix + path
15
+ end
16
+
17
+ private
18
+
19
+ # @return [EacConfig::NodeEntry]
20
+ def full_entry_uncached
21
+ node.from_node.entry(full_path)
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_config/entry_path'
4
+ require 'eac_config/paths_hash'
5
+ require 'eac_ruby_utils/core_ext'
6
+
7
+ module EacConfig
8
+ class PrefixedPathNode
9
+ require_sub __FILE__
10
+ include ::EacConfig::Node
11
+ common_constructor :from_node, :path_prefix do
12
+ self.path_prefix = ::EacConfig::EntryPath.assert(path_prefix)
13
+ end
14
+
15
+ def entry(path)
16
+ ::EacConfig::Entry.new(self, path)
17
+ end
18
+ end
19
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacConfig
4
- VERSION = '0.8.0'
4
+ VERSION = '0.10.0'
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.8.0
4
+ version: 0.10.0
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: 2022-01-17 00:00:00.000000000 Z
11
+ date: 2022-08-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -30,28 +30,28 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0.83'
33
+ version: '0.97'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0.83'
40
+ version: '0.97'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: eac_ruby_gem_support
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0.3'
47
+ version: 0.5.1
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '0.3'
54
+ version: 0.5.1
55
55
  description:
56
56
  email:
57
57
  executables: []
@@ -75,6 +75,8 @@ files:
75
75
  - lib/eac_config/paths_hash/entry_key_error.rb
76
76
  - lib/eac_config/paths_hash/node.rb
77
77
  - lib/eac_config/paths_hash/path_search.rb
78
+ - lib/eac_config/prefixed_path_node.rb
79
+ - lib/eac_config/prefixed_path_node/entry.rb
78
80
  - lib/eac_config/rspec.rb
79
81
  - lib/eac_config/rspec/setup.rb
80
82
  - lib/eac_config/version.rb