Please review pull request #367: (#9443) Allow digits in face names opened by (fpletz)

Description:

This patch allows digits to be used in face names. The first character,
however, is not allowed to be a digit. This fixes #9443.

  • Opened: Sat Jan 21 19:00:26 UTC 2012
  • Based on: puppetlabs:master (ed73922ed27fc2a87df344a7fc66cd4d2059d82c)
  • Requested merge: fpletz:fix-9443 (8f4d0eb85cfd8156da19a8abe33e87d8e9c45943)

Diff follows:

diff --git a/lib/puppet/interface/face_collection.rb b/lib/puppet/interface/face_collection.rb
index b1f6ba3..d2e3dbe 100644
--- a/lib/puppet/interface/face_collection.rb
+++ b/lib/puppet/interface/face_collection.rb
@@ -119,7 +119,7 @@ def self.register(face)
   end
 
   def self.underscorize(name)
-    unless name.to_s =~ /^[-_a-z]+$/i then
+    unless name.to_s =~ /^[-_a-z][-_a-z0-9]*$/i then
       raise ArgumentError, "#{name.inspect} (#{name.class}) is not a valid face name"
     end
 
diff --git a/spec/unit/interface/face_collection_spec.rb b/spec/unit/interface/face_collection_spec.rb
index 514a624..3df64bd 100755
--- a/spec/unit/interface/face_collection_spec.rb
+++ b/spec/unit/interface/face_collection_spec.rb
@@ -146,14 +146,16 @@
   end
 
   describe "::underscorize" do
-    faulty = [1, "#foo", "$bar", "sturm und drang", :"sturm und drang"]
+    faulty = [1, "23foo", "#foo", "$bar", "sturm und drang", :"sturm und drang"]
     valid  = {
-      "Foo"      => :foo,
-      :Foo       => :foo,
-      "foo_bar"  => :foo_bar,
-      :foo_bar   => :foo_bar,
-      "foo-bar"  => :foo_bar,
-      :"foo-bar" => :foo_bar,
+      "Foo"       => :foo,
+      :Foo        => :foo,
+      "foo_bar"   => :foo_bar,
+      :foo_bar    => :foo_bar,
+      "foo-bar"   => :foo_bar,
+      :"foo-bar"  => :foo_bar,
+      "foo_bar23" => :foo_bar23,
+      :foo_bar23  => :foo_bar23,
     }
 
     valid.each do |input, expect|

    

--
You received this message because you are subscribed to the Google Groups "Puppet Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to [email protected].
For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.

Reply via email to