[augeas-devel] augeas: master - Fix bug #25 - allow indented entries in puppet.conf
David Lutterkort
lutter at fedoraproject.org
Thu Jan 22 22:37:00 UTC 2009
Gitweb: http://git.fedorahosted.org/git/augeas.git?p=augeas.git;a=commitdiff;h=67d2e28ee4f97e787daad3822b738b5cba947bf7
Commit: 67d2e28ee4f97e787daad3822b738b5cba947bf7
Parent: 2d4c4da36f5a8d9428d8b6871cebbec757aeec6c
Author: David Lutterkort <lutter at redhat.com>
AuthorDate: Thu Jan 22 13:49:37 2009 -0800
Committer: David Lutterkort <lutter at redhat.com>
CommitterDate: Thu Jan 22 13:49:37 2009 -0800
Fix bug #25 - allow indented entries in puppet.conf
* lenses/inifile.aug: add new indented_entry and indented_title
lenses
* lenses/puppet.aug: use the indented_* lenses
* lenses/tests/test_puppet.aug: test with indented entries
---
lenses/inifile.aug | 34 ++++++++++++++++++++++++++++++++++
lenses/puppet.aug | 4 ++--
lenses/tests/test_puppet.aug | 8 ++++----
3 files changed, 40 insertions(+), 6 deletions(-)
diff --git a/lenses/inifile.aug b/lenses/inifile.aug
index a97ad1a..30f5233 100644
--- a/lenses/inifile.aug
+++ b/lenses/inifile.aug
@@ -141,6 +141,26 @@ let entry (kw:regexp) (sep:lens) (comment:lens)
= [ key kw . sep . sto_to_comment? . (comment|eol) ] | comment
(*
+View: indented_entry
+ Generic INI File entry that might be indented with an arbitrary
+ amount of whitespace
+
+ Parameters:
+ kw:regexp - keyword regexp for the label
+ sep:lens - lens to use as key/value separator
+ comment:lens - lens to use as comment
+
+ Sample Usage:
+ > let entry = IniFile.indented_entry setting sep comment
+*)
+let indented_entry (kw:regexp) (sep:lens) (comment:lens)
+ = [ Util.del_opt_ws "" .
+ key kw . sep . sto_to_comment? .
+ (comment|eol)
+ ]
+ | comment
+
+(*
Variable: entry_re
Default regexp for <entry> keyword
*)
@@ -168,6 +188,20 @@ let title (kw:regexp)
. Util.del_str "]". eol
(*
+View: indented_title
+ Title for <record>. This maps the title of a record as a node in the abstract tree. The title may be indented with arbitrary amounts of whitespace
+
+ Parameters:
+ kw:regexp - keyword regexp for the label
+
+ Sample Usage:
+ > let title = IniFile.title IniFile.record_re
+*)
+let indented_title (kw:regexp)
+ = Util.del_opt_ws "" . Util.del_str "[" . key kw
+ . Util.del_str "]". eol
+
+(*
View: title_label
Title for <record>. This maps the title of a record as a value in the abstract tree.
diff --git a/lenses/puppet.aug b/lenses/puppet.aug
index 4b5afc5..bae6534 100644
--- a/lenses/puppet.aug
+++ b/lenses/puppet.aug
@@ -21,14 +21,14 @@ let sep = IniFile.sep "=" "="
* ENTRY
* puppet.conf uses standard INI File entries
*************************************************************************)
-let entry = IniFile.entry IniFile.entry_re sep comment
+let entry = IniFile.indented_entry IniFile.entry_re sep comment
(************************************************************************
* RECORD
* puppet.conf uses standard INI File records
*************************************************************************)
-let title = IniFile.title IniFile.record_re
+let title = IniFile.indented_title IniFile.record_re
let record = IniFile.record title entry
diff --git a/lenses/tests/test_puppet.aug b/lenses/tests/test_puppet.aug
index 40d52e9..a10ef01 100644
--- a/lenses/tests/test_puppet.aug
+++ b/lenses/tests/test_puppet.aug
@@ -4,8 +4,8 @@ module Test_puppet =
[main]
logdir=/var/log/puppet
-[puppetd]
-server=misspiggy.network.com
+ [puppetd]
+ server=misspiggy.network.com
"
test Puppet.lns get conf =
@@ -25,7 +25,7 @@ logdir=/var/log/puppet
vardir=/var/lib/puppet
rundir=/var/run/puppet
-[puppetd]
-server=misspiggy.network.com
+ [puppetd]
+ server=misspiggy.network.com
"
More information about the augeas-devel
mailing list