configature 0.3.4 → 0.3.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +5 -7
- data/Gemfile +3 -0
- data/Gemfile.lock +18 -14
- data/VERSION +1 -1
- data/lib/configature/config.rb +15 -13
- data/lib/configature/data.rb +3 -3
- data/lib/configature/namespace.rb +11 -3
- data/lib/configature/support.rb +2 -3
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '080afc9a5e1852192d430bb691b87260cbd9dbb5dedc5cd6803d4fb78aa2cb7e'
|
4
|
+
data.tar.gz: 294737d6d91bd078c95c7e7a908f088081a2c4143f5f4cba682034e09a915098
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 602be0de3c36b974b2ce6af817c6e352fbdee38010fe1006b7a21dc5842af615f49adfd3f3503ad8f6d787f14e47feefae00cf4a0541cb00254d5299cd1c3dbc
|
7
|
+
data.tar.gz: 1e6d62685d3beab2bdf9ccdcca98943ce3a766cff07d2f2cf8dcb8d569cc9b5fb4326ebebd4392c5f5293c85d2b508429ab6f56a7fcf2057a2b6f3f203e49557
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,26 +1,26 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
configature (0.3.
|
4
|
+
configature (0.3.7)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
9
|
diff-lcs (1.4.4)
|
10
|
-
rake (13.0.
|
11
|
-
rspec (3.
|
12
|
-
rspec-core (~> 3.
|
13
|
-
rspec-expectations (~> 3.
|
14
|
-
rspec-mocks (~> 3.
|
15
|
-
rspec-core (3.
|
16
|
-
rspec-support (~> 3.
|
17
|
-
rspec-expectations (3.
|
10
|
+
rake (13.0.3)
|
11
|
+
rspec (3.10.0)
|
12
|
+
rspec-core (~> 3.10.0)
|
13
|
+
rspec-expectations (~> 3.10.0)
|
14
|
+
rspec-mocks (~> 3.10.0)
|
15
|
+
rspec-core (3.10.1)
|
16
|
+
rspec-support (~> 3.10.0)
|
17
|
+
rspec-expectations (3.10.1)
|
18
18
|
diff-lcs (>= 1.2.0, < 2.0)
|
19
|
-
rspec-support (~> 3.
|
20
|
-
rspec-mocks (3.
|
19
|
+
rspec-support (~> 3.10.0)
|
20
|
+
rspec-mocks (3.10.2)
|
21
21
|
diff-lcs (>= 1.2.0, < 2.0)
|
22
|
-
rspec-support (~> 3.
|
23
|
-
rspec-support (3.
|
22
|
+
rspec-support (~> 3.10.0)
|
23
|
+
rspec-support (3.10.2)
|
24
24
|
|
25
25
|
PLATFORMS
|
26
26
|
ruby
|
@@ -30,6 +30,10 @@ DEPENDENCIES
|
|
30
30
|
configature!
|
31
31
|
rake
|
32
32
|
rspec
|
33
|
+
rspec-core
|
34
|
+
|
35
|
+
RUBY VERSION
|
36
|
+
ruby 3.0.1p64
|
33
37
|
|
34
38
|
BUNDLED WITH
|
35
|
-
2.
|
39
|
+
2.2.16
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.7
|
data/lib/configature/config.rb
CHANGED
@@ -7,9 +7,9 @@ require_relative './namespace'
|
|
7
7
|
|
8
8
|
class Configature::Config < Configature::Data
|
9
9
|
# == Constants ============================================================
|
10
|
-
|
10
|
+
|
11
11
|
# == Properties ===========================================================
|
12
|
-
|
12
|
+
|
13
13
|
# == Class Methods ========================================================
|
14
14
|
|
15
15
|
def self.config_dir
|
@@ -21,7 +21,9 @@ class Configature::Config < Configature::Data
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def self.namespace(name, file: nil, env_suffix: '', extends: nil, &block)
|
24
|
-
|
24
|
+
extends &&= self.namespaces[extends]
|
25
|
+
|
26
|
+
namespace = self.namespaces[name] = Configature::Namespace.new(name, env_suffix: env_suffix, extends: extends).tap do |n|
|
25
27
|
case (block&.arity)
|
26
28
|
when nil
|
27
29
|
nil
|
@@ -32,7 +34,7 @@ class Configature::Config < Configature::Data
|
|
32
34
|
end
|
33
35
|
end
|
34
36
|
|
35
|
-
file = file&.
|
37
|
+
file = (file || extends&.config_name || name).to_s
|
36
38
|
|
37
39
|
if (file and !file.include?('.'))
|
38
40
|
file += '.yml'
|
@@ -42,11 +44,9 @@ class Configature::Config < Configature::Data
|
|
42
44
|
iv = :"@#{name}"
|
43
45
|
|
44
46
|
singleton_class.send(:define_method, name) do
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
instance_variable_get(iv) or instance_variable_set(iv, namespace.__instantiate(source: config))
|
47
|
+
instance_variable_get(iv) or instance_variable_set(iv, namespace.__instantiate(
|
48
|
+
source: Configature::Support.yaml_if_exist(File.expand_path(file, self.config_dir))
|
49
|
+
))
|
50
50
|
end
|
51
51
|
end
|
52
52
|
end
|
@@ -54,15 +54,17 @@ class Configature::Config < Configature::Data
|
|
54
54
|
def self.namespaces
|
55
55
|
@namespaces ||= { }
|
56
56
|
end
|
57
|
-
|
57
|
+
|
58
58
|
# == Instance Methods =====================================================
|
59
59
|
|
60
|
-
def initialize(config_dir: nil, env: ENV)
|
60
|
+
def initialize(config_dir: nil, path: nil, env: ENV, data: nil)
|
61
61
|
super(
|
62
62
|
self.class.namespaces.map do |name, namespace|
|
63
|
-
|
63
|
+
config = data || begin
|
64
|
+
path ||= File.expand_path('%s.yml' % namespace.config_name, config_dir || self.class.config_dir)
|
64
65
|
|
65
|
-
|
66
|
+
Configature::Support.yaml_if_exist(path)
|
67
|
+
end
|
66
68
|
|
67
69
|
[
|
68
70
|
name,
|
data/lib/configature/data.rb
CHANGED
@@ -19,8 +19,8 @@ class Configature::Data < OpenStruct
|
|
19
19
|
# == Instance Methods =====================================================
|
20
20
|
|
21
21
|
def to_h
|
22
|
-
super.
|
23
|
-
self.class.hashify(v)
|
24
|
-
end
|
22
|
+
super.map do |k, v|
|
23
|
+
[ k, self.class.hashify(v) ]
|
24
|
+
end.to_h
|
25
25
|
end
|
26
26
|
end
|
@@ -40,6 +40,7 @@ class Configature::Namespace
|
|
40
40
|
# == Properties ===========================================================
|
41
41
|
|
42
42
|
attr_reader :name
|
43
|
+
attr_reader :config_name
|
43
44
|
attr_reader :env_name_prefix
|
44
45
|
attr_reader :namespaces
|
45
46
|
attr_reader :parameters
|
@@ -53,18 +54,25 @@ class Configature::Namespace
|
|
53
54
|
@extends = extends
|
54
55
|
@env = extends&.instance_variable_get(:@env)
|
55
56
|
@env_default = extends&.instance_variable_get(:@env_default)
|
56
|
-
@namespaces = extends
|
57
|
-
@parameters = extends
|
57
|
+
@namespaces = extends&.namespaces&.dup || { }
|
58
|
+
@parameters = extends&.parameters&.dup || { }
|
58
59
|
@env_suffix = env_suffix
|
59
60
|
@env_name_prefix = name ? Configature::Support.extend_env_prefix(env_name_prefix, name) : ''
|
60
61
|
|
62
|
+
@config_name = extends&.config_name || name
|
63
|
+
|
61
64
|
yield(self) if (block_given?)
|
62
65
|
end
|
63
66
|
|
64
67
|
def namespace(name, env_suffix: '', extends: nil, &block)
|
65
68
|
name = name.to_sym
|
66
69
|
|
67
|
-
@namespaces[name] = self.class.new(
|
70
|
+
@namespaces[name] = self.class.new(
|
71
|
+
name,
|
72
|
+
env_suffix: env_suffix,
|
73
|
+
extends: extends && self.namespaces[extends],
|
74
|
+
env_name_prefix: @env_name_prefix
|
75
|
+
).tap do |n|
|
68
76
|
case (block&.arity)
|
69
77
|
when nil
|
70
78
|
nil
|
data/lib/configature/support.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: configature
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Scott Tadman
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-05-29 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Assists in the creation of config files from example templates and can
|
14
14
|
identify when some customization is necessary.
|
@@ -63,7 +63,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
63
63
|
- !ruby/object:Gem::Version
|
64
64
|
version: '0'
|
65
65
|
requirements: []
|
66
|
-
rubygems_version: 3.
|
66
|
+
rubygems_version: 3.2.15
|
67
67
|
signing_key:
|
68
68
|
specification_version: 4
|
69
69
|
summary: Configuration file auto-generator
|