diff options
author | Paul Lathrop <paul@tertiusfamily.net> | 2008-02-05 15:07:05 -0800 |
---|---|---|
committer | Paul Lathrop <paul@tertiusfamily.net> | 2008-02-05 15:07:05 -0800 |
commit | b3f67ec4017940a7eb47f3a044fd77c8d32a74cf (patch) | |
tree | f7648cadbbca1d799f773628fc049ad054bae178 | |
parent | aedd59cb2427c8642b817587b0c5ad1319161daa (diff) | |
download | puppet-b3f67ec4017940a7eb47f3a044fd77c8d32a74cf.tar.gz puppet-b3f67ec4017940a7eb47f3a044fd77c8d32a74cf.tar.xz puppet-b3f67ec4017940a7eb47f3a044fd77c8d32a74cf.zip |
Fix ticket 974. My original "fix" wasn't. This actually fixes the problem by using a regular expression that matches only up to the first square bracket.
-rw-r--r-- | lib/puppet/resource_reference.rb | 4 | ||||
-rwxr-xr-x | spec/unit/resource_reference.rb | 6 |
2 files changed, 8 insertions, 2 deletions
diff --git a/lib/puppet/resource_reference.rb b/lib/puppet/resource_reference.rb index d5fc90d1f..771a91be7 100644 --- a/lib/puppet/resource_reference.rb +++ b/lib/puppet/resource_reference.rb @@ -36,8 +36,8 @@ class Puppet::ResourceReference # If the title has square brackets, treat it like a reference and # set things appropriately; else, just set it. def title=(value) - if value =~ /^(.+)\[(.+)\]$/ - @type = $1 + if value =~ /^([^\[\]]+)\[(.+)\]$/ + self.type = $1 @title = $2 else @title = value diff --git a/spec/unit/resource_reference.rb b/spec/unit/resource_reference.rb index ef172d80a..cbbd6ef51 100755 --- a/spec/unit/resource_reference.rb +++ b/spec/unit/resource_reference.rb @@ -40,6 +40,12 @@ describe Puppet::ResourceReference do ref.type.should == "Foo::Bar" ref.title.should == "yay" end + + it "should interpret the title as a reference and assign appropriately if the type is nil and the title contains nested square brackets" do + ref = Puppet::ResourceReference.new(nil, "foo::bar[baz[yay]]") + ref.type.should == "Foo::Bar" + ref.title.should =="baz[yay]" + end end describe Puppet::ResourceReference, "when resolving resources without a catalog" do |