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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 32f262a5b50b2917c267347f115164a015f8ab90
4
- data.tar.gz: 3176500e2eaf820e855256173727063531f0493f
3
+ metadata.gz: 5cc60de2a77f52cf7151ca7718a6c39227738812
4
+ data.tar.gz: b4fb51ca20a78494d942bb36532912eaa1179618
5
5
  SHA512:
6
- metadata.gz: 5dcb2bb6c76f0d5f64e01136e7f9fbafe7adb9df73ce7d258b51c7c1edfbac53841901a64ca343ea27c89e4c645e0049d414043bde12e313feed28d13a813acd
7
- data.tar.gz: 0c36d26a6aa4cf1b630edead68021db0fd8d69071a3c650cef110cb8a78874d7473e2f0d063ffc35868866ea4ef0b245f92e21b502bdd08a85b1f631eb4036a8
6
+ metadata.gz: 90ef9be9f16f9f8de64dab976ec91d6f30c0d140f42ef3c0a5460a457e28d47c8da5392afae9fee9fc03397a0fdad0297cbbcee8a64926245dd84c9cf669dae7
7
+ data.tar.gz: 77b4d655522566e47d89f6690252262fd00acf7759853ef91c98e01be117f5ec8948dcf580d31003d25fe0f6e5d652f78d27fb217047d957f34c3454a58f8dbf
@@ -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", "~> 1.1.1"
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"
@@ -3,30 +3,57 @@ require "itamae/node_env/version"
3
3
 
4
4
  module Itamae
5
5
  module NodeEnv
6
- def convert_env(val)
6
+ private
7
+
8
+ def apply_env(val, klass = nil)
9
+ klass ||= self.class
10
+
7
11
  case val
8
- when String then
9
- if /\Aenv\[([^\]]+)\]\z/ =~ val
10
- return ENV[$1]
12
+ when String
13
+ if /\Aenv\[(?<key>[^\]]+)\]\z/ =~ val
14
+ ENV[key]
15
+ else
16
+ val
11
17
  end
12
- when Array then
13
- return val.map {|v| convert_env(v)}
14
- when Hash then
15
- hash = Hash.new
16
- val.each {|k,v| hash[k] = convert_env(v)}
17
- return hash
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
- source_hash = convert_env(source_hash)
24
- super(source_hash, default, &blk)
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::Node.send(:prepend, ::Itamae::NodeEnv)
50
+ major, minor, revision = ::Itamae::VERSION.split(".").map(&:to_i)
30
51
 
31
- Dotenv.load if Object.const_defined?(:Dotenv)
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)
@@ -1,5 +1,5 @@
1
1
  module Itamae
2
2
  module NodeEnv
3
- VERSION = "0.0.4"
3
+ VERSION = "0.0.5"
4
4
  end
5
5
  end
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
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: 2014-12-29 00:00:00.000000000 Z
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