Mercurial Hosting > luan
changeset 144:2e92f0a6fcac
add Reactionary.luan
git-svn-id: https://luan-java.googlecode.com/svn/trunk@145 21e917c8-12df-6dd8-5cb6-c86387c605b9
author | fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9> |
---|---|
date | Sun, 15 Jun 2014 06:42:58 +0000 |
parents | fcb81fa2df0d |
children | 90f38a5d0e0a |
files | src/luan/lib/IoLib.java src/luan/lib/PackageLib.java src/luan/lib/init.luan src/luan/modules/Reactionary.luan |
diffstat | 4 files changed, 37 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
diff -r fcb81fa2df0d -r 2e92f0a6fcac src/luan/lib/IoLib.java --- a/src/luan/lib/IoLib.java Fri Jun 13 19:04:05 2014 +0000 +++ b/src/luan/lib/IoLib.java Sun Jun 15 06:42:58 2014 +0000 @@ -212,7 +212,7 @@ public static abstract class LuanIn { abstract InputStream inputStream() throws IOException; - abstract String name(); + public abstract String name(); public String read_text() throws IOException { Reader in = new InputStreamReader(inputStream()); @@ -317,11 +317,11 @@ this.url = new URL(s); } - InputStream inputStream() throws IOException { + @Override InputStream inputStream() throws IOException { return url.openStream(); } - String name() { + @Override public String name() { return url.toString(); } } @@ -333,15 +333,15 @@ this.file = new File(name); } - InputStream inputStream() throws IOException { + @Override InputStream inputStream() throws IOException { return new FileInputStream(file); } - OutputStream outputStream() throws IOException { + @Override OutputStream outputStream() throws IOException { return new FileOutputStream(file); } - String name() { + @Override public String name() { return file.toString(); } } @@ -374,15 +374,15 @@ this.socket = socket; } - InputStream inputStream() throws IOException { + @Override InputStream inputStream() throws IOException { return socket.getInputStream(); } - OutputStream outputStream() throws IOException { + @Override OutputStream outputStream() throws IOException { return socket.getOutputStream(); } - String name() { + @Override public String name() { return socket.toString(); }
diff -r fcb81fa2df0d -r 2e92f0a6fcac src/luan/lib/PackageLib.java --- a/src/luan/lib/PackageLib.java Fri Jun 13 19:04:05 2014 +0000 +++ b/src/luan/lib/PackageLib.java Sun Jun 15 06:42:58 2014 +0000 @@ -21,7 +21,7 @@ LuanTable global = luan.global(); module.put("loaded",luan.loaded()); module.put("preload",luan.preload()); - module.put("path","?.luan"); + module.put("path","?.luan;java:luan/modules/?.luan"); try { add( global, "require", LuanState.class, String.class ); add( module, "get_loader", String.class );
diff -r fcb81fa2df0d -r 2e92f0a6fcac src/luan/lib/init.luan --- a/src/luan/lib/init.luan Fri Jun 13 19:04:05 2014 +0000 +++ b/src/luan/lib/init.luan Sun Jun 15 06:42:58 2014 +0000 @@ -63,3 +63,7 @@ end end end + + +-- import modules +_G.Reactionary = require "Reactionary"
diff -r fcb81fa2df0d -r 2e92f0a6fcac src/luan/modules/Reactionary.luan --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/luan/modules/Reactionary.luan Sun Jun 15 06:42:58 2014 +0000 @@ -0,0 +1,23 @@ +-- Reactionary + +host = "localhost" +port = 9101 + +function put(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)%>) + <% + pc.close() +end + +function delete(domain,password) + local pc = Io.socket(host,port).pickle_client() + local pickle = pc.pickle + pc.call %> + Reactionary.do_delete(<%=pickle(domain)%>,<%=pickle(password)%>) + <% + pc.close() +end +