config_env 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/README.md +17 -23
- data/config_env.gemspec +5 -5
- data/lib/config_env/version.rb +1 -1
- data/lib/config_env.rb +5 -2
- data/spec/{config_env → lib/config_env}/rake_tasts_spec.rb +1 -1
- data/spec/{config_env_spec.rb → lib/config_env_spec.rb} +46 -21
- metadata +29 -29
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d9767a6ba806006a66c7539931f5b7898ae8b8a1
|
4
|
+
data.tar.gz: 2988dcd695c7d0b580a01a345205322afc2c6953
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 42898bb84560900b9a51e606ca449fca5882bae46904cc2d7e9bb1a432e4f451000f09606bebe917fa3627d2dc27e9e9d9d68064991e9f3b295b0c8b0d50a03e
|
7
|
+
data.tar.gz: f13c8f98f84a314c30f16850a8094d27b32b865e361cf3f6e1dbc44464468c2a9068e4dad3abd5a5de5d98088e4dfb6d13fa8dc8c3fe343c3f041a68ec24f4f8
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
ruby-2.
|
1
|
+
ruby-2.1
|
data/README.md
CHANGED
@@ -1,57 +1,51 @@
|
|
1
|
-
# ConfigEnv
|
1
|
+
# ConfigEnv - config your `ENV['variables']`
|
2
2
|
|
3
|
-
ENV
|
3
|
+
Configurator of the `ENV['key']` for any Ruby environment
|
4
4
|
|
5
|
-
-
|
6
|
-
- Upload
|
5
|
+
- Describe `ENV['key']` variables in config file with Ruby syntax
|
6
|
+
- Upload the configuration to Heroku
|
7
7
|
|
8
|
-
Note. It similar to Sinarta configuration
|
9
8
|
|
10
|
-
##
|
11
|
-
|
12
|
-
Add to Gemfile (as top as possible):
|
9
|
+
## Usage
|
13
10
|
|
14
11
|
gem 'config_env'
|
15
12
|
|
16
|
-
|
13
|
+
# Specify path your `config_env.rb`
|
14
|
+
ConfigEnv.path_to_config("#{__dir__}/config/config_env.rb")
|
17
15
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
## Usage
|
22
|
-
|
23
|
-
Create file `config_env.rb`:
|
16
|
+
Create file `config/config_env.rb`:
|
24
17
|
|
25
18
|
# any ENV['RACK_ENV']
|
26
19
|
config_env do
|
27
|
-
set '
|
20
|
+
set 'secret_key', 'value_for_all_RACK_ENV'
|
28
21
|
end
|
29
22
|
|
30
23
|
# only when ENV['RACK_ENV'] == :test
|
31
24
|
config_env :test do
|
32
|
-
set '
|
25
|
+
set 'secret_key', 'overwrite_value_for_test_rack_env'
|
33
26
|
end
|
34
27
|
|
35
28
|
config_env :production, :development do
|
36
|
-
set '
|
29
|
+
set 'secret_key', 'overwrite_value_for_test_or_dev_rack_env'
|
37
30
|
end
|
38
31
|
|
39
32
|
Add line to `.gitignore`
|
40
33
|
|
41
34
|
config_env.rb
|
42
35
|
|
43
|
-
### Heroku
|
44
36
|
|
45
|
-
|
37
|
+
### Upload configurated variables to Heroku
|
38
|
+
|
39
|
+
Add to `Rakefile`
|
46
40
|
|
47
41
|
require 'config_env/rake_tasks'
|
48
|
-
ConfigEnv.
|
42
|
+
ConfigEnv.path_to_config("#{__dir__}/config/config_env.rb")
|
49
43
|
|
50
|
-
|
44
|
+
Run rake command
|
51
45
|
|
52
46
|
rake config_env:heroku
|
53
47
|
|
54
|
-
Optionally, you can pass in the name of the Heroku app
|
48
|
+
Optionally, you can pass in the name of the Heroku app
|
55
49
|
|
56
50
|
rake config_env:heroku[app-name]
|
57
51
|
|
data/config_env.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.email = ['sergey@makridenkov.com']
|
11
11
|
spec.description = %q{Manage ENV[] variables, upload ENV to Heroku}
|
12
12
|
spec.summary = %q{ENV manager for any Ruby code}
|
13
|
-
spec.homepage = ''
|
13
|
+
spec.homepage = 'https://github.com/SergXIIIth/config_env'
|
14
14
|
spec.license = 'MIT'
|
15
15
|
|
16
16
|
spec.files = `git ls-files`.split($/)
|
@@ -18,8 +18,8 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ['lib']
|
20
20
|
|
21
|
-
spec.add_development_dependency 'bundler'
|
22
|
-
spec.add_development_dependency 'rake'
|
23
|
-
spec.add_development_dependency 'rspec'
|
24
|
-
spec.add_development_dependency 'rerun'
|
21
|
+
spec.add_development_dependency 'bundler', '~> 1.5'
|
22
|
+
spec.add_development_dependency 'rake', '~> 10.3'
|
23
|
+
spec.add_development_dependency 'rspec', '~> 2.14'
|
24
|
+
spec.add_development_dependency 'rerun', '~> 0.10'
|
25
25
|
end
|
data/lib/config_env/version.rb
CHANGED
data/lib/config_env.rb
CHANGED
@@ -2,8 +2,11 @@ require "config_env/version"
|
|
2
2
|
|
3
3
|
module ConfigEnv
|
4
4
|
# path to config_env file. Used in app Rakefile
|
5
|
-
def self.
|
5
|
+
def self.path_to_config(new_path)
|
6
6
|
@path = new_path
|
7
|
+
if File.exists?(path)
|
8
|
+
Kernel.load(path)
|
9
|
+
end
|
7
10
|
end
|
8
11
|
|
9
12
|
def self.path
|
@@ -38,7 +41,7 @@ module ConfigEnv
|
|
38
41
|
ENV['RACK_ENV'] || 'development'
|
39
42
|
end
|
40
43
|
|
41
|
-
|
44
|
+
private
|
42
45
|
|
43
46
|
attr_accessor :vars
|
44
47
|
|
@@ -7,35 +7,32 @@ describe ConfigEnv do
|
|
7
7
|
|
8
8
|
before { ConfigEnv.clear }
|
9
9
|
|
10
|
-
describe
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
describe '.path_to_config' do
|
11
|
+
let(:path){ double('path') }
|
12
|
+
subject(:path_to_config) { ConfigEnv.path_to_config(path) }
|
13
|
+
|
14
|
+
# on Heroku ENV set manually and config_env does not exist
|
15
|
+
context 'when config_env not exist' do
|
16
|
+
it 'do nothing' do
|
17
|
+
expect(Kernel).to_not receive(:load)
|
18
|
+
path_to_config
|
14
19
|
end
|
15
|
-
|
16
|
-
ENV['omniauth.twitter'].should == '111'
|
17
20
|
end
|
18
21
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
ENV['RACK_ENV'] = 'test'
|
23
|
-
|
24
|
-
config_env :test do
|
25
|
-
set 'omniauth.twitter', 'test'
|
22
|
+
context 'when config_env exist' do
|
23
|
+
before do
|
24
|
+
allow(File).to receive(:exists?).with(path){ true }
|
26
25
|
end
|
27
26
|
|
28
|
-
|
29
|
-
|
27
|
+
it 'load config_env' do
|
28
|
+
expect(Kernel).to receive(:load).with(path)
|
29
|
+
path_to_config
|
30
30
|
end
|
31
|
-
|
32
|
-
ENV['omniauth.twitter'].should == 'test'
|
33
|
-
|
34
|
-
ENV['RACK_ENV'] = old_rack_env
|
35
31
|
end
|
36
32
|
end
|
37
33
|
|
38
|
-
|
34
|
+
|
35
|
+
describe '.vars' do
|
39
36
|
it 'returns empty hash by default' do
|
40
37
|
ConfigEnv.vars.should == {}
|
41
38
|
end
|
@@ -68,4 +65,32 @@ describe ConfigEnv do
|
|
68
65
|
ConfigEnv.vars('production').should == {key2 => val2, key => val}
|
69
66
|
end
|
70
67
|
end
|
71
|
-
|
68
|
+
|
69
|
+
describe 'global shortcut config_env' do
|
70
|
+
it 'set ENV from code block' do
|
71
|
+
config_env do
|
72
|
+
set 'omniauth.twitter', 111
|
73
|
+
end
|
74
|
+
|
75
|
+
ENV['omniauth.twitter'].should == '111'
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'use RACK_ENV as env swither' do
|
79
|
+
old_rack_env = ENV['RACK_ENV']
|
80
|
+
|
81
|
+
ENV['RACK_ENV'] = 'test'
|
82
|
+
|
83
|
+
config_env :test do
|
84
|
+
set 'omniauth.twitter', 'test'
|
85
|
+
end
|
86
|
+
|
87
|
+
config_env :production, :development do
|
88
|
+
set 'omniauth.twitter', 'live'
|
89
|
+
end
|
90
|
+
|
91
|
+
ENV['omniauth.twitter'].should == 'test'
|
92
|
+
|
93
|
+
ENV['RACK_ENV'] = old_rack_env
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
metadata
CHANGED
@@ -1,71 +1,71 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: config_env
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
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: 2014-05-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '1.5'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '1.5'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '10.3'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '10.3'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '2.14'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '2.14'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rerun
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
61
|
+
version: '0.10'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
68
|
+
version: '0.10'
|
69
69
|
description: Manage ENV[] variables, upload ENV to Heroku
|
70
70
|
email:
|
71
71
|
- sergey@makridenkov.com
|
@@ -73,9 +73,9 @@ executables: []
|
|
73
73
|
extensions: []
|
74
74
|
extra_rdoc_files: []
|
75
75
|
files:
|
76
|
-
- .gitignore
|
77
|
-
- .ruby-gemset
|
78
|
-
- .ruby-version
|
76
|
+
- ".gitignore"
|
77
|
+
- ".ruby-gemset"
|
78
|
+
- ".ruby-version"
|
79
79
|
- Gemfile
|
80
80
|
- LICENSE.txt
|
81
81
|
- README.md
|
@@ -84,11 +84,11 @@ files:
|
|
84
84
|
- lib/config_env.rb
|
85
85
|
- lib/config_env/rake_tasks.rb
|
86
86
|
- lib/config_env/version.rb
|
87
|
-
- spec/config_env/rake_tasts_spec.rb
|
88
|
-
- spec/config_env_spec.rb
|
87
|
+
- spec/lib/config_env/rake_tasts_spec.rb
|
88
|
+
- spec/lib/config_env_spec.rb
|
89
89
|
- spec/spec_helper.rb
|
90
90
|
- spec/support/rnd_helpers.rb
|
91
|
-
homepage:
|
91
|
+
homepage: https://github.com/SergXIIIth/config_env
|
92
92
|
licenses:
|
93
93
|
- MIT
|
94
94
|
metadata: {}
|
@@ -98,22 +98,22 @@ require_paths:
|
|
98
98
|
- lib
|
99
99
|
required_ruby_version: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- -
|
101
|
+
- - ">="
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: '0'
|
104
104
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
105
105
|
requirements:
|
106
|
-
- -
|
106
|
+
- - ">="
|
107
107
|
- !ruby/object:Gem::Version
|
108
108
|
version: '0'
|
109
109
|
requirements: []
|
110
110
|
rubyforge_project:
|
111
|
-
rubygems_version: 2.
|
111
|
+
rubygems_version: 2.2.2
|
112
112
|
signing_key:
|
113
113
|
specification_version: 4
|
114
114
|
summary: ENV manager for any Ruby code
|
115
115
|
test_files:
|
116
|
-
- spec/config_env/rake_tasts_spec.rb
|
117
|
-
- spec/config_env_spec.rb
|
116
|
+
- spec/lib/config_env/rake_tasts_spec.rb
|
117
|
+
- spec/lib/config_env_spec.rb
|
118
118
|
- spec/spec_helper.rb
|
119
119
|
- spec/support/rnd_helpers.rb
|