envvy 1.0.7 → 1.0.8

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8964d989a7f48c96aba90ab6bca1abbdd4b49ca2
4
- data.tar.gz: 85d8c93540837b8251dda610e21106d8d136950d
3
+ metadata.gz: ac16142198bf160408763202786ef9c908e904e9
4
+ data.tar.gz: 3597049580d66c7a22ed6bb16647f0e7392c5598
5
5
  SHA512:
6
- metadata.gz: 6605e9a35a4da1f83f8f7fe79444ead51c653e409851c1059b42c2e04c39c249269f37ebf5d467c76a331ea46cec8f40f564d361eb1264e41542910408ad2fd7
7
- data.tar.gz: f0a22dcd8eb6e9e7f6b7a0ca5582a6f110ef579a2266e2db4c73af862e2a78d366cc0247cec17967b6e7bcbf33591e6041a013047fe39f7bc444fabe329fba12
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
@@ -1,3 +1,3 @@
1
1
  module Envvy
2
- VERSION = "1.0.7"
2
+ VERSION = "1.0.8"
3
3
  end
@@ -1,5 +1,10 @@
1
1
  config:
2
2
  some_key: secret
3
3
  storage: "/mnt/storage"
4
+
4
5
  js_config:
5
6
  xx_api: http://localhost:3002
7
+
8
+ test:
9
+ config:
10
+ some_key: test secret
@@ -27,4 +27,6 @@ Dummy::Application.configure do
27
27
  config.eager_load = true
28
28
 
29
29
  config.i18n.default_locale = :fr
30
+
31
+ config.active_support.test_order = :random
30
32
  end
@@ -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
- assert ENV["SOME_KEY"] = "secret"
8
- assert ENV["STORAGE"] = "/mnt/storage"
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.7
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-03 00:00:00.000000000 Z
12
+ date: 2015-05-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails