confg 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/confg.rb +8 -0
- data/lib/confg/configuration.rb +5 -5
- data/lib/confg/erb_context.rb +14 -0
- data/lib/confg/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 586d879e12ec7af553fbae6344c93d8d3d7651a7
|
4
|
+
data.tar.gz: 8a2394ac7e568b0559d6307e73092e6e75a43b39
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: caa46a61612f4fa7719381f96843dc8abb96aa8e6a702e6e015eb41300a03ecf7d9fa55b0a85186bfe30af5be5aa68159e04ddd49101e95791a8e99c68bc23bd
|
7
|
+
data.tar.gz: 834b091feed593e873e06ce86b79931959ff98f868058a89bce89e43efe432d866dcb868ba3ec2e93306ae31b40a325228b272755c7c5e03c65894c7aaac16c9
|
data/lib/confg.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'confg/version'
|
2
2
|
require 'confg/configuration'
|
3
|
+
require 'confg/erb_context'
|
3
4
|
|
4
5
|
module Confg
|
5
6
|
|
@@ -9,6 +10,13 @@ module Confg
|
|
9
10
|
@root ||= Pathname.new(calc_root_string).expand_path
|
10
11
|
end
|
11
12
|
|
13
|
+
def erb_function(function_name, &block)
|
14
|
+
::Confg::ErbContext.class_eval do
|
15
|
+
define_method(function_name, &block)
|
16
|
+
end
|
17
|
+
self
|
18
|
+
end
|
19
|
+
|
12
20
|
def configure(raise_on_missed_key = false)
|
13
21
|
@configuration ||= ::Confg::Configuration.new(raise_on_missed_key)
|
14
22
|
yield @configuration if block_given?
|
data/lib/confg/configuration.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'yaml'
|
2
|
-
require 'erb'
|
3
1
|
require 'active_support/core_ext/module/delegation'
|
4
2
|
|
5
3
|
module Confg
|
@@ -47,9 +45,11 @@ module Confg
|
|
47
45
|
|
48
46
|
return unless raw_content
|
49
47
|
|
50
|
-
|
51
|
-
content
|
52
|
-
|
48
|
+
ctxt = ::Confg::ErbContext.new
|
49
|
+
content = ctxt.evaluate(raw_content)
|
50
|
+
|
51
|
+
env = defined?(Rails) ? Rails.env.to_s : ENV["RAILS_ENV"] || ENV["RACK_ENV"]
|
52
|
+
content = content[Rails.env] if env && content.is_a?(::Hash) && content.has_key?(Rails.env)
|
53
53
|
|
54
54
|
if key
|
55
55
|
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.1
|
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-
|
11
|
+
date: 2017-12-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -38,6 +38,7 @@ files:
|
|
38
38
|
- confg.gemspec
|
39
39
|
- lib/confg.rb
|
40
40
|
- lib/confg/configuration.rb
|
41
|
+
- lib/confg/erb_context.rb
|
41
42
|
- lib/confg/version.rb
|
42
43
|
homepage: ''
|
43
44
|
licenses: []
|