rubber 2.1.1 → 2.1.2

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.
data/CHANGELOG CHANGED
@@ -1,3 +1,12 @@
1
+ 2.1.2 (10/05/2012)
2
+ ------------------
3
+
4
+ New Features:
5
+ ============
6
+
7
+ [core] Allowing marking of a config variable as overriding the ones that come before it, so that non-scalar values (lists/maps) get overridden instead of combined <3d66fc8>
8
+ [core] Allow erb in rubber*.yml <60e6394>
9
+
1
10
  2.1.1 (10/02/2012)
2
11
  ------------------
3
12
 
@@ -17,7 +26,6 @@ Improvements:
17
26
  [jenkins] Added support for backing up Jenkins. <a44162d>
18
27
  [jenkins] Fixed Jenkins config. <bbaa6f4>
19
28
  [jenkins] Make sure we have the header module enabled for the config to work. <93d03d8>
20
- [jenkins] The module is "headers", not "header". <4057334>
21
29
  [passenger] Bumped rubber from 3.0.12 to 3.0.15. <bc408f1>
22
30
  [passenger_nginx] Updated Nginx config to improve performance of asset pipeline. <7184327>
23
31
  [torquebox] Updated TorqueBox config from 2.0.3 to 2.1.0. <13a0268>
@@ -36,7 +36,7 @@ module Rubber
36
36
  Rubber.logger.debug{"Reading rubber configuration from #{file}"}
37
37
  if File.exist?(file)
38
38
  begin
39
- @items = Environment.combine(@items, YAML.load_file(file) || {})
39
+ @items = Environment.combine(@items, YAML::load(ERB.new(IO.read(file)).result) || {})
40
40
  rescue Exception => e
41
41
  Rubber.logger.error{"Unable to read rubber configuration from #{file}"}
42
42
  raise
@@ -56,7 +56,7 @@ module Rubber
56
56
 
57
57
  # all the roles known about in yml files
58
58
  Dir["#{@config_root}/rubber*.yml"].each do |yml|
59
- rubber_yml = YAML.load(File.read(yml)) rescue {}
59
+ rubber_yml = YAML::load(ERB.new(IO.read(yml)).result) rescue {}
60
60
  roles.concat(rubber_yml['roles'].keys) rescue nil
61
61
  roles.concat(rubber_yml['role_dependencies'].keys) rescue nil
62
62
  roles.concat(rubber_yml['role_dependencies'].values) rescue nil
@@ -89,7 +89,12 @@ module Rubber
89
89
  if old.is_a?(Hash) && new.is_a?(Hash)
90
90
  value = old.clone
91
91
  new.each do |nk, nv|
92
- value[nk] = combine(value[nk], nv)
92
+ if nk[0] == '^'
93
+ nk = nk[1..-1]
94
+ value[nk] = combine(nil, nv)
95
+ else
96
+ value[nk] = combine(value[nk], nv)
97
+ end
93
98
  end
94
99
  elsif old.is_a?(Array) && new.is_a?(Array)
95
100
  value = old | new
@@ -1,3 +1,3 @@
1
1
  module Rubber
2
- VERSION = "2.1.1"
2
+ VERSION = "2.1.2"
3
3
  end
@@ -298,7 +298,7 @@ stop_on_error_cmd: "function error_exit { exit 99; }; trap error_exit ERR"
298
298
 
299
299
  # OPTIONAL: You can also define your own variables here for use when
300
300
  # transforming config files, and they will be available in your config
301
- # templates as <%= rubber_env.var_name %>
301
+ # templates as <%%= rubber_env.var_name %>
302
302
  #
303
303
  # var_name: var_value
304
304
 
@@ -75,6 +75,13 @@ class EnvironmentTest < Test::Unit::TestCase
75
75
  assert_equal({1 => {1 => "1", 2 => "2"}}, env.combine({1 => {1 => "1"}}, {1 => {2 => "2"}}), "Maps should be unioned recursively when combined")
76
76
  end
77
77
 
78
+ def test_combine_override
79
+ env = Rubber::Configuration::Environment
80
+ assert_equal({"x" => 4, "y" => 2, "z" => 3}, env.combine({"x" => 1, "y" => 2}, {"^x" => 4, "z" => 3}), "scalars should override")
81
+ assert_equal({"x" => [3, 4]}, env.combine({"x" => [1, 2]}, {"^x" => [3, 4]}), "lists should override")
82
+ assert_equal({"x" => {"y" => [3, 4]}}, env.combine({"x" => {"y" => [1, 2]}}, {"x" => {"^y" => [3, 4]}}), "Maps should override recursively")
83
+ end
84
+
78
85
  def test_expansion
79
86
  env = Rubber::Configuration::Environment.new("#{File.dirname(__FILE__)}/fixtures/expansion", 'test')
80
87
  e = env.bind()
@@ -152,4 +159,10 @@ class EnvironmentTest < Test::Unit::TestCase
152
159
  assert_equal "50.1.1.1", e['var1']
153
160
  end
154
161
 
162
+ def test_erb_yml
163
+ env = Rubber::Configuration::Environment.new("#{File.dirname(__FILE__)}/fixtures/basic", 'test')
164
+ e = env.bind()
165
+ assert_equal [0, 1, 2], e["erb_var"], 'should be able to generate env using erb'
166
+ end
167
+
155
168
  end
@@ -28,4 +28,8 @@ environments:
28
28
 
29
29
  role_dependencies:
30
30
  role3: [role4, role5]
31
-
31
+
32
+ erb_var:
33
+ <% 3.times do |i| %>
34
+ - <%= i %>
35
+ <% end %>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubber
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.1
4
+ version: 2.1.2
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: 2012-10-02 00:00:00.000000000 Z
13
+ date: 2012-10-05 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: capistrano
@@ -664,7 +664,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
664
664
  version: '0'
665
665
  segments:
666
666
  - 0
667
- hash: 3394204759182119607
667
+ hash: -1263821507028843624
668
668
  required_rubygems_version: !ruby/object:Gem::Requirement
669
669
  none: false
670
670
  requirements:
@@ -673,7 +673,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
673
673
  version: '0'
674
674
  segments:
675
675
  - 0
676
- hash: 3394204759182119607
676
+ hash: -1263821507028843624
677
677
  requirements: []
678
678
  rubyforge_project: rubber
679
679
  rubygems_version: 1.8.24