config-reader 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/config-reader.rb +7 -4
- data/lib/config-reader/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c7ce214efba842d40d1adc82bf5313ca57f2f3099e510068d4a4f0739371bc47
|
4
|
+
data.tar.gz: cbd23f6c1163bc9a84ba243cd7346d3a6b4a34c27092f1e2466e254b6d753557
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6e4e3cbf47c540791af60f56e8333ab3ec4a88f5e3f656886e15a03c14d125085818f7f7317210122afee14b32ba62ad2223dba5f4d464bcfed129627ec98335
|
7
|
+
data.tar.gz: 66c0d83bc8bd2bd4ffd4efd6b24aef8b2ce1eec124bac584c3175140aaccf3db0f53ccd179a6eb542c346cba74c01562b118f344494ec0495d967e4c7036482f
|
data/lib/config-reader.rb
CHANGED
@@ -3,10 +3,13 @@ require 'erb'
|
|
3
3
|
require 'ostruct'
|
4
4
|
require 'yaml'
|
5
5
|
|
6
|
-
class ConfigReader
|
6
|
+
class ConfigReader
|
7
|
+
# Process IO as ERB and then YAML
|
8
|
+
# and return results as OpenStruct
|
9
|
+
# @param [String] path
|
10
|
+
# @param [String,Symbol] env
|
11
|
+
# @return [OpenStruct]
|
7
12
|
def self.load(path, env)
|
8
|
-
|
9
|
-
processed = ERB.new(contents).result
|
10
|
-
new(YAML.load(processed)[env.to_s])
|
13
|
+
OpenStruct.new(YAML.load(ERB.new(IO.read(path)).result)[env.to_s])
|
11
14
|
end
|
12
15
|
end
|