eac_config 0.15.0 → 0.15.1

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: e0d9bb41e5a01540806754be7d0b507efd74a4ad72bd587ccbb73b1bb32408a2
4
- data.tar.gz: 9968df7a790e28201fbe07fa84614c01ea4f88c0343b65dfda160efc8eb2fb3b
3
+ metadata.gz: 1b74bc1ca4debbeb6a28606a3fe821e428197d5c00074025d071988d822bc7e2
4
+ data.tar.gz: 87a26f9f8a3db12b5f9a7b46a7d33fb6f5e692cc36e24d4072847772962999d8
5
5
  SHA512:
6
- metadata.gz: 85a4f3257297571207ac3eaa8737bb4ac15c11f0674706cc8a5db51444d1a9da13ba7394214a4bf80ca403875dad9ee3364077ec0189be12f9a43d93d34853c0
7
- data.tar.gz: 4b7ea65b45170abfa3378ed179d0a17abd0842f6ef7e91da049380d19ef294b85bba9e31f2bb878536d1977e2a734866e5068c0ae0383bdaa52143d3a4cc9479
6
+ metadata.gz: 65c80b5c42dce0daba891943b0de0612dcaa5bd7cafabe47694f25b814829c587b52bcd859da85bba8139a0273b81bb6b04d69baca6d138a13f81f7687b6302e
7
+ data.tar.gz: 18af8f0646a9647b7d1b902531a18ca9ce57f61e05f40a8753a124f99ea13712ed95970fc979a6cb8df1b8c0a52a58416df665c40287095d2c01cb1b410994a8
@@ -1,12 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'eac_config/entry_path'
4
- require 'eac_ruby_utils'
5
-
6
3
  module EacConfig
7
4
  class Entries
8
- require_sub __FILE__
9
- enable_simple_cache
5
+ enable_memoized
10
6
  common_constructor :root_node, :path do
11
7
  self.path = ::EacConfig::EntryPath.assert(path)
12
8
  end
@@ -15,20 +11,18 @@ module EacConfig
15
11
  "#{self.class}[RootNode: #{root_node}, Path: #{path}]"
16
12
  end
17
13
 
18
- private
19
-
20
14
  # @return [Array<EacConfig::Entries>]
21
- def node_entries_uncached
15
+ memoize def node_entries
22
16
  node_entries_from_root + node_entries_from_load_path
23
17
  end
24
18
 
25
19
  # @return [Array<EacConfig::Entries>]
26
- def node_entries_from_load_path_uncached
20
+ memoize def node_entries_from_load_path
27
21
  root_node.recursive_loaded_nodes.flat_map { |loaded_node| loaded_node.self_entries(path) }
28
22
  end
29
23
 
30
24
  # @return [Array<EacConfig::Entries>]
31
- def node_entries_from_root_uncached
25
+ memoize def node_entries_from_root
32
26
  root_node.self_entries(path)
33
27
  end
34
28
  end
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'eac_ruby_utils'
4
-
5
3
  module EacConfig
6
4
  class Entry
7
5
  class NotFoundError < ::RuntimeError
@@ -1,12 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'eac_config/entry_path'
4
- require 'eac_ruby_utils'
5
-
6
3
  module EacConfig
7
4
  class Entry
8
- require_sub __FILE__
9
- enable_simple_cache
5
+ enable_memoized
10
6
  common_constructor :root_node, :path do
11
7
  self.path = ::EacConfig::EntryPath.assert(path)
12
8
  end
@@ -47,16 +43,16 @@ module EacConfig
47
43
 
48
44
  private
49
45
 
50
- def node_entry_uncached
46
+ memoize def node_entry
51
47
  node_entry_from_root || node_entry_from_load_path
52
48
  end
53
49
 
54
- def node_entry_from_load_path_uncached
50
+ memoize def node_entry_from_load_path
55
51
  root_node.recursive_loaded_nodes.lazy.map { |loaded_node| loaded_node.self_entry(path) }
56
52
  .find(&:found?)
57
53
  end
58
54
 
59
- def node_entry_from_root_uncached
55
+ memoize def node_entry_from_root
60
56
  e = root_node.self_entry(path)
61
57
  e.found? ? e : nil
62
58
  end
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'eac_ruby_utils'
4
-
5
3
  module EacConfig
6
4
  class EntryPath
7
5
  PART_SEPARATOR = '.'
@@ -41,12 +39,12 @@ module EacConfig
41
39
  self.class.new(parts + self.class.assert(other).parts)
42
40
  end
43
41
 
44
- def [](*args)
45
- slice(*args)
42
+ def [](*)
43
+ slice(*)
46
44
  end
47
45
 
48
- def slice(*args)
49
- r = parts.slice(*args)
46
+ def slice(*)
47
+ r = parts.slice(*)
50
48
  r.is_a?(::Enumerable) ? self.class.new(r) : r
51
49
  end
52
50
 
@@ -1,9 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'eac_config/entry_path'
4
- require 'eac_config/node_entry'
5
- require 'eac_ruby_utils'
6
-
7
3
  module EacConfig
8
4
  class EnvvarsNode
9
5
  class Entry < ::EacConfig::NodeEntry
@@ -28,7 +24,7 @@ module EacConfig
28
24
  end
29
25
  end
30
26
 
31
- enable_simple_cache
27
+ enable_memoized
32
28
 
33
29
  def found?
34
30
  ENV.key?(envvar_name)
@@ -44,7 +40,7 @@ module EacConfig
44
40
 
45
41
  private
46
42
 
47
- def envvar_name_uncached
43
+ memoize def envvar_name
48
44
  self.class.entry_path_to_envvar_name(path)
49
45
  end
50
46
  end
@@ -1,13 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'addressable'
4
- require 'eac_config/node'
5
- require 'eac_ruby_utils'
6
4
 
7
5
  module EacConfig
8
6
  # A node that read/write entries from environment variables.
9
7
  class EnvvarsNode
10
- require_sub __FILE__
11
8
  include ::EacConfig::Node
12
9
 
13
10
  URI = ::Addressable::URI.parse('self://envvars')
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'eac_ruby_utils'
4
-
5
3
  module EacConfig
6
4
  class LoadNodesSearch
7
5
  common_constructor :root_node do
@@ -1,8 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'eac_config/entry_path'
4
- require 'eac_ruby_utils'
5
-
6
3
  module EacConfig
7
4
  class LoadPath
8
5
  ENTRY_PATH = ::EacConfig::EntryPath.assert(%w[load_path])
@@ -1,16 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'eac_config/entries'
4
- require 'eac_config/entry'
5
- require 'eac_config/entry_path'
6
- require 'eac_config/load_path'
7
- require 'eac_config/load_nodes_search'
8
- require 'eac_config/node_entry'
9
- require 'eac_config/node_uri'
10
- require 'eac_ruby_utils'
11
-
12
3
  module EacConfig
13
4
  module Node
5
+ include ::Memoized
6
+
14
7
  class << self
15
8
  def context
16
9
  @context ||= ::EacRubyUtils::Context.new
@@ -59,13 +52,12 @@ module EacConfig
59
52
  end
60
53
 
61
54
  # @return [Array<EacConfig::Node>]
62
- def recursive_loaded_nodes
55
+ memoize def recursive_loaded_nodes
63
56
  ::EacConfig::LoadNodesSearch.new(self).result
64
57
  end
65
58
 
66
59
  # @return [EacConfig::PrefixedPathNode]
67
60
  def with_prefix(path_prefix)
68
- require 'eac_config/prefixed_path_node'
69
61
  ::EacConfig::PrefixedPathNode.new(self, path_prefix)
70
62
  end
71
63
 
@@ -1,14 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'eac_config/entry_path'
4
- require 'eac_config/paths_hash'
5
- require 'eac_ruby_utils'
6
-
7
3
  module EacConfig
8
4
  # A entry which search values only in the source node.
9
5
  class NodeEntry
10
6
  enable_abstract_methods
11
- enable_simple_cache
7
+ enable_memoized
12
8
  common_constructor :node, :path do
13
9
  self.path = ::EacConfig::EntryPath.assert(path)
14
10
  end
@@ -4,13 +4,11 @@ module EacConfig
4
4
  class NodeUri
5
5
  class InstanciateSingle
6
6
  acts_as_instance_method
7
- enable_simple_cache
7
+ enable_memoized
8
8
  common_constructor :node_uri, :instance_uri
9
9
 
10
10
  # @return [Array<Class>]
11
11
  def available_node_classes
12
- require 'eac_config/envvars_node'
13
- require 'eac_config/yaml_file_node'
14
12
  [::EacConfig::EnvvarsNode, ::EacConfig::YamlFileNode]
15
13
  end
16
14
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  module EacConfig
4
4
  class NodeUri
5
- enable_simple_cache
5
+ enable_memoized
6
6
  common_constructor :source, :loader_uri, default: [nil]
7
7
 
8
8
  # @return [Array<EacConfig::Node>]
@@ -25,7 +25,7 @@ module EacConfig
25
25
  end
26
26
  end
27
27
 
28
- def to_addressable_uncached
28
+ memoize def to_addressable
29
29
  r = ::Addressable::URI.parse(source)
30
30
  path = r.path.to_pathname
31
31
  r.path = path.expand_path(loader_uri_path_directory).to_path if path.relative?
@@ -1,12 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'eac_ruby_utils'
4
- require 'eac_config/paths_hash'
5
-
6
3
  module EacConfig
7
4
  class OldConfigs
8
5
  class Base
9
- enable_simple_cache
6
+ enable_memoized
10
7
 
11
8
  common_constructor :data, default: [{}] do
12
9
  self.data = ::EacConfig::PathsHash.new(data)
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'eac_config/old_configs/base'
4
3
  require 'yaml'
5
4
 
6
5
  module EacConfig
@@ -2,14 +2,11 @@
2
2
 
3
3
  require 'active_support/core_ext/string'
4
4
  require 'yaml'
5
- require 'eac_config/old_configs/file'
6
- require 'eac_ruby_utils'
7
- require 'eac_config/paths_hash'
8
5
 
9
6
  module EacConfig
10
7
  # @deprecated Use {EacConfig::YamlFileNode} instead.
11
8
  class OldConfigs
12
- include ::EacRubyUtils::SimpleCache
9
+ enable_memoized
13
10
 
14
11
  attr_reader :configs_key, :options
15
12
 
@@ -38,23 +35,17 @@ module EacConfig
38
35
  read_entry(entry_key)
39
36
  end
40
37
 
41
- def read_entry(entry_key)
42
- file.read(entry_key)
43
- end
44
-
45
- delegate :autosave?, to: :file
46
-
47
- private
48
-
49
- attr_accessor :data
50
-
51
- def file_uncached
38
+ memoize def file
52
39
  ::EacConfig::OldConfigs::File.new(
53
40
  storage_path, options
54
41
  )
55
42
  end
56
43
 
57
- def storage_path_uncached
44
+ def read_entry(entry_key)
45
+ file.read(entry_key)
46
+ end
47
+
48
+ memoize def storage_path
58
49
  path = options_storage_path || default_storage_path
59
50
  return path if ::File.exist?(path) && ::File.size(path).positive?
60
51
 
@@ -63,6 +54,12 @@ module EacConfig
63
54
  path
64
55
  end
65
56
 
57
+ delegate :autosave?, to: :file
58
+
59
+ private
60
+
61
+ attr_accessor :data
62
+
66
63
  def options_storage_path
67
64
  options[:storage_path]
68
65
  end
@@ -1,8 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'eac_ruby_utils'
4
- require 'eac_config/paths_hash/entry_key_error'
5
-
6
3
  module EacConfig
7
4
  class PathsHash
8
5
  class Node
@@ -1,11 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'eac_ruby_utils'
4
-
5
3
  module EacConfig
6
4
  class PathsHash
7
- require_sub __FILE__
8
-
9
5
  class << self
10
6
  def parse_entry_key(entry_key) # rubocop:disable Metrics/CyclomaticComplexity
11
7
  r = entry_key.to_s.strip
@@ -1,12 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'eac_config/node_entry'
4
- require 'eac_ruby_utils'
5
-
6
3
  module EacConfig
7
4
  class PrefixedPathNode
8
5
  class Entry < ::EacConfig::NodeEntry
9
- enable_simple_cache
6
+ enable_memoized
10
7
  delegate :found?, :found_node, :secret_value, :value, :value=, :writ_node, to: :full_entry
11
8
 
12
9
  # @return [EacConfig::EntryPath]
@@ -17,7 +14,7 @@ module EacConfig
17
14
  private
18
15
 
19
16
  # @return [EacConfig::NodeEntry]
20
- def full_entry_uncached
17
+ memoize def full_entry
21
18
  node.from_node.entry(full_path)
22
19
  end
23
20
  end
@@ -1,13 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'eac_config/entry_path'
4
- require 'eac_config/paths_hash'
5
- require 'eac_ruby_utils'
6
-
7
3
  module EacConfig
8
4
  class PrefixedPathNode
9
- require_sub __FILE__
10
5
  include ::EacConfig::Node
6
+
11
7
  common_constructor :from_node, :path_prefix do
12
8
  self.path_prefix = ::EacConfig::EntryPath.assert(path_prefix)
13
9
  end
@@ -1,10 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'eac_ruby_utils'
4
- require 'eac_config/envvars_node'
5
- require 'eac_config/node'
6
- require 'eac_config/yaml_file_node'
7
-
8
3
  module EacConfig
9
4
  module Rspec
10
5
  module Setup
@@ -36,12 +31,12 @@ module EacConfig
36
31
  # temporary file is used.
37
32
  # @param node_builder [Proc] Should return the desired EacConfig node. If not provided, a
38
33
  # EacConfig::YamlFileNode is created.
39
- def stub_eac_config_node(target_example = nil, target_file = nil, &node_builder)
34
+ def stub_eac_config_node(target_example = nil, target_file = nil, &)
40
35
  parent_self = self
41
36
  (target_example || rspec_config).around do |example|
42
37
  parent_self.stub_eac_config_node_on_file(target_file) do |file|
43
38
  ::EacConfig::Node
44
- .context.on(parent_self.stub_eac_config_node_build(file, &node_builder)) do
39
+ .context.on(parent_self.stub_eac_config_node_build(file, &)) do
45
40
  example.run
46
41
  end
47
42
  end
@@ -52,11 +47,11 @@ module EacConfig
52
47
  node_builder.present? ? node_builder.call(file) : ::EacConfig::YamlFileNode.new(file)
53
48
  end
54
49
 
55
- def stub_eac_config_node_on_file(target_file, &block)
50
+ def stub_eac_config_node_on_file(target_file, &)
56
51
  if target_file
57
52
  yield(target_file.to_pathname)
58
53
  else
59
- ::EacRubyUtils::Fs::Temp.on_file(&block)
54
+ ::EacRubyUtils::Fs::Temp.on_file(&)
60
55
  end
61
56
  end
62
57
  end
@@ -1,9 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'eac_ruby_utils'
4
-
5
3
  module EacConfig
6
4
  module Rspec
7
- require_sub __FILE__
8
5
  end
9
6
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacConfig
4
- VERSION = '0.15.0'
4
+ VERSION = '0.15.1'
5
5
  end
@@ -1,13 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'eac_config/entry_path'
4
- require 'eac_config/node_entry'
5
- require 'eac_ruby_utils'
6
-
7
3
  module EacConfig
8
4
  class YamlFileNode
9
5
  class Entry < ::EacConfig::NodeEntry
10
- enable_simple_cache
6
+ enable_memoized
11
7
 
12
8
  def found?
13
9
  paths_hash.key?(to_paths_hash_key)
@@ -1,9 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'eac_config/entry_path'
4
- require 'eac_config/yaml_file_node/entry'
5
- require 'eac_ruby_utils'
6
-
7
3
  module EacConfig
8
4
  class YamlFileNode
9
5
  class SelfEntries
@@ -1,14 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'addressable'
4
- require 'eac_config/node'
5
- require 'eac_ruby_utils'
6
4
 
7
5
  module EacConfig
8
6
  class YamlFileNode
9
- require_sub __FILE__
10
7
  include ::EacConfig::Node
11
- enable_simple_cache
8
+
9
+ enable_memoized
12
10
 
13
11
  class << self
14
12
  def from_uri(uri)
@@ -21,6 +19,17 @@ module EacConfig
21
19
  end
22
20
  compare_by :path
23
21
 
22
+ memoize def data
23
+ r = nil
24
+ if path.file?
25
+ r = ::EacRubyUtils::Yaml.load_file(path)
26
+ elsif path.exist?
27
+ raise("\"#{path}\" is a not a file")
28
+ end
29
+
30
+ r.is_a?(::Hash) ? r : {}
31
+ end
32
+
24
33
  def persist_data(new_data)
25
34
  path.parent.mkpath
26
35
  ::EacRubyUtils::Yaml.dump_file(path, new_data)
@@ -35,19 +44,6 @@ module EacConfig
35
44
  "#{self.class}[#{path}]"
36
45
  end
37
46
 
38
- private
39
-
40
- def data_uncached
41
- r = nil
42
- if path.file?
43
- r = ::EacRubyUtils::Yaml.load_file(path)
44
- elsif path.exist?
45
- raise("\"#{path}\" is a not a file")
46
- end
47
-
48
- r.is_a?(::Hash) ? r : {}
49
- end
50
-
51
47
  require_sub __FILE__, require_mode: :kernel
52
48
  end
53
49
  end
data/lib/eac_config.rb CHANGED
@@ -1,8 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'eac_ruby_utils'
4
- EacRubyUtils::RootModuleSetup.perform __FILE__
5
-
6
- module EacConfig
7
- require_sub __FILE__
8
- end
3
+ require 'eac_ruby_base1'
4
+ EacRubyBase1::RootModuleSetup.perform __FILE__
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eac_config
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.15.0
4
+ version: 0.15.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Put here the authors
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2025-06-05 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: addressable
@@ -16,56 +15,48 @@ dependencies:
16
15
  requirements:
17
16
  - - "~>"
18
17
  - !ruby/object:Gem::Version
19
- version: '2.8'
20
- - - ">="
21
- - !ruby/object:Gem::Version
22
- version: 2.8.7
18
+ version: '2.9'
23
19
  type: :runtime
24
20
  prerelease: false
25
21
  version_requirements: !ruby/object:Gem::Requirement
26
22
  requirements:
27
23
  - - "~>"
28
24
  - !ruby/object:Gem::Version
29
- version: '2.8'
30
- - - ">="
31
- - !ruby/object:Gem::Version
32
- version: 2.8.7
25
+ version: '2.9'
33
26
  - !ruby/object:Gem::Dependency
34
- name: eac_ruby_utils
27
+ name: eac_ruby_base1
35
28
  requirement: !ruby/object:Gem::Requirement
36
29
  requirements:
37
30
  - - "~>"
38
31
  - !ruby/object:Gem::Version
39
- version: '0.127'
32
+ version: '0.1'
33
+ - - ">="
34
+ - !ruby/object:Gem::Version
35
+ version: 0.1.1
40
36
  type: :runtime
41
37
  prerelease: false
42
38
  version_requirements: !ruby/object:Gem::Requirement
43
39
  requirements:
44
40
  - - "~>"
45
41
  - !ruby/object:Gem::Version
46
- version: '0.127'
42
+ version: '0.1'
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: 0.1.1
47
46
  - !ruby/object:Gem::Dependency
48
47
  name: eac_ruby_gem_support
49
48
  requirement: !ruby/object:Gem::Requirement
50
49
  requirements:
51
50
  - - "~>"
52
51
  - !ruby/object:Gem::Version
53
- version: '0.11'
54
- - - ">="
55
- - !ruby/object:Gem::Version
56
- version: 0.11.1
52
+ version: '0.15'
57
53
  type: :development
58
54
  prerelease: false
59
55
  version_requirements: !ruby/object:Gem::Requirement
60
56
  requirements:
61
57
  - - "~>"
62
58
  - !ruby/object:Gem::Version
63
- version: '0.11'
64
- - - ">="
65
- - !ruby/object:Gem::Version
66
- version: 0.11.1
67
- description:
68
- email:
59
+ version: '0.15'
69
60
  executables: []
70
61
  extensions: []
71
62
  extra_rdoc_files: []
@@ -98,10 +89,8 @@ files:
98
89
  - lib/eac_config/yaml_file_node.rb
99
90
  - lib/eac_config/yaml_file_node/entry.rb
100
91
  - lib/eac_config/yaml_file_node/self_entries.rb
101
- homepage:
102
92
  licenses: []
103
93
  metadata: {}
104
- post_install_message:
105
94
  rdoc_options: []
106
95
  require_paths:
107
96
  - lib
@@ -109,15 +98,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
109
98
  requirements:
110
99
  - - ">="
111
100
  - !ruby/object:Gem::Version
112
- version: 2.7.0
101
+ version: '3.2'
113
102
  required_rubygems_version: !ruby/object:Gem::Requirement
114
103
  requirements:
115
104
  - - ">="
116
105
  - !ruby/object:Gem::Version
117
106
  version: '0'
118
107
  requirements: []
119
- rubygems_version: 3.1.6
120
- signing_key:
108
+ rubygems_version: 3.6.9
121
109
  specification_version: 4
122
110
  summary: Put here de description.
123
111
  test_files: []