capistrano-env 0.0.7 → 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/.travis.yml +1 -0
- data/README.md +3 -0
- data/lib/capistrano/env/config.rb +8 -4
- data/lib/capistrano/env/version.rb +1 -1
- data/spec/capistrano/env/config_spec.rb +9 -0
- 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: eca7b988424503f05ab3e67e4dfe6a9b9bf18bf0
|
4
|
+
data.tar.gz: 3c5cecb6d77d1c5e51914892964a1bee6165946e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f71e31fce1fa9e316d74dc3839520e20679b811c0beb75432f7a1299c1d4c02a44903f2ecb47f5487c0a1170b05db29fbee70d1509c1bfcec367fb674114423c
|
7
|
+
data.tar.gz: 79da44e5a2556f819b49759584bf9586ecc6e18034c4fc780b9d16b1771f2b557522b047c3b0291f84beb26e442067b48aa6b1be4e7e716f0ffe892fc2e3be00
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -24,6 +24,9 @@ Or install it yourself as:
|
|
24
24
|
```ruby
|
25
25
|
capenv.use do |env|
|
26
26
|
env.add /^MYAPP_/
|
27
|
+
env.add /^MYAPP_/ do |key|
|
28
|
+
key.gsub /^MYAPP_/, '' # replace keyname like MYAPP_DATABASE_URL => DATABASE_URL
|
29
|
+
end
|
27
30
|
env.add 'UNICORN_PROCESSES'
|
28
31
|
env.add 'HOGE', 'hage'
|
29
32
|
end
|
@@ -9,11 +9,11 @@ module Capistrano
|
|
9
9
|
@keys = []
|
10
10
|
end
|
11
11
|
|
12
|
-
def add(name_or_regexp, val = nil)
|
12
|
+
def add(name_or_regexp, val = nil, &block)
|
13
13
|
if val && name_or_regexp.is_a?(String)
|
14
14
|
@values[name_or_regexp] = val
|
15
15
|
else
|
16
|
-
@keys << name_or_regexp
|
16
|
+
@keys << [name_or_regexp, block]
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
@@ -26,13 +26,17 @@ module Capistrano
|
|
26
26
|
|
27
27
|
def envs
|
28
28
|
result = {}
|
29
|
-
@keys.each do |key|
|
29
|
+
@keys.each do |key, block|
|
30
30
|
key_values = if key.is_a? Regexp
|
31
31
|
ENV.select{|x| x =~ key }
|
32
32
|
else
|
33
33
|
ENV.select{|x| x == key }
|
34
34
|
end
|
35
|
-
|
35
|
+
if block
|
36
|
+
key_values = Hash[key_values.map do |k, v|
|
37
|
+
[block.call(k), v]
|
38
|
+
end]
|
39
|
+
end
|
36
40
|
result.merge!(key_values)
|
37
41
|
end
|
38
42
|
result.merge(@values)
|
@@ -50,5 +50,14 @@ describe Capistrano::Env::Config do
|
|
50
50
|
end
|
51
51
|
it { expect(config.envs).to eq({"CAPENV_TEST_A" => "a", "CAPENV_TEST_B" => "UNKO"}) }
|
52
52
|
end
|
53
|
+
describe "fix key with block" do
|
54
|
+
before do
|
55
|
+
config.add /^CAPENV_TEST_/
|
56
|
+
config.add /^CAPENV_TEST_/ do |key|
|
57
|
+
key.gsub(/CAPENV_/, '')
|
58
|
+
end
|
59
|
+
end
|
60
|
+
it { expect(config.envs).to eq({"CAPENV_TEST_A" => "a", "CAPENV_TEST_B" => "1,2,3", "TEST_A" => "a", "TEST_B" => "1,2,3"}) }
|
61
|
+
end
|
53
62
|
end
|
54
63
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano-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
|
- masarakki
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-07-
|
11
|
+
date: 2014-07-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|