gaston 0.1.5 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +2 -0
- data/lib/gaston/parse.rb +11 -1
- data/lib/gaston/version.rb +1 -1
- metadata +2 -2
data/README.md
CHANGED
@@ -36,6 +36,8 @@ You can use erb inside values.
|
|
36
36
|
key: <%= ENV["API_KEY"] %>
|
37
37
|
```
|
38
38
|
|
39
|
+
Since verion `0.2.0`, gaston also accept json files.
|
40
|
+
|
39
41
|
Create an initializer. You can define an environment with the `env` method, and specify config files with the `files` method. Default `env` is `:development`.
|
40
42
|
|
41
43
|
``` ruby
|
data/lib/gaston/parse.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require 'erb'
|
3
|
+
require 'json'
|
3
4
|
|
4
5
|
class Gaston
|
5
6
|
class Parse
|
@@ -14,7 +15,7 @@ class Gaston
|
|
14
15
|
def initialize(files, env)
|
15
16
|
@env = env
|
16
17
|
@hash = files.inject({}) do |hash, file|
|
17
|
-
|
18
|
+
parse(file)
|
18
19
|
hash.merge(deep_merge_hash(default_values, env_values))
|
19
20
|
end
|
20
21
|
end
|
@@ -70,5 +71,14 @@ class Gaston
|
|
70
71
|
end
|
71
72
|
hash1
|
72
73
|
end
|
74
|
+
|
75
|
+
def parse(file)
|
76
|
+
erb = ERB.new(File.read(file)).result
|
77
|
+
if File.extname(file) == '.json'
|
78
|
+
@parse = JSON.parse(erb, :symbolize_names => true) || {}
|
79
|
+
else
|
80
|
+
@parse = YAML.load(erb) || {}
|
81
|
+
end
|
82
|
+
end
|
73
83
|
end
|
74
84
|
end
|
data/lib/gaston/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gaston
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-10-
|
12
|
+
date: 2012-10-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|