changeset 160:138b9baee80b

include IoLib.LuanFile fns in OsLib.LuanFile; improve PickleClient error output; git-svn-id: https://luan-java.googlecode.com/svn/trunk@161 21e917c8-12df-6dd8-5cb6-c86387c605b9
author fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
date Thu, 19 Jun 2014 07:02:16 +0000
parents 0abc9181061a
children d310ebf4d6e7
files src/luan/lib/OsLib.java src/luan/lib/PickleClient.java src/luan/modules/Reactionary.luan
diffstat 3 files changed, 28 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
diff -r 0abc9181061a -r 138b9baee80b src/luan/lib/OsLib.java
--- a/src/luan/lib/OsLib.java	Thu Jun 19 04:40:12 2014 +0000
+++ b/src/luan/lib/OsLib.java	Thu Jun 19 07:02:16 2014 +0000
@@ -41,10 +41,6 @@
 			return new LuanFile(new File(file,name)).table();
 		}
 
-		public LuanTable io_file() {
-			return new IoLib.LuanFile(file).table();
-		}
-
 		public LuanTable children() {
 			File[] files = file.listFiles();
 			if( files==null )
@@ -57,11 +53,8 @@
 		}
 
 		LuanTable table() {
-			LuanTable tbl = new LuanTable();
+			LuanTable tbl = new IoLib.LuanFile(file).table();
 			try {
-				tbl.put( "to_string", new LuanJavaFunction(
-					File.class.getMethod( "toString" ), file
-				) );
 				tbl.put( "name", new LuanJavaFunction(
 					File.class.getMethod( "getName" ), file
 				) );
@@ -89,9 +82,6 @@
 				tbl.put( "child", new LuanJavaFunction(
 					LuanFile.class.getMethod( "child", String.class ), this
 				) );
-				tbl.put( "io_file", new LuanJavaFunction(
-					LuanFile.class.getMethod( "io_file" ), this
-				) );
 				tbl.put( "children", new LuanJavaFunction(
 					LuanFile.class.getMethod( "children" ), this
 				) );
diff -r 0abc9181061a -r 138b9baee80b src/luan/lib/PickleClient.java
--- a/src/luan/lib/PickleClient.java	Thu Jun 19 04:40:12 2014 +0000
+++ b/src/luan/lib/PickleClient.java	Thu Jun 19 07:02:16 2014 +0000
@@ -57,7 +57,7 @@
 				msg + "\n"
 				+ "in:\n"
 				+ "------------------\n"
-				+ src + "\n"
+				+ formatCode(src) + "\n"
 				+ "------------------\n"
 			);
 		}
@@ -81,4 +81,26 @@
 		return tbl;
 	}
 
+
+	public static String formatCode(String s) {
+		StringBuilder buf = new StringBuilder();
+		int line = 1;
+		int i = 0;
+		int i2 = 0;
+		while( i2 != -1 ) {
+			buf.append( line++ );
+			buf.append( '\t' );
+			i2 = s.indexOf('\n',i);
+			String lineStr = i2 == -1 ? s.substring(i) : s.substring(i,i2+1);
+			int j;
+			for( j=0; j<lineStr.length() && lineStr.charAt(j)=='\t'; j++ ) {
+				buf.append( "    " );
+			}
+			buf.append( lineStr.substring(j) );
+			i = i2 + 1;
+		}
+		return buf.toString();
+	}
+
+
 }
diff -r 0abc9181061a -r 138b9baee80b src/luan/modules/Reactionary.luan
--- a/src/luan/modules/Reactionary.luan	Thu Jun 19 04:40:12 2014 +0000
+++ b/src/luan/modules/Reactionary.luan	Thu Jun 19 07:02:16 2014 +0000
@@ -3,20 +3,20 @@
 host = "localhost"
 port = 9101
 
-function put(domain,password,dir)
+function put_site(domain,password,dir)
 	local pc = Io.Socket(host,port).Pickle_client()
 	local pickle = pc.pickle
 	pc.call %>
-		Reactionary.do_put(<%=pickle(domain)%>,<%=pickle(password)%>,<%=pickle(dir)%>)
+		Reactionary.do_put_site(<%=pickle(domain)%>,<%=pickle(password)%>,<%=pickle(dir)%>)
 	<%
 	pc.close()
 end
 
-function delete(domain,password)
+function delete_site(domain,password)
 	local pc = Io.Socket(host,port).Pickle_client()
 	local pickle = pc.pickle
 	pc.call %>
-		Reactionary.do_delete(<%=pickle(domain)%>,<%=pickle(password)%>)
+		Reactionary.do_delete_site(<%=pickle(domain)%>,<%=pickle(password)%>)
 	<%
 	pc.close()
 end