eac_config 0.14.3 → 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: f2bb825a40b843c079d5972653c7d131b02f53c30f67666385bbd2c09dd1126a
4
- data.tar.gz: 9882816c1abb0df01c34ded3300f444671a67614b34aff5acca0dc19d29607a5
3
+ metadata.gz: 1b74bc1ca4debbeb6a28606a3fe821e428197d5c00074025d071988d822bc7e2
4
+ data.tar.gz: 87a26f9f8a3db12b5f9a7b46a7d33fb6f5e692cc36e24d4072847772962999d8
5
5
  SHA512:
6
- metadata.gz: 24599fc13c12ec0edf12ed30a9a66193b8318e920a7e2704cff0282f31bbec5849336629837a2e13205779a86275d939f31ba29213f104ea63c175945558f494
7
- data.tar.gz: df2696b6a7929f6f4bd559ba121926d5960858fee7c54cf4e2d6746aa9097b3162322b1eb739e284666bb77a6126a23d9e1b918abdfa801aecb255b58b5ae9b1
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/core_ext'
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/core_ext'
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/core_ext'
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/core_ext'
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,11 +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/blank_not_blank'
6
- require 'eac_ruby_utils/core_ext'
7
- require 'eac_ruby_utils/yaml'
8
-
9
3
  module EacConfig
10
4
  class EnvvarsNode
11
5
  class Entry < ::EacConfig::NodeEntry
@@ -30,7 +24,7 @@ module EacConfig
30
24
  end
31
25
  end
32
26
 
33
- enable_simple_cache
27
+ enable_memoized
34
28
 
35
29
  def found?
36
30
  ENV.key?(envvar_name)
@@ -46,7 +40,7 @@ module EacConfig
46
40
 
47
41
  private
48
42
 
49
- def envvar_name_uncached
43
+ memoize def envvar_name
50
44
  self.class.entry_path_to_envvar_name(path)
51
45
  end
52
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/core_ext'
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/core_ext'
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/core_ext'
5
-
6
3
  module EacConfig
7
4
  class LoadPath
8
5
  ENTRY_PATH = ::EacConfig::EntryPath.assert(%w[load_path])
@@ -1,17 +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/core_ext'
11
- require 'eac_ruby_utils/context'
12
-
13
3
  module EacConfig
14
4
  module Node
5
+ include ::Memoized
6
+
15
7
  class << self
16
8
  def context
17
9
  @context ||= ::EacRubyUtils::Context.new
@@ -60,13 +52,12 @@ module EacConfig
60
52
  end
61
53
 
62
54
  # @return [Array<EacConfig::Node>]
63
- def recursive_loaded_nodes
55
+ memoize def recursive_loaded_nodes
64
56
  ::EacConfig::LoadNodesSearch.new(self).result
65
57
  end
66
58
 
67
59
  # @return [EacConfig::PrefixedPathNode]
68
60
  def with_prefix(path_prefix)
69
- require 'eac_config/prefixed_path_node'
70
61
  ::EacConfig::PrefixedPathNode.new(self, path_prefix)
71
62
  end
72
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/core_ext'
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,13 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'eac_ruby_utils/blank_not_blank'
4
- require 'eac_ruby_utils/core_ext'
5
- require 'eac_config/paths_hash'
6
-
7
3
  module EacConfig
8
4
  class OldConfigs
9
5
  class Base
10
- enable_simple_cache
6
+ enable_memoized
11
7
 
12
8
  common_constructor :data, default: [{}] do
13
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,15 +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/patches/hash/sym_keys_hash'
7
- require 'eac_config/paths_hash'
8
- require 'eac_ruby_utils/simple_cache'
9
5
 
10
6
  module EacConfig
11
7
  # @deprecated Use {EacConfig::YamlFileNode} instead.
12
8
  class OldConfigs
13
- include ::EacRubyUtils::SimpleCache
9
+ enable_memoized
14
10
 
15
11
  attr_reader :configs_key, :options
16
12
 
@@ -39,23 +35,17 @@ module EacConfig
39
35
  read_entry(entry_key)
40
36
  end
41
37
 
42
- def read_entry(entry_key)
43
- file.read(entry_key)
44
- end
45
-
46
- delegate :autosave?, to: :file
47
-
48
- private
49
-
50
- attr_accessor :data
51
-
52
- def file_uncached
38
+ memoize def file
53
39
  ::EacConfig::OldConfigs::File.new(
54
40
  storage_path, options
55
41
  )
56
42
  end
57
43
 
58
- def storage_path_uncached
44
+ def read_entry(entry_key)
45
+ file.read(entry_key)
46
+ end
47
+
48
+ memoize def storage_path
59
49
  path = options_storage_path || default_storage_path
60
50
  return path if ::File.exist?(path) && ::File.size(path).positive?
61
51
 
@@ -64,6 +54,12 @@ module EacConfig
64
54
  path
65
55
  end
66
56
 
57
+ delegate :autosave?, to: :file
58
+
59
+ private
60
+
61
+ attr_accessor :data
62
+
67
63
  def options_storage_path
68
64
  options[:storage_path]
69
65
  end
@@ -1,8 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'eac_ruby_utils/core_ext'
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/core_ext'
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/core_ext'
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/core_ext'
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,11 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'eac_ruby_utils/core_ext'
4
- require 'eac_ruby_utils/fs/temp'
5
- require 'eac_config/envvars_node'
6
- require 'eac_config/node'
7
- require 'eac_config/yaml_file_node'
8
-
9
3
  module EacConfig
10
4
  module Rspec
11
5
  module Setup
@@ -37,12 +31,12 @@ module EacConfig
37
31
  # temporary file is used.
38
32
  # @param node_builder [Proc] Should return the desired EacConfig node. If not provided, a
39
33
  # EacConfig::YamlFileNode is created.
40
- 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, &)
41
35
  parent_self = self
42
36
  (target_example || rspec_config).around do |example|
43
37
  parent_self.stub_eac_config_node_on_file(target_file) do |file|
44
38
  ::EacConfig::Node
45
- .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
46
40
  example.run
47
41
  end
48
42
  end
@@ -53,11 +47,11 @@ module EacConfig
53
47
  node_builder.present? ? node_builder.call(file) : ::EacConfig::YamlFileNode.new(file)
54
48
  end
55
49
 
56
- def stub_eac_config_node_on_file(target_file, &block)
50
+ def stub_eac_config_node_on_file(target_file, &)
57
51
  if target_file
58
52
  yield(target_file.to_pathname)
59
53
  else
60
- ::EacRubyUtils::Fs::Temp.on_file(&block)
54
+ ::EacRubyUtils::Fs::Temp.on_file(&)
61
55
  end
62
56
  end
63
57
  end
@@ -1,9 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'eac_ruby_utils/core_ext'
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.14.3'
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/core_ext'
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,10 +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/core_ext'
6
- require 'eac_ruby_utils/wildcards'
7
-
8
3
  module EacConfig
9
4
  class YamlFileNode
10
5
  class SelfEntries
@@ -1,15 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'addressable'
4
- require 'eac_config/node'
5
- require 'eac_ruby_utils/core_ext'
6
- require 'eac_ruby_utils/yaml'
7
4
 
8
5
  module EacConfig
9
6
  class YamlFileNode
10
- require_sub __FILE__
11
7
  include ::EacConfig::Node
12
- enable_simple_cache
8
+
9
+ enable_memoized
13
10
 
14
11
  class << self
15
12
  def from_uri(uri)
@@ -22,6 +19,17 @@ module EacConfig
22
19
  end
23
20
  compare_by :path
24
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
+
25
33
  def persist_data(new_data)
26
34
  path.parent.mkpath
27
35
  ::EacRubyUtils::Yaml.dump_file(path, new_data)
@@ -36,19 +44,6 @@ module EacConfig
36
44
  "#{self.class}[#{path}]"
37
45
  end
38
46
 
39
- private
40
-
41
- def data_uncached
42
- r = nil
43
- if path.file?
44
- r = ::EacRubyUtils::Yaml.load_file(path)
45
- elsif path.exist?
46
- raise("\"#{path}\" is a not a file")
47
- end
48
-
49
- r.is_a?(::Hash) ? r : {}
50
- end
51
-
52
47
  require_sub __FILE__, require_mode: :kernel
53
48
  end
54
49
  end
data/lib/eac_config.rb CHANGED
@@ -1,7 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'eac_ruby_utils/core_ext'
4
-
5
- module EacConfig
6
- require_sub __FILE__
7
- 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.14.3
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: 2024-11-30 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,50 +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.124'
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.124'
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.10'
52
+ version: '0.15'
54
53
  type: :development
55
54
  prerelease: false
56
55
  version_requirements: !ruby/object:Gem::Requirement
57
56
  requirements:
58
57
  - - "~>"
59
58
  - !ruby/object:Gem::Version
60
- version: '0.10'
61
- description:
62
- email:
59
+ version: '0.15'
63
60
  executables: []
64
61
  extensions: []
65
62
  extra_rdoc_files: []
@@ -92,10 +89,8 @@ files:
92
89
  - lib/eac_config/yaml_file_node.rb
93
90
  - lib/eac_config/yaml_file_node/entry.rb
94
91
  - lib/eac_config/yaml_file_node/self_entries.rb
95
- homepage:
96
92
  licenses: []
97
93
  metadata: {}
98
- post_install_message:
99
94
  rdoc_options: []
100
95
  require_paths:
101
96
  - lib
@@ -103,15 +98,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
103
98
  requirements:
104
99
  - - ">="
105
100
  - !ruby/object:Gem::Version
106
- version: 2.7.0
101
+ version: '3.2'
107
102
  required_rubygems_version: !ruby/object:Gem::Requirement
108
103
  requirements:
109
104
  - - ">="
110
105
  - !ruby/object:Gem::Version
111
106
  version: '0'
112
107
  requirements: []
113
- rubygems_version: 3.1.6
114
- signing_key:
108
+ rubygems_version: 3.6.9
115
109
  specification_version: 4
116
110
  summary: Put here de description.
117
111
  test_files: []