chef_cap 0.2.8 → 0.2.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,3 @@
1
1
  module ChefCap
2
- VERSION = "0.2.8"
2
+ VERSION = "0.2.9"
3
3
  end
@@ -12,12 +12,13 @@ class ChefCapHelper
12
12
  end
13
13
  next if key == :ssh_options # skip restricted variables
14
14
 
15
- unless value.nil?
16
- debug("Setting #{key.inspect} => #{value.inspect}")
17
- ChefCapConfiguration.configuration.set key, value
18
- else
15
+ override_value = ENV[key.to_s]
16
+ if value.nil? || override_value == "null"
19
17
  debug("Unsetting #{key.inspect} => #{value.inspect}")
20
18
  ChefCapConfiguration.configuration.unset key
19
+ else
20
+ debug("Setting #{key.inspect} => #{value.inspect}")
21
+ ChefCapConfiguration.configuration.set key, (override_value || value)
21
22
  end
22
23
  end
23
24
  end
@@ -45,6 +45,25 @@ describe ChefCapHelper do
45
45
  end
46
46
  end
47
47
 
48
+ context "given an environment variable matching the key name" do
49
+ before { ENV["gateway"] = "mygateway" }
50
+ after { ENV["gateway"] = nil }
51
+
52
+ it "should overwrite the value with the environment variable" do
53
+ @configuration.should_receive(:set).with(:gateway, "mygateway")
54
+ ChefCapHelper.parse_hash({"gateway" => "yourgateway"})
55
+ end
56
+ end
57
+
58
+ context "given an environment variable matching the key name" do
59
+ before { ENV["gateway"] = "null" }
60
+ after { ENV["gateway"] = nil }
61
+
62
+ it "should overwrite the value with the environment variable" do
63
+ @configuration.should_receive(:unset).with(:gateway)
64
+ ChefCapHelper.parse_hash({"gateway" => "yourgateway"})
65
+ end
66
+ end
48
67
  it "should unset null values" do
49
68
  @configuration.should_receive(:unset).with(:somekey)
50
69
  @configuration.should_not_receive(:set)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chef_cap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.8
4
+ version: 0.2.9
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-12-07 00:00:00.000000000Z
12
+ date: 2011-12-09 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: capistrano
16
- requirement: &2165477760 !ruby/object:Gem::Requirement
16
+ requirement: &2157483920 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 2.5.5
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2165477760
24
+ version_requirements: *2157483920
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rspec-rails
27
- requirement: &2165476780 !ruby/object:Gem::Requirement
27
+ requirement: &2157482840 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,7 +32,7 @@ dependencies:
32
32
  version: '2.1'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *2165476780
35
+ version_requirements: *2157482840
36
36
  description: chef_cap uses chef"s JSON config format to drive both capistrano and
37
37
  chef-solo"
38
38
  email:
@@ -91,7 +91,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
91
91
  version: '0'
92
92
  segments:
93
93
  - 0
94
- hash: 1089902353298414569
94
+ hash: -2444766936816973139
95
95
  required_rubygems_version: !ruby/object:Gem::Requirement
96
96
  none: false
97
97
  requirements:
@@ -100,7 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
100
100
  version: '0'
101
101
  segments:
102
102
  - 0
103
- hash: 1089902353298414569
103
+ hash: -2444766936816973139
104
104
  requirements: []
105
105
  rubyforge_project:
106
106
  rubygems_version: 1.8.12