eac_config 0.8.1 → 0.11.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: 6bdff961fb028eac14cca56c7fa1bb9a14bc360c57fca532df4fc71d8711ef1b
4
- data.tar.gz: e295fe2003758ae1d6cea311e5fc3b4fc15dde36ce65dd12a6ba85304f087cab
3
+ metadata.gz: 3895d22823b308b9efa0e6a3e87e54325edfe3ff7cbaa746c914c59427b34c3d
4
+ data.tar.gz: fd5d69eb38f696e81f27ceae2ae7d65751f0da899c23268348c251cf67707dab
5
5
  SHA512:
6
- metadata.gz: 36bdfa528f5dab7de44549c202fca7294cb9aeb4b1d37e716f7e432e189eefebf30aeb4d740471052e5dbfa0d1b5e7889cb23897ccf04d4770f2030c570319e9
7
- data.tar.gz: b806238018633952079123cb59fa426d23b14734b62d8670c74c9867738a2f866e946028a9acf9f06606e4f340b9c55e195751b2f10f74151060ef6c0109d338
6
+ metadata.gz: 7143591a8db4cc19f8bcde4e2890ffd7257af2ff761b25469c010898748a0f36b63238ad34829ed2352b447d9a2d5fb02d904d87af3cb9c114fc1ea25ef178c2
7
+ data.tar.gz: '089ff436de128f10c84da78ad41e3ea813a7b5186c82c5fbd9976cf1ac13c400e5a13acbffe8b07cc41d8f92a31455a338a0c1c751ef3874a6948c7b5cb71cd6'
@@ -28,14 +28,35 @@ 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
32
43
 
33
- def initialize(parts)
34
- @parts = parts.to_a.freeze
44
+ def [](*args)
45
+ slice(*args)
46
+ end
47
+
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
38
- "#{self.class}[#{parts.join(PART_SEPARATOR)}]"
54
+ "#{self.class}[#{to_string}]"
55
+ end
56
+
57
+ # @return [String]
58
+ def to_string
59
+ parts.join(PART_SEPARATOR)
39
60
  end
40
61
  end
41
62
  end
@@ -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)
@@ -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.1'
4
+ VERSION = '0.11.0'
5
5
  end
metadata CHANGED
@@ -1,43 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eac_config
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.11.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-06-04 00:00:00.000000000 Z
11
+ date: 2022-08-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: '2.8'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: '2.8'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: eac_ruby_utils
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0.83'
33
+ version: '0.100'
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.100'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: eac_ruby_gem_support
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -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