Can we get some tests to show that this works? It should be straightforward to make sure that Augeas is called correctly, with the quoted strings. That will make it easier to iterate on the parsing mechanism if necessary.
On Dec 23, 2008, at 2:00 AM, Marc Fournier wrote: > > > This patch fixes the issue in a quite basic way. Legitimate " or ' > characters > get silently dropped (ie: changes => "set \"server string\" marc's > server" > results in "server string = marc s server") and "onlyif => ..." > still chokes on > whitespaces. > > Still some work left, but at least it lets augeas edit items > containing > whitespaces. > > Signed-off-by: Marc Fournier <[email protected]> > --- > lib/puppet/provider/augeas/augeas.rb | 8 +++++++- > lib/puppet/type/augeas.rb | 7 +++++++ > 2 files changed, 14 insertions(+), 1 deletions(-) > > diff --git a/lib/puppet/provider/augeas/augeas.rb b/lib/puppet/ > provider/augeas/augeas.rb > index 0ffddeb..e92560b 100644 > --- a/lib/puppet/provider/augeas/augeas.rb > +++ b/lib/puppet/provider/augeas/augeas.rb > @@ -38,7 +38,13 @@ Puppet::Type.type(:augeas).provide(:augeas) do > if data.is_a?(String) > data.each_line do |line| > cmd_array = Array.new() > - tokens = line.split(" ") > + if line.include? ?" or line.include? ?' > + tokens = line.split(/\"|'/) > + tokens[0].slice!(/\s+$/) > + tokens[2].slice!(/^\s+/) > + else > + tokens = line.split(" ") > + end > cmd = tokens.shift() > file = tokens.shift() > other = tokens.join(" ") > diff --git a/lib/puppet/type/augeas.rb b/lib/puppet/type/augeas.rb > index 67b62e8..17cdde0 100644 > --- a/lib/puppet/type/augeas.rb > +++ b/lib/puppet/type/augeas.rb > @@ -50,6 +50,13 @@ Puppet::Type.newtype(:augeas) do > load_path => \"$/usr/share/jbossas/lenses\", > } > > + Sample usage when parameters contain whitespace:: > + > + augeas{\"samba server string\": > + context => \"/files/etc/samba/smb.conf/target[1]\", > + changes => \"set \\\"server string\\\" %h server\", > + } > + > " > > newparam (:name) do > -- > 1.5.6.5 > > > > -- Don't tell me how hard you work. Tell me how much you get done. -- James Ling --------------------------------------------------------------------- Luke Kanies | http://reductivelabs.com | http://madstop.com --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
