config_env 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +17 -6
- data/lib/config_env/version.rb +1 -1
- data/lib/config_env.rb +6 -5
- data/spec/lib/config_env/rake_tasts_spec.rb +7 -7
- data/spec/lib/config_env_spec.rb +9 -5
- data/spec/spec_helper.rb +0 -2
- metadata +3 -7
- data/.ruby-gemset +0 -1
- data/.ruby-version +0 -1
- data/spec/support/rnd_helpers.rb +0 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ef1573f36c0335e6447a11bc7727ab2476b79084
|
4
|
+
data.tar.gz: 4333a92141a27773f65a8b220d62dbcabc590f67
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a8ccb2f23be8ba979276f1efc4406c3188a98b843dd977ce477ced0b9d7c5458f6012925bf146af705f4c1b4a43044a79657af90ed51fa3748359e70a176358a
|
7
|
+
data.tar.gz: 130661404a0c633644cbbadc07e914e5590e4925399e9843a625e7c429e792da918b8fb03cde5bc9a9171f6de9d872fc76ba405b58da4366ad3ef8e721ae99a5
|
data/README.md
CHANGED
@@ -1,4 +1,9 @@
|
|
1
|
-
# ConfigEnv - config your
|
1
|
+
# ConfigEnv - config your ENV['variables']
|
2
|
+
|
3
|
+
|
4
|
+
[![Code Climate](https://codeclimate.com/github/SergXIIIth/config_env.png)](https://codeclimate.com/github/SergXIIIth/config_env)
|
5
|
+
[![Dependency Status](https://gemnasium.com/SergXIIIth/config_env.svg)](https://gemnasium.com/SergXIIIth/config_env)
|
6
|
+
|
2
7
|
|
3
8
|
Configurator of the `ENV['key']` for any Ruby environment
|
4
9
|
|
@@ -8,19 +13,20 @@ Configurator of the `ENV['key']` for any Ruby environment
|
|
8
13
|
|
9
14
|
## Usage
|
10
15
|
|
16
|
+
```ruby
|
11
17
|
gem 'config_env'
|
12
18
|
|
13
19
|
# Specify path your `config_env.rb`
|
14
20
|
ConfigEnv.path_to_config("#{__dir__}/config/config_env.rb")
|
21
|
+
```
|
15
22
|
|
16
|
-
Create file `config/
|
23
|
+
Create file `config/env.rb`:
|
17
24
|
|
18
|
-
|
19
|
-
config_env do
|
25
|
+
```ruby
|
26
|
+
config_env do
|
20
27
|
set 'secret_key', 'value_for_all_RACK_ENV'
|
21
28
|
end
|
22
29
|
|
23
|
-
# only when ENV['RACK_ENV'] == :test
|
24
30
|
config_env :test do
|
25
31
|
set 'secret_key', 'overwrite_value_for_test_rack_env'
|
26
32
|
end
|
@@ -28,10 +34,15 @@ Create file `config/config_env.rb`:
|
|
28
34
|
config_env :production, :development do
|
29
35
|
set 'secret_key', 'overwrite_value_for_test_or_dev_rack_env'
|
30
36
|
end
|
37
|
+
```
|
38
|
+
|
39
|
+
For Rails add to `application.rb`
|
40
|
+
|
41
|
+
ConfigEnv.path_to_config("#{__dir__}/env.rb")
|
31
42
|
|
32
43
|
Add line to `.gitignore`
|
33
44
|
|
34
|
-
|
45
|
+
config/env.rb
|
35
46
|
|
36
47
|
|
37
48
|
### Upload configurated variables to Heroku
|
data/lib/config_env/version.rb
CHANGED
data/lib/config_env.rb
CHANGED
@@ -20,13 +20,13 @@ module ConfigEnv
|
|
20
20
|
env = env.to_s
|
21
21
|
@vars[env] ||= {}
|
22
22
|
@vars[env].merge!(vars)
|
23
|
-
end
|
23
|
+
end
|
24
24
|
end
|
25
25
|
|
26
26
|
def self.vars(environment = nil)
|
27
27
|
environment ||= self.environment
|
28
28
|
environment = environment.to_s
|
29
|
-
|
29
|
+
|
30
30
|
vars = (vars_hash[environment] || {}).clone
|
31
31
|
vars.merge!(vars_hash["any"] || {})
|
32
32
|
|
@@ -79,7 +79,8 @@ def config_env(*envs, &code)
|
|
79
79
|
|
80
80
|
envs = envs.size > 0 ? envs : ['any']
|
81
81
|
|
82
|
-
|
83
|
-
|
84
|
-
|
82
|
+
if command.vars
|
83
|
+
ConfigEnv.set_vars(command.vars, envs)
|
84
|
+
ConfigEnv.setup_env(command.vars, envs)
|
85
|
+
end
|
85
86
|
end
|
@@ -4,18 +4,18 @@ require 'config_env/rake_tasks'
|
|
4
4
|
module ConfigEnv::Tasks
|
5
5
|
describe Heroku do
|
6
6
|
before { ConfigEnv.clear }
|
7
|
-
|
7
|
+
|
8
8
|
it 'set use :production as default env'
|
9
9
|
|
10
10
|
describe '#upload_env_to_heroku' do
|
11
11
|
it 'set config:set to heroku' do
|
12
12
|
heroku = Heroku.new
|
13
|
-
|
14
|
-
key2 = "key2_#{rnd}"
|
15
|
-
val2 = "val2_#{rnd}"
|
16
13
|
|
17
|
-
|
18
|
-
|
14
|
+
key2 = "key2_#{rand(1000)}"
|
15
|
+
val2 = "val2_#{rand(1000)}"
|
16
|
+
|
17
|
+
key = "key_#{rand(1000)}"
|
18
|
+
val = "val_#{rand(1000)}"
|
19
19
|
|
20
20
|
config_env :production do
|
21
21
|
set key2, val2
|
@@ -28,7 +28,7 @@ module ConfigEnv::Tasks
|
|
28
28
|
expect(heroku).to receive(:heroku){ 'production' }
|
29
29
|
expect(heroku).to receive(:heroku).with('config')
|
30
30
|
expect(heroku).to receive(:heroku).with("config:set #{key2}=#{val2} #{key}=#{val}")
|
31
|
-
|
31
|
+
|
32
32
|
heroku.upload_env_to_heroku
|
33
33
|
end
|
34
34
|
end
|
data/spec/lib/config_env_spec.rb
CHANGED
@@ -2,8 +2,8 @@ require 'spec_helper'
|
|
2
2
|
require 'ostruct'
|
3
3
|
|
4
4
|
describe ConfigEnv do
|
5
|
-
let(:key){ "key_#{
|
6
|
-
let(:val){ "val_#{
|
5
|
+
let(:key){ "key_#{rand(1000)}" }
|
6
|
+
let(:val){ "val_#{rand(1000)}" }
|
7
7
|
|
8
8
|
before { ConfigEnv.clear }
|
9
9
|
|
@@ -31,7 +31,6 @@ describe ConfigEnv do
|
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
-
|
35
34
|
describe '.vars' do
|
36
35
|
it 'returns empty hash by default' do
|
37
36
|
ConfigEnv.vars.should == {}
|
@@ -51,8 +50,8 @@ describe ConfigEnv do
|
|
51
50
|
it 'returns production and any envs values' do
|
52
51
|
key = key()
|
53
52
|
val = val()
|
54
|
-
key2 = "key2_#{
|
55
|
-
val2 = "val2_#{
|
53
|
+
key2 = "key2_#{rand(1000)}"
|
54
|
+
val2 = "val2_#{rand(1000)}"
|
56
55
|
|
57
56
|
config_env :production do
|
58
57
|
set key2, val2
|
@@ -92,5 +91,10 @@ describe ConfigEnv do
|
|
92
91
|
|
93
92
|
ENV['RACK_ENV'] = old_rack_env
|
94
93
|
end
|
94
|
+
|
95
|
+
it 'allow empty in block' do
|
96
|
+
config_env do
|
97
|
+
end
|
98
|
+
end
|
95
99
|
end
|
96
100
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: config_env
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sergey Makridenkov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -74,8 +74,6 @@ extensions: []
|
|
74
74
|
extra_rdoc_files: []
|
75
75
|
files:
|
76
76
|
- ".gitignore"
|
77
|
-
- ".ruby-gemset"
|
78
|
-
- ".ruby-version"
|
79
77
|
- Gemfile
|
80
78
|
- LICENSE.txt
|
81
79
|
- README.md
|
@@ -87,7 +85,6 @@ files:
|
|
87
85
|
- spec/lib/config_env/rake_tasts_spec.rb
|
88
86
|
- spec/lib/config_env_spec.rb
|
89
87
|
- spec/spec_helper.rb
|
90
|
-
- spec/support/rnd_helpers.rb
|
91
88
|
homepage: https://github.com/SergXIIIth/config_env
|
92
89
|
licenses:
|
93
90
|
- MIT
|
@@ -108,7 +105,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
108
105
|
version: '0'
|
109
106
|
requirements: []
|
110
107
|
rubyforge_project:
|
111
|
-
rubygems_version: 2.
|
108
|
+
rubygems_version: 2.5.1
|
112
109
|
signing_key:
|
113
110
|
specification_version: 4
|
114
111
|
summary: ENV manager for any Ruby code
|
@@ -116,4 +113,3 @@ test_files:
|
|
116
113
|
- spec/lib/config_env/rake_tasts_spec.rb
|
117
114
|
- spec/lib/config_env_spec.rb
|
118
115
|
- spec/spec_helper.rb
|
119
|
-
- spec/support/rnd_helpers.rb
|
data/.ruby-gemset
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
config_env
|
data/.ruby-version
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
ruby-2.1
|
data/spec/support/rnd_helpers.rb
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
module RndHelpers
|
2
|
-
def rnd(text = nil)
|
3
|
-
RndHelpers.rnd(text)
|
4
|
-
end
|
5
|
-
|
6
|
-
# rnd -> 1,5,7
|
7
|
-
# rnd('key') -> key 1, key 5, key 7
|
8
|
-
def self.rnd(text = nil)
|
9
|
-
rnd = Random.rand(10000)
|
10
|
-
if text.nil?
|
11
|
-
rnd
|
12
|
-
else
|
13
|
-
"#{text}_#{rnd}"
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|