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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d9767a6ba806006a66c7539931f5b7898ae8b8a1
4
- data.tar.gz: 2988dcd695c7d0b580a01a345205322afc2c6953
3
+ metadata.gz: ef1573f36c0335e6447a11bc7727ab2476b79084
4
+ data.tar.gz: 4333a92141a27773f65a8b220d62dbcabc590f67
5
5
  SHA512:
6
- metadata.gz: 42898bb84560900b9a51e606ca449fca5882bae46904cc2d7e9bb1a432e4f451000f09606bebe917fa3627d2dc27e9e9d9d68064991e9f3b295b0c8b0d50a03e
7
- data.tar.gz: f13c8f98f84a314c30f16850a8094d27b32b865e361cf3f6e1dbc44464468c2a9068e4dad3abd5a5de5d98088e4dfb6d13fa8dc8c3fe343c3f041a68ec24f4f8
6
+ metadata.gz: a8ccb2f23be8ba979276f1efc4406c3188a98b843dd977ce477ced0b9d7c5458f6012925bf146af705f4c1b4a43044a79657af90ed51fa3748359e70a176358a
7
+ data.tar.gz: 130661404a0c633644cbbadc07e914e5590e4925399e9843a625e7c429e792da918b8fb03cde5bc9a9171f6de9d872fc76ba405b58da4366ad3ef8e721ae99a5
data/README.md CHANGED
@@ -1,4 +1,9 @@
1
- # ConfigEnv - config your `ENV['variables']`
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/config_env.rb`:
23
+ Create file `config/env.rb`:
17
24
 
18
- # any ENV['RACK_ENV']
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
- config_env.rb
45
+ config/env.rb
35
46
 
36
47
 
37
48
  ### Upload configurated variables to Heroku
@@ -1,3 +1,3 @@
1
1
  module ConfigEnv
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
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
- ConfigEnv.set_vars(command.vars, envs)
84
- ConfigEnv.setup_env(command.vars, envs)
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
- key = "key_#{rnd}"
18
- val = "val_#{rnd}"
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
@@ -2,8 +2,8 @@ require 'spec_helper'
2
2
  require 'ostruct'
3
3
 
4
4
  describe ConfigEnv do
5
- let(:key){ "key_#{rnd}" }
6
- let(:val){ "val_#{rnd}" }
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_#{rnd}"
55
- val2 = "val2_#{rnd}"
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
@@ -7,7 +7,5 @@ Dir["#{__dir__}/support/**/*.rb"].each{ |path| require path }
7
7
  RSpec.configure do |config|
8
8
  config.filter_run focus: true
9
9
  config.run_all_when_everything_filtered = true
10
-
11
- config.include RndHelpers
12
10
  end
13
11
 
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.0
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: 2014-05-17 00:00:00.000000000 Z
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.2.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
@@ -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