[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, master, updated. debian/0.24.7-1-98-gf19c0e5

Bryan Kearney bkearney at redhat.com
Wed Apr 8 21:48:22 UTC 2009


The following commit has been merged in the master branch:
commit cedeb7982b051e00173822c8d14a794e4fb10ae7
Author: Bryan Kearney <bkearney at redhat.com>
Date:   Wed Feb 18 12:46:17 2009 -0500

    Backport the fix for #1835

diff --git a/lib/puppet/provider/augeas/augeas.rb b/lib/puppet/provider/augeas/augeas.rb
index 5fa5ab4..e9471b1 100644
--- a/lib/puppet/provider/augeas/augeas.rb
+++ b/lib/puppet/provider/augeas/augeas.rb
@@ -42,10 +42,27 @@ Puppet::Type.type(:augeas).provide(:augeas) do
         if data.is_a?(String)
             data.each_line do |line|
                 cmd_array = Array.new()
-                tokens = line.split(" ")
-                cmd = tokens.shift()
-                file = tokens.shift()
-                other = tokens.join(" ")
+                single = line.index("'")
+                double = line.index('"')
+                tokens = nil
+                delim = " "
+                if ((single != nil) or (double != nil))
+                    single = 99999 if single == nil
+                    double = 99999 if double == nil
+                    delim = '"' if double < single
+                    delim = "'" if single < double
+                end
+                tokens = line.split(delim)
+                # If the length of tokens is 2, thn that means the pattern was
+                # command file "some text", therefore we need to re-split
+                # the first line
+                if tokens.length == 2
+                    tokens = (tokens[0].split(" ")) << tokens[1]
+                end
+                cmd = tokens.shift().strip()
+                delim = "" if delim == " "
+                file = tokens.shift().strip()
+                other = tokens.join(" ").strip()
                 cmd_array << cmd if !cmd.nil?
                 cmd_array << file if !file.nil?
                 cmd_array << other if other != ""
@@ -59,6 +76,7 @@ Puppet::Type.type(:augeas).provide(:augeas) do
         return commands
     end
 
+
     def open_augeas
         if (@aug.nil?)
             flags = 0
diff --git a/spec/unit/provider/augeas/augeas.rb b/spec/unit/provider/augeas/augeas.rb
index 3ce6457..e05812d 100644
--- a/spec/unit/provider/augeas/augeas.rb
+++ b/spec/unit/provider/augeas/augeas.rb
@@ -54,6 +54,86 @@ describe provider_class do
             tokens[0][1].should == "/Jar/Jar"
             tokens[0][2].should == "Binks is my copilot"            
         end
+
+        it "should accept spaces and and single ticks" do
+            provider = provider_class.new()
+            tokens = provider.parse_commands("set 'Jar Jar' Binks")
+            tokens.size.should == 1
+            tokens[0].size.should == 3
+            tokens[0][0].should == "set"
+            tokens[0][1].should == "Jar Jar"
+            tokens[0][2].should == "Binks"
+        end
+ 
+        it "should accept spaces in the value and and single ticks" do
+            provider = provider_class.new()
+            tokens = provider.parse_commands("set 'Jar Jar' 'Binks is my copilot'")
+            tokens.size.should == 1
+            tokens[0].size.should == 3
+            tokens[0][0].should == "set"
+            tokens[0][1].should == "Jar Jar"
+            tokens[0][2].should == "Binks is my copilot"
+        end
+ 
+        it "should accept spaces and and double ticks" do
+            provider = provider_class.new()
+            tokens = provider.parse_commands('set "Jar Jar" Binks')
+            tokens.size.should == 1
+            tokens[0].size.should == 3
+            tokens[0][0].should == "set"
+            tokens[0][1].should == 'Jar Jar'
+            tokens[0][2].should == 'Binks'
+        end
+ 
+        it "should accept spaces in the value and and double ticks" do
+            provider = provider_class.new()
+            tokens = provider.parse_commands('set "Jar Jar" "Binks is my copilot"')
+            tokens.size.should == 1
+            tokens[0].size.should == 3
+            tokens[0][0].should == "set"
+            tokens[0][1].should == 'Jar Jar'
+            tokens[0][2].should == 'Binks is my copilot'
+        end
+ 
+        it "should accept mixed ticks" do
+            provider = provider_class.new()
+            tokens = provider.parse_commands('set "Jar Jar" "Some \'Test\'"')
+            tokens.size.should == 1
+            tokens[0].size.should == 3
+            tokens[0][0].should == "set"
+            tokens[0][1].should == 'Jar Jar'
+            tokens[0][2].should == "Some \'Test\'"
+        end
+ 
+        it "should accept only the last value using ticks" do
+            provider = provider_class.new()
+            tokens = provider.parse_commands('set /Jar/Jar "Binks is my copilot"')
+            tokens.size.should == 1
+            tokens[0].size.should == 3
+            tokens[0][0].should == "set"
+            tokens[0][1].should == '/Jar/Jar'
+            tokens[0][2].should == "Binks is my copilot"
+        end
+ 
+        it "should accept only the first value using ticks" do
+            provider = provider_class.new()
+            tokens = provider.parse_commands('set "Jar Jar" copilot')
+            tokens.size.should == 1
+            tokens[0].size.should == 3
+            tokens[0][0].should == "set"
+            tokens[0][1].should == 'Jar Jar'
+            tokens[0][2].should == "copilot"
+        end
+ 
+        it "should accept only the first value using ticks and the last values being concatenated" do
+            provider = provider_class.new()
+            tokens = provider.parse_commands('set "Jar Jar" Binks is my copilot')
+            tokens.size.should == 1
+            tokens[0].size.should == 3
+            tokens[0][0].should == "set"
+            tokens[0][1].should == 'Jar Jar'
+            tokens[0][2].should == "Binks is my copilot"
+        end         
     end
     
     describe "get filters" do

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list