gaston 0.1.5 → 0.2.0

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.
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
- @parse = YAML.load(ERB.new(File.read(file)).result) || {}
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
@@ -1,4 +1,4 @@
1
1
  # encoding: utf-8
2
2
  class Gaston
3
- VERSION = "0.1.5"
3
+ VERSION = "0.2.0"
4
4
  end
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.1.5
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-16 00:00:00.000000000 Z
12
+ date: 2012-10-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec