[asterisk-commits] mnicholson: branch mnicholson/asttest r175026 - in /team/mnicholson/asttest/a...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Feb 11 21:11:06 CST 2009


Author: mnicholson
Date: Wed Feb 11 21:11:06 2009
New Revision: 175026

URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=175026
Log:
added the ability to add verbatim data to config files, and updated the astlib test to test for that

Modified:
    team/mnicholson/asttest/asttest/lua/astlib.lua
    team/mnicholson/asttest/asttest/self-tests/test_astlib/test.lua

Modified: team/mnicholson/asttest/asttest/lua/astlib.lua
URL: http://svn.digium.com/svn-view/asterisk/team/mnicholson/asttest/asttest/lua/astlib.lua?view=diff&rev=175026&r1=175025&r2=175026
==============================================================================
--- team/mnicholson/asttest/asttest/lua/astlib.lua (original)
+++ team/mnicholson/asttest/asttest/lua/astlib.lua Wed Feb 11 21:11:06 2009
@@ -61,6 +61,10 @@
 	return ac
 end
 
+function config:verbatim(data)
+	table.insert(self.sections, data)
+end
+
 function config:add_section(new_section)
 	if (getmetatable(new_section) ~= conf_section) then
 		error("got " .. type(new_section) .. " expected type conf_section")
@@ -92,34 +96,11 @@
 	end
 
 	for _, section in ipairs(self.sections) do
-		f:write("[" .. section.name .. "]")
-		if section.template then
-			f:write("(!")
-			for _, i in ipairs(section.inherit) do
-				f:write("," .. i)
-			end
-			f:write(")")
+		if getmetatable(section) == conf_section then
+			section:write(f)
 		else
-			if #section.inherit ~= 0 then
-				f:write("(")
-				local first = true
-				for _, i in ipairs(section.inherit) do
-					if not first then
-						f:write(",")
-					else
-						first = false
-					end
-					f:write(i)
-				end
-				f:write(")")
-			end
+			f:write(tostring(section))
 		end
-		f:write("\n")
-
-		for _, value in ipairs(section.values) do
-			f:write(tostring(value[1]) .. " = " .. tostring(value[2]) .. "\n")
-		end
-		f:write("\n")
 	end
 
 	f:close()
@@ -150,3 +131,34 @@
 	return self.values[self.value_index[key]]
 end
 
+function conf_section:write(f)
+	f:write("[" .. self.name .. "]")
+	if self.template then
+		f:write("(!")
+		for _, i in ipairs(self.inherit) do
+			f:write("," .. i)
+		end
+		f:write(")")
+	else
+		if #self.inherit ~= 0 then
+			f:write("(")
+			local first = true
+			for _, i in ipairs(self.inherit) do
+				if not first then
+					f:write(",")
+				else
+					first = false
+				end
+				f:write(i)
+			end
+			f:write(")")
+		end
+	end
+	f:write("\n")
+
+	for _, value in ipairs(self.values) do
+		f:write(tostring(value[1]) .. " = " .. tostring(value[2]) .. "\n")
+	end
+	f:write("\n")
+end
+

Modified: team/mnicholson/asttest/asttest/self-tests/test_astlib/test.lua
URL: http://svn.digium.com/svn-view/asterisk/team/mnicholson/asttest/asttest/self-tests/test_astlib/test.lua?view=diff&rev=175026&r1=175025&r2=175026
==============================================================================
--- team/mnicholson/asttest/asttest/self-tests/test_astlib/test.lua (original)
+++ team/mnicholson/asttest/asttest/self-tests/test_astlib/test.lua Wed Feb 11 21:11:06 2009
@@ -15,6 +15,8 @@
 
 [section]
 value = no
+
+#include file
 
 [template](!)
 value = default
@@ -50,6 +52,8 @@
 
 s = c:new_section("section")
 s["value"] = "no"
+
+c:verbatim("#include file\n\n")
 
 s = c:new_section("template")
 s.template = true




More information about the asterisk-commits mailing list