confg 1.0.2 → 1.0.3
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 +4 -4
- data/lib/confg/configuration.rb +15 -4
- data/lib/confg/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3a22248aee15636933d13104780068971f2663a3
|
4
|
+
data.tar.gz: e8b1bbf96b54edf9cf796ed5c49724df47b93f87
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2e7cf98c81efeb762c04acc64c82e7c15a5792d9b54c8a1de90433562e4fcd27f797fc09869abaa297b9881270d40b9d3dd06017984f43337cc82527129092b8
|
7
|
+
data.tar.gz: 12dfb2ab1b2d4c6c1a1e5cff7adf12a0e3ffc8919686e09a72f54cffc9b251f4fcaeb37e27faa7b20e7f81b1d2a5957cc4caf348eb7e876498b3eadf89eddc58
|
data/lib/confg/configuration.rb
CHANGED
@@ -18,6 +18,15 @@ module Confg
|
|
18
18
|
end
|
19
19
|
alias_method :merge!, :merge
|
20
20
|
|
21
|
+
def to_hash
|
22
|
+
out = @attributes.to_h.dup
|
23
|
+
out.each_pair do |k,v|
|
24
|
+
out[k] = v.to_hash if v.is_a?(self.class)
|
25
|
+
end
|
26
|
+
out
|
27
|
+
end
|
28
|
+
alias_method :to_h, :to_hash
|
29
|
+
|
21
30
|
def [](key)
|
22
31
|
self.get(key)
|
23
32
|
end
|
@@ -36,10 +45,10 @@ module Confg
|
|
36
45
|
|
37
46
|
def load_key(key)
|
38
47
|
# loads yaml file with given key
|
39
|
-
load_yaml(key, key)
|
48
|
+
load_yaml(key, key: key)
|
40
49
|
end
|
41
50
|
|
42
|
-
def load_yaml(path, key
|
51
|
+
def load_yaml(path, key: nil, ignore_env: false)
|
43
52
|
path = find_config_yaml(path)
|
44
53
|
raw_content = File.open(path, 'r'){|io| io.read } rescue nil
|
45
54
|
|
@@ -48,8 +57,10 @@ module Confg
|
|
48
57
|
ctxt = ::Confg::ErbContext.new
|
49
58
|
content = ctxt.evaluate(raw_content)
|
50
59
|
|
51
|
-
|
52
|
-
|
60
|
+
unless ignore_env
|
61
|
+
env = defined?(Rails) ? Rails.env.to_s : ENV["RAILS_ENV"] || ENV["RACK_ENV"]
|
62
|
+
content = content[Rails.env] if env && content.is_a?(::Hash) && content.has_key?(Rails.env)
|
63
|
+
end
|
53
64
|
|
54
65
|
if key
|
55
66
|
self.set(key, content)
|
data/lib/confg/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: confg
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Nelson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-12-
|
11
|
+
date: 2017-12-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|