json_to_env 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/json_to_env.rb +11 -2
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b70c4f0d0f4624664f79e08e24ddc986355297ba
4
- data.tar.gz: a0202bff86d6d16daac1bee2f361e5412bbbd3c2
3
+ metadata.gz: 99dbd0a251f8ffdc6b9a42dfee1b49d7f1525a34
4
+ data.tar.gz: 17baba1153f3b41220d0efcee2a208d4e965df7c
5
5
  SHA512:
6
- metadata.gz: 3e49764537a8e747511ece630fd2b257c69162e474313148ec4440caa952189bea712028fdf92a24988406b336e7095c0bb3c3eb936bad843ecd77d86f7ad16b
7
- data.tar.gz: 0368fcd4d2aa5fa90a81da0a6f3ca31c97bc0061218bfb3f067ffcd372741244f052697d3da3172321ac9fd40598388713a7538194ee53469917ceed804804c7
6
+ metadata.gz: 8f3c25857b4aa65b5e14741057e973807ee1ed8224b2026a631166a24a95b21239d9e9b98299a30b785ab15431a96cf20e69d0d755fbdd6262907471373313e5
7
+ data.tar.gz: 79f964dd2bd0cfb48860360823c4ec40bdc64eb4962ed5b730ea6f52317c14ee6e5f3ecd7a8427d8f86adaef8ad1f23bad2fed1ded9821379091e5ecbb8a9eb0
@@ -1,5 +1,7 @@
1
+ require 'json'
2
+
1
3
  class JsonToEnv
2
- VERSION = "0.1.0"
4
+ VERSION = "0.2.0"
3
5
 
4
6
  def self.load(json)
5
7
  hash = JSON.parse json
@@ -17,7 +19,14 @@ class JsonToEnv
17
19
  end
18
20
  end
19
21
 
20
- envs.each { |k,v| ENV[k] = v unless ENV.has_key? k }
22
+ envs.each { |k,v| ENV[k] = self.stringify(v) unless ENV.has_key? k }
23
+ end
24
+
25
+ def self.stringify(v)
26
+ str_value = v
27
+ str_value = JSON.dump(v) if v.is_a?(Array)
28
+ str_value = JSON.dump(v) if v.is_a?(Hash)
29
+ str_value.to_s
21
30
  end
22
31
 
23
32
  def self.load_file(file_path)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: json_to_env
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen Crosby
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-12 00:00:00.000000000 Z
11
+ date: 2015-03-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler