soloist 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/soloist/config.rb +4 -4
- data/lib/soloist/royal_crown.rb +24 -1
- data/lib/soloist/version.rb +1 -1
- data/soloist.gemspec +2 -0
- data/spec/lib/soloist/config_spec.rb +15 -2
- metadata +4 -3
data/lib/soloist/config.rb
CHANGED
@@ -74,11 +74,11 @@ module Soloist
|
|
74
74
|
end
|
75
75
|
|
76
76
|
def compiled
|
77
|
-
@compiled ||= royal_crown.dup.tap do |
|
78
|
-
while
|
79
|
-
|
77
|
+
@compiled ||= royal_crown.dup.tap do |working_royal_crown|
|
78
|
+
while working_royal_crown["env_variable_switches"]
|
79
|
+
working_royal_crown.delete("env_variable_switches").each do |variable, switch|
|
80
80
|
switch.each do |value, inner|
|
81
|
-
|
81
|
+
working_royal_crown.merge!(inner) if ENV[variable] == value
|
82
82
|
end
|
83
83
|
end
|
84
84
|
end
|
data/lib/soloist/royal_crown.rb
CHANGED
@@ -14,8 +14,25 @@ module Soloist
|
|
14
14
|
self["node_attributes"] = Hashie::Mash.new(hash)
|
15
15
|
end
|
16
16
|
|
17
|
+
def merge!(other_royal_crown)
|
18
|
+
merge_recipes(other_royal_crown["recipes"])
|
19
|
+
merge_cookbook_paths(other_royal_crown["cookbook_paths"])
|
20
|
+
self.node_attributes.deep_merge!(other_royal_crown["node_attributes"])
|
21
|
+
self.env_variable_switches = other_royal_crown["env_variable_switches"]
|
22
|
+
self
|
23
|
+
end
|
24
|
+
|
25
|
+
def merge_recipes(new_recipes = [])
|
26
|
+
merge_array_property("recipes", new_recipes)
|
27
|
+
end
|
28
|
+
|
29
|
+
def merge_cookbook_paths(new_cookbook_paths = [])
|
30
|
+
merge_array_property("cookbook_paths", new_cookbook_paths)
|
31
|
+
end
|
32
|
+
|
17
33
|
def env_variable_switches=(hash)
|
18
|
-
self["env_variable_switches"]
|
34
|
+
self["env_variable_switches"] ||= Hashie::Mash.new
|
35
|
+
self["env_variable_switches"].merge!(Hashie::Mash.new(hash))
|
19
36
|
end
|
20
37
|
|
21
38
|
def to_yaml
|
@@ -52,5 +69,11 @@ module Soloist
|
|
52
69
|
def self.nilable_properties
|
53
70
|
(properties - [:path]).map(&:to_s)
|
54
71
|
end
|
72
|
+
|
73
|
+
def merge_array_property(property_name, values)
|
74
|
+
self[property_name] ||= []
|
75
|
+
self[property_name] += values
|
76
|
+
self[property_name].uniq!
|
77
|
+
end
|
55
78
|
end
|
56
79
|
end
|
data/lib/soloist/version.rb
CHANGED
data/soloist.gemspec
CHANGED
@@ -109,6 +109,10 @@ describe Soloist::Config do
|
|
109
109
|
"TONGUES" => {
|
110
110
|
"FINE" => {
|
111
111
|
"recipes" => ["hobo_fist"],
|
112
|
+
"cookbook_paths" => ["shell_in"],
|
113
|
+
"node_attributes" => {
|
114
|
+
"doc" => "absent"
|
115
|
+
},
|
112
116
|
"env_variable_switches" => nested
|
113
117
|
}
|
114
118
|
}
|
@@ -132,6 +136,10 @@ describe Soloist::Config do
|
|
132
136
|
config.compiled.recipes.should =~ ["hobo_fist"]
|
133
137
|
end
|
134
138
|
|
139
|
+
it "merges the node attributes" do
|
140
|
+
config.compiled.node_attributes.should == {"doc" => "absent"}
|
141
|
+
end
|
142
|
+
|
135
143
|
context "when an inactive switch is nested" do
|
136
144
|
let(:nested) { {"BEANS" => {"EW" => {"recipes" => ["slammin"]}}} }
|
137
145
|
|
@@ -141,10 +149,15 @@ describe Soloist::Config do
|
|
141
149
|
end
|
142
150
|
|
143
151
|
context "when an active switch is nested" do
|
144
|
-
let(:nested) { {"BEANS" => {"FINE" => {"recipes" => ["slammin"]}}} }
|
152
|
+
let(:nested) { {"BEANS" => {"FINE" => {"cookbook_paths" => ["shell_out"], "recipes" => ["slammin"], "node_attributes" => {"kocher" => "present"}}}} }
|
145
153
|
|
146
154
|
it "merges the attributes" do
|
147
|
-
config.compiled.recipes.should =~ ["slammin"]
|
155
|
+
config.compiled.recipes.should =~ ["slammin", "hobo_fist"]
|
156
|
+
config.compiled.cookbook_paths.should =~ ["shell_in", "shell_out"]
|
157
|
+
end
|
158
|
+
|
159
|
+
it "merges the node attributes" do
|
160
|
+
config.compiled.node_attributes.should == {"doc" => "absent", "kocher" => "present"}
|
148
161
|
end
|
149
162
|
end
|
150
163
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: soloist
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-11-
|
13
|
+
date: 2013-11-15 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: chef
|
@@ -263,7 +263,8 @@ files:
|
|
263
263
|
- spec/lib/soloist/spotlight_spec.rb
|
264
264
|
- spec/spec_helper.rb
|
265
265
|
homepage: http://github.com/mkocher/soloist
|
266
|
-
licenses:
|
266
|
+
licenses:
|
267
|
+
- MIT
|
267
268
|
post_install_message:
|
268
269
|
rdoc_options: []
|
269
270
|
require_paths:
|