We're converting the regex to a straight name to be used as the node class name which later on will be used as tag. It was possible to generate an invalid tag name (containing leading or successive dots).
Signed-off-by: Brice Figureau <brice-pup...@daysofwonder.com> --- lib/puppet/parser/ast/leaf.rb | 2 +- spec/unit/parser/ast/leaf.rb | 5 +++++ 2 files changed, 6 insertions(+), 1 deletions(-) diff --git a/lib/puppet/parser/ast/leaf.rb b/lib/puppet/parser/ast/leaf.rb index d10ea62..1f96d9b 100644 --- a/lib/puppet/parser/ast/leaf.rb +++ b/lib/puppet/parser/ast/leaf.rb @@ -103,7 +103,7 @@ class Puppet::Parser::AST def to_classname classname = @value.to_s.downcase - classname.gsub!(/[^-a-zA-Z0-9:.]/,'') if regex? + classname.gsub!(/[^-a-zA-Z0-9:.]/,'').gsub!(/^\.+/,'') if regex? classname end diff --git a/spec/unit/parser/ast/leaf.rb b/spec/unit/parser/ast/leaf.rb index 6215f63..69b704a 100755 --- a/spec/unit/parser/ast/leaf.rb +++ b/spec/unit/parser/ast/leaf.rb @@ -200,6 +200,11 @@ describe Puppet::Parser::AST::HostName do host.to_classname.should == "this-isnotaclassname" end + it "should return a string usable as a tag when calling to_classname" do + host = Puppet::Parser::AST::HostName.new( :value => Puppet::Parser::AST::Regex.new(:value => "/.+.reductivelabs\.com/") ) + host.to_classname.should == "reductivelabs.com" + end + it "should delegate 'match' to the underlying value if it is an HostName" do @value.expects(:match).with("value") @host.match("value") -- 1.6.4 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Puppet Developers" group. To post to this group, send email to puppet-dev@googlegroups.com To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en -~----------~----~----~----~------~----~------~--~---