[augeas-devel] [PATCH 1/2] odbc: new lens and tests.
Marc Fournier
marc.fournier at camptocamp.com
Tue Sep 14 13:46:09 UTC 2010
Signed-off-by: Marc Fournier <marc.fournier at camptocamp.com>
---
lenses/odbc.aug | 43 +++++++++++++++++++++++++++
lenses/tests/test_odbc.aug | 69 ++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 112 insertions(+), 0 deletions(-)
create mode 100644 lenses/odbc.aug
create mode 100644 lenses/tests/test_odbc.aug
diff --git a/lenses/odbc.aug b/lenses/odbc.aug
new file mode 100644
index 0000000..633891d
--- /dev/null
+++ b/lenses/odbc.aug
@@ -0,0 +1,43 @@
+(*
+ ODBC lens for Augeas
+ Author: Marc Fournier <marc.fournier at camptocamp.com>
+
+ odbc.ini and odbcinst.ini are standard INI files.
+*)
+
+
+module Odbc =
+ autoload xfm
+
+(************************************************************************
+ * INI File settings
+ * odbc.ini only supports "# as commentary and "=" as separator
+ ************************************************************************)
+let comment = IniFile.comment "#" "#"
+let sep = IniFile.sep "=" "="
+
+
+(************************************************************************
+ * ENTRY
+ * odbc.ini uses standard INI File entries
+ ************************************************************************)
+let entry = IniFile.indented_entry IniFile.entry_re sep comment
+
+
+(************************************************************************
+ * RECORD
+ * odbc.ini uses standard INI File records
+ ************************************************************************)
+let title = IniFile.indented_title IniFile.record_re
+let record = IniFile.record title entry
+
+
+(************************************************************************
+ * LENS & FILTER
+ ************************************************************************)
+let lns = IniFile.lns record comment
+
+let filter = incl "/etc/odbc.ini"
+ . incl "/etc/odbcinst.ini"
+
+let xfm = transform lns filter
diff --git a/lenses/tests/test_odbc.aug b/lenses/tests/test_odbc.aug
new file mode 100644
index 0000000..5f886f9
--- /dev/null
+++ b/lenses/tests/test_odbc.aug
@@ -0,0 +1,69 @@
+module Test_odbc =
+
+ let conf = "
+# Example driver definitinions
+#
+#
+
+# Included in the unixODBC package
+[PostgreSQL]
+Description = ODBC for PostgreSQL
+Driver = /usr/lib/libodbcpsql.so
+Setup = /usr/lib/libodbcpsqlS.so
+FileUsage = 1
+
+[MySQL]
+# Driver from the MyODBC package
+# Setup from the unixODBC package
+Description = ODBC for MySQL
+Driver = /usr/lib/libmyodbc.so
+Setup = /usr/lib/libodbcmyS.so
+FileUsage = 1
+"
+
+test Odbc.lns get conf =
+ { }
+ { "#comment" = "Example driver definitinions" }
+ { "#comment" }
+ { "#comment" }
+ { }
+ { "#comment" = "Included in the unixODBC package" }
+
+ { "PostgreSQL"
+ { "Description" = "ODBC for PostgreSQL" }
+ { "Driver" = "/usr/lib/libodbcpsql.so" }
+ { "Setup" = "/usr/lib/libodbcpsqlS.so" }
+ { "FileUsage" = "1" }
+ {}
+ }
+ { "MySQL"
+ { "#comment" = "Driver from the MyODBC package" }
+ { "#comment" = "Setup from the unixODBC package" }
+ { "Description" = "ODBC for MySQL" }
+ { "Driver" = "/usr/lib/libmyodbc.so" }
+ { "Setup" = "/usr/lib/libodbcmyS.so" }
+ { "FileUsage" = "1" }
+ }
+
+test Odbc.lns put conf after
+ set "MySQL/Driver" "/usr/lib64/libmyodbc3.so";
+ set "MySQL/Driver/#comment" "note the path" = "
+# Example driver definitinions
+#
+#
+
+# Included in the unixODBC package
+[PostgreSQL]
+Description = ODBC for PostgreSQL
+Driver = /usr/lib/libodbcpsql.so
+Setup = /usr/lib/libodbcpsqlS.so
+FileUsage = 1
+
+[MySQL]
+# Driver from the MyODBC package
+# Setup from the unixODBC package
+Description = ODBC for MySQL
+Driver = /usr/lib64/libmyodbc3.so#note the path
+Setup = /usr/lib/libodbcmyS.so
+FileUsage = 1
+"
--
1.7.1
More information about the augeas-devel
mailing list