itamae-node_env 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/itamae-node_env.gemspec +1 -1
- data/lib/itamae/node_env.rb +42 -15
- data/lib/itamae/node_env/version.rb +1 -1
- metadata +10 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5cc60de2a77f52cf7151ca7718a6c39227738812
|
4
|
+
data.tar.gz: b4fb51ca20a78494d942bb36532912eaa1179618
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 90ef9be9f16f9f8de64dab976ec91d6f30c0d140f42ef3c0a5460a457e28d47c8da5392afae9fee9fc03397a0fdad0297cbbcee8a64926245dd84c9cf669dae7
|
7
|
+
data.tar.gz: 77b4d655522566e47d89f6690252262fd00acf7759853ef91c98e01be117f5ec8948dcf580d31003d25fe0f6e5d652f78d27fb217047d957f34c3454a58f8dbf
|
data/itamae-node_env.gemspec
CHANGED
@@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
|
|
17
17
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
18
|
spec.require_paths = ["lib"]
|
19
19
|
|
20
|
-
spec.add_dependency "itamae",
|
20
|
+
spec.add_dependency "itamae", '>= 1.1.1', '< 1.3.0'
|
21
21
|
|
22
22
|
spec.add_development_dependency "bundler", "~> 1.7"
|
23
23
|
spec.add_development_dependency "rake", "~> 10.0"
|
data/lib/itamae/node_env.rb
CHANGED
@@ -3,30 +3,57 @@ require "itamae/node_env/version"
|
|
3
3
|
|
4
4
|
module Itamae
|
5
5
|
module NodeEnv
|
6
|
-
|
6
|
+
private
|
7
|
+
|
8
|
+
def apply_env(val, klass = nil)
|
9
|
+
klass ||= self.class
|
10
|
+
|
7
11
|
case val
|
8
|
-
when String
|
9
|
-
if /\Aenv\[([^\]]+)\]\z/ =~ val
|
10
|
-
|
12
|
+
when String
|
13
|
+
if /\Aenv\[(?<key>[^\]]+)\]\z/ =~ val
|
14
|
+
ENV[key]
|
15
|
+
else
|
16
|
+
val
|
11
17
|
end
|
12
|
-
when Array
|
13
|
-
|
14
|
-
when
|
15
|
-
|
16
|
-
val
|
17
|
-
|
18
|
+
when Array
|
19
|
+
val.map { |v| apply_env(v, klass) }
|
20
|
+
when klass
|
21
|
+
val.each { |k, v| val[k] = apply_env(v, klass) }
|
22
|
+
val
|
23
|
+
else
|
24
|
+
val
|
18
25
|
end
|
19
|
-
return val
|
20
26
|
end
|
27
|
+
end
|
28
|
+
|
29
|
+
module NodeEnv11
|
30
|
+
include NodeEnv
|
21
31
|
|
22
32
|
def initialize(source_hash = nil, default = nil, &blk)
|
23
|
-
|
24
|
-
|
33
|
+
super
|
34
|
+
self.each do |key, val|
|
35
|
+
self[key] = apply_env(val)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
module NodeEnv12
|
41
|
+
include NodeEnv
|
42
|
+
|
43
|
+
def initialize(initial_hash, backend)
|
44
|
+
super
|
45
|
+
@mash = apply_env(@mash, Hashie::Mash)
|
25
46
|
end
|
26
47
|
end
|
27
48
|
end
|
28
49
|
|
29
|
-
::Itamae::
|
50
|
+
major, minor, revision = ::Itamae::VERSION.split(".").map(&:to_i)
|
30
51
|
|
31
|
-
|
52
|
+
case minor.to_i
|
53
|
+
when 1
|
54
|
+
::Itamae::Node.send(:prepend, ::Itamae::NodeEnv11)
|
55
|
+
when 2
|
56
|
+
::Itamae::Node.send(:prepend, ::Itamae::NodeEnv12)
|
57
|
+
end
|
32
58
|
|
59
|
+
Dotenv.load if Object.const_defined?(:Dotenv)
|
metadata
CHANGED
@@ -1,29 +1,35 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: itamae-node_env
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- nownabe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-04-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: itamae
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 1.1.1
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 1.3.0
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
|
-
- - "
|
27
|
+
- - ">="
|
25
28
|
- !ruby/object:Gem::Version
|
26
29
|
version: 1.1.1
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 1.3.0
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: bundler
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|