eac_config 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/eac_config/paths_hash.rb +7 -0
- data/lib/eac_config/rspec/setup.rb +49 -0
- data/lib/eac_config/rspec.rb +9 -0
- data/lib/eac_config/version.rb +1 -1
- data/lib/eac_config/yaml_file_node/entry.rb +2 -3
- data/lib/eac_config/yaml_file_node.rb +10 -11
- metadata +9 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8ac2dc8e897b518ae3ff7c683d486380fa6cf76ad835a718e01436f4dbc4571d
|
4
|
+
data.tar.gz: 7dbefbb66b1912343c4e2e5b529828dea1f1d5165fea20e390ede6de4d7ea3d7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5048086be008f75628f187fc588a804a41ac6903f97d8ea60f3ca07e930d823e24d5193a14fbccde27b6a8ff2e328417e2a8cc2bd45960f268031557ac5cd566
|
7
|
+
data.tar.gz: 9fe7946dcb40890a213fba6fab0af3bda15456e00b277f1eb578f69ec6f62d45c0fced3139ea61afadfe491b8bf504ed526ab36ff5298aac29ec75c2798280a4
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
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
|
+
module EacConfig
|
10
|
+
module Rspec
|
11
|
+
module Setup
|
12
|
+
def self.extended(obj)
|
13
|
+
obj.rspec_config.around do |example|
|
14
|
+
obj.on_envvars_load_path_clean(example)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def on_envvars_load_path_clean(example)
|
19
|
+
old_value = envvars_load_path_entry.value
|
20
|
+
begin
|
21
|
+
envvars_load_path_entry.value = old_value = []
|
22
|
+
example.run
|
23
|
+
ensure
|
24
|
+
envvars_load_path_entry.value = old_value
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def envvars_load_path_entry
|
29
|
+
::EacConfig::EnvvarsNode.new.load_path.entry
|
30
|
+
end
|
31
|
+
|
32
|
+
def stub_eac_config_node(&node_builder)
|
33
|
+
parent_self = self
|
34
|
+
rspec_config.around do |example|
|
35
|
+
::EacRubyUtils::Fs::Temp.on_file do |file|
|
36
|
+
::EacConfig::Node
|
37
|
+
.context.on(parent_self.stub_eac_config_node_build(file, &node_builder)) do
|
38
|
+
example.run
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def stub_eac_config_node_build(file, &node_builder)
|
45
|
+
node_builder.present? ? node_builder.call(file) : ::EacConfig::YamlFileNode.new(file)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
data/lib/eac_config/version.rb
CHANGED
@@ -18,14 +18,13 @@ module EacConfig
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def value=(a_value)
|
21
|
-
paths_hash
|
22
|
-
node.persist_data(paths_hash.root.to_h)
|
21
|
+
node.persist_data(paths_hash.write(to_paths_hash_key, a_value).root.to_h)
|
23
22
|
end
|
24
23
|
|
25
24
|
private
|
26
25
|
|
27
26
|
# @return [EacConfig::PathsHash]
|
28
|
-
def
|
27
|
+
def paths_hash
|
29
28
|
::EacConfig::PathsHash.new(node.data)
|
30
29
|
end
|
31
30
|
|
@@ -9,6 +9,7 @@ module EacConfig
|
|
9
9
|
class YamlFileNode
|
10
10
|
require_sub __FILE__
|
11
11
|
include ::EacConfig::Node
|
12
|
+
enable_simple_cache
|
12
13
|
|
13
14
|
class << self
|
14
15
|
def from_uri(uri)
|
@@ -20,14 +21,10 @@ module EacConfig
|
|
20
21
|
self.path = path.to_pathname
|
21
22
|
end
|
22
23
|
|
23
|
-
def data
|
24
|
-
@data ||= ::EacRubyUtils::Yaml.load_file(assert_path) || {}
|
25
|
-
end
|
26
|
-
|
27
24
|
def persist_data(new_data)
|
28
25
|
path.parent.mkpath
|
29
26
|
::EacRubyUtils::Yaml.dump_file(path, new_data)
|
30
|
-
|
27
|
+
reset_cache(:data)
|
31
28
|
end
|
32
29
|
|
33
30
|
def url
|
@@ -36,13 +33,15 @@ module EacConfig
|
|
36
33
|
|
37
34
|
private
|
38
35
|
|
39
|
-
def
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
36
|
+
def data_uncached
|
37
|
+
r = nil
|
38
|
+
if path.file?
|
39
|
+
r = ::EacRubyUtils::Yaml.load_file(path)
|
40
|
+
elsif path.exist?
|
41
|
+
raise("\"#{path}\" is a not a file")
|
44
42
|
end
|
45
|
-
|
43
|
+
|
44
|
+
r.is_a?(::Hash) ? r : {}
|
46
45
|
end
|
47
46
|
end
|
48
47
|
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.
|
4
|
+
version: 0.6.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: 2021-
|
11
|
+
date: 2021-12-11 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.
|
33
|
+
version: '0.81'
|
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.
|
40
|
+
version: '0.81'
|
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.
|
47
|
+
version: '0.3'
|
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.
|
54
|
+
version: '0.3'
|
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/rspec.rb
|
79
|
+
- lib/eac_config/rspec/setup.rb
|
78
80
|
- lib/eac_config/version.rb
|
79
81
|
- lib/eac_config/yaml_file_node.rb
|
80
82
|
- lib/eac_config/yaml_file_node/entry.rb
|
@@ -96,7 +98,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
96
98
|
- !ruby/object:Gem::Version
|
97
99
|
version: '0'
|
98
100
|
requirements: []
|
99
|
-
rubygems_version: 3.
|
101
|
+
rubygems_version: 3.1.6
|
100
102
|
signing_key:
|
101
103
|
specification_version: 4
|
102
104
|
summary: Put here de description.
|