envvy 1.0.7 → 1.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/envvy/engine.rb +20 -0
- data/lib/envvy/version.rb +1 -1
- data/test/dummy_app/config/env_vars.yml +5 -0
- data/test/dummy_app/config/environments/test.rb +2 -0
- data/test/engine/engine_test.rb +5 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ac16142198bf160408763202786ef9c908e904e9
|
4
|
+
data.tar.gz: 3597049580d66c7a22ed6bb16647f0e7392c5598
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d897e363534cb8bad60c67753042d2a23367a638d4a9ada3180983f686b4438e42287415eca760227092ad1241adab4681b13d4228e4b9f7a5a266a844e201b8
|
7
|
+
data.tar.gz: ccc37405faec5c0d3aff2ce847997fa2ad9718826348270602e04b9d0afd1450b0fd3d8c1939a099c8ad2216a1a38800b694794752c87871529a896802f7cccc
|
data/lib/envvy/engine.rb
CHANGED
@@ -50,6 +50,10 @@ module Envvy
|
|
50
50
|
def set_env file
|
51
51
|
self.env = {"js_config" => {}, "config" => {}}
|
52
52
|
self.env.merge! YAML.load(File.read(file)) if File.exist?(file)
|
53
|
+
|
54
|
+
if env[Rails.env]
|
55
|
+
self.env.deep_merge!(self.env[Rails.env])
|
56
|
+
end
|
53
57
|
end
|
54
58
|
|
55
59
|
def get(key, &block)
|
@@ -59,5 +63,21 @@ module Envvy
|
|
59
63
|
return self.env[key]
|
60
64
|
end
|
61
65
|
end
|
66
|
+
|
67
|
+
private
|
68
|
+
|
69
|
+
def merge_current_env!(hash)
|
70
|
+
rails_envs.each do |rails_env|
|
71
|
+
if Rails.env == rails_env && hash[rails_env]
|
72
|
+
hash.merge! hash[rails_env]
|
73
|
+
end
|
74
|
+
hash.delete rails_env
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def rails_envs
|
79
|
+
@rails_envs ||= Dir.glob(Rails.root + "config/environments/*.rb")
|
80
|
+
.map { |filename| File.basename(filename, ".rb") }
|
81
|
+
end
|
62
82
|
end
|
63
83
|
end
|
data/lib/envvy/version.rb
CHANGED
data/test/engine/engine_test.rb
CHANGED
@@ -4,7 +4,10 @@ class EnvvyEngineTest < Minitest::Test
|
|
4
4
|
|
5
5
|
# Based on test/dummy_app/config/env_vars.yml
|
6
6
|
def test_env_variables_exist
|
7
|
-
|
8
|
-
|
7
|
+
assert_equal "/mnt/storage", ENV["STORAGE"]
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_env_specific_variable_exist
|
11
|
+
assert_equal "test secret", ENV["SOME_KEY"]
|
9
12
|
end
|
10
13
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: envvy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Guillaume Balaine
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-05-
|
12
|
+
date: 2015-05-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|