Mercurial Hosting > luan
changeset 435:5b36f663a1b8
make members lower case
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sun, 03 May 2015 21:28:49 -0600 |
parents | 472fc70853cd |
children | 52a6295e92c9 |
files | core/src/luan/modules/Io.luan core/src/luan/modules/IoLuan.java core/src/luan/modules/PackageLuan.java core/src/luan/modules/host/Hosting.luan lucene/src/luan/modules/lucene/Ab_testing.luan lucene/src/luan/modules/lucene/Lucene.luan lucene/src/luan/modules/lucene/Web_search.luan scripts/test.luan web/src/luan/modules/web/Server.luan |
diffstat | 9 files changed, 37 insertions(+), 35 deletions(-) [+] |
line wrap: on
line diff
--- a/core/src/luan/modules/Io.luan Sun May 03 16:21:25 2015 -0600 +++ b/core/src/luan/modules/Io.luan Sun May 03 21:28:49 2015 -0600 @@ -4,7 +4,7 @@ read_console_line = IoLuan.read_console_line schemes = IoLuan.newSchemes() -Uri = IoLuan.Uri +uri = IoLuan.uri stdin = IoLuan.defaultStdin.table() socket_server = IoLuan.socket_server stdout = IoLuan.textWriter(System.out) @@ -79,11 +79,13 @@ end end +local uri = uri -- make local + function repr(obj) local old_out = stdout return try { function() - local string_uri = Uri "string:" + local string_uri = uri "string:" stdout = string_uri.text_writer() do_repr(obj,{}) stdout.close()
--- a/core/src/luan/modules/IoLuan.java Sun May 03 16:21:25 2015 -0600 +++ b/core/src/luan/modules/IoLuan.java Sun May 03 21:28:49 2015 -0600 @@ -37,7 +37,7 @@ public final class IoLuan { - private static void add(LuanTable t,String method,Class<?>... parameterTypes) throws NoSuchMethodException { + private static void add(LuanTable t,String method,Class... parameterTypes) throws NoSuchMethodException { t.rawPut( method, new LuanJavaFunction(IoLuan.class.getMethod(method,parameterTypes),null) ); } @@ -576,7 +576,7 @@ return t; } - public static LuanTable Uri(LuanState luan,String name) throws LuanException { + public static LuanTable uri(LuanState luan,String name) throws LuanException { int i = name.indexOf(':'); if( i == -1 ) throw luan.exception( "invalid Io name '"+name+"', missing scheme" ); @@ -612,7 +612,7 @@ return socket.toString(); } - public LuanTable Pickle_client(LuanState luan) throws IOException { + public LuanTable pickle_client(LuanState luan) throws IOException { InputStream in = new BufferedInputStream(inputStream()); OutputStream out = new BufferedOutputStream(outputStream()); return new PickleClient(luan,in,out).table(); @@ -627,8 +627,8 @@ @Override public LuanTable table() { LuanTable tbl = super.table(); try { - tbl.rawPut( "Pickle_client", new LuanJavaFunction( - LuanSocket.class.getMethod( "Pickle_client", LuanState.class ), this + tbl.rawPut( "pickle_client", new LuanJavaFunction( + LuanSocket.class.getMethod( "pickle_client", LuanState.class ), this ) ); tbl.rawPut( "run_pickle_server", new LuanJavaFunction( LuanSocket.class.getMethod( "run_pickle_server", LuanState.class ), this
--- a/core/src/luan/modules/PackageLuan.java Sun May 03 16:21:25 2015 -0600 +++ b/core/src/luan/modules/PackageLuan.java Sun May 03 21:28:49 2015 -0600 @@ -62,7 +62,7 @@ } static String read(LuanState luan,String uri) throws LuanException { - LuanTable t = IoLuan.Uri(luan,uri); + LuanTable t = IoLuan.uri(luan,uri); if( t == null ) return null; LuanFunction existsFn = (LuanFunction)t.get(luan,"exists");
--- a/core/src/luan/modules/host/Hosting.luan Sun May 03 16:21:25 2015 -0600 +++ b/core/src/luan/modules/host/Hosting.luan Sun May 03 21:28:49 2015 -0600 @@ -8,11 +8,11 @@ port = 9101 function push(domain,password,dir) - local f = Io.Uri("file:"..dir) + local f = Io.uri("file:"..dir) f.exists() or error("directory '"..dir.."' not found") f.is_directory() or error("'"..dir.."' is not a directory") local socket = "socket:" .. domain .. ":" .. port - local pc = Io.Uri(socket).Pickle_client() + local pc = Io.uri(socket).pickle_client() local pickle = pc.pickle pc.call(%> local Hosting = require "luan:host/Hosting" @@ -23,7 +23,7 @@ function delete(domain,password) local socket = "socket:" .. domain .. ":" .. port - local pc = Io.Uri(socket).Pickle_client() + local pc = Io.uri(socket).pickle_client() local pickle = pc.pickle pc.call(%> local Hosting = require "luan:host/Hosting"
--- a/lucene/src/luan/modules/lucene/Ab_testing.luan Sun May 03 16:21:25 2015 -0600 +++ b/lucene/src/luan/modules/lucene/Ab_testing.luan Sun May 03 21:28:49 2015 -0600 @@ -49,7 +49,7 @@ for name, factory in pairs(test.aggregator_factories) do aggregators[name] = factory() end - local query = index.Query.term{ [field] = value } + local query = index.query.term{ [field] = value } searcher.search(query, function(doc) for _, aggregator in pairs(aggregators) do aggregator.aggregate(doc)
--- a/lucene/src/luan/modules/lucene/Lucene.luan Sun May 03 16:21:25 2015 -0600 +++ b/lucene/src/luan/modules/lucene/Lucene.luan Sun May 03 21:28:49 2015 -0600 @@ -13,10 +13,10 @@ local SortField = require "java:org.apache.lucene.search.SortField" -function Index(indexDir) +function index(indexDir) local index = {} local java_index = LuceneIndex.new(indexDir) - index.fields = java_index.fields + index.fields = java_index.fields.newTable() index.to_string = java_index.to_string index.backup = java_index.backup index.Writer = java_index.Writer @@ -61,14 +61,14 @@ - local Query = {} - index.Query = Query + local queryTbl = {} + index.query = queryTbl - Query.parse = java_index.parse + queryTbl.parse = java_index.parse - Query.all_docs = MatchAllDocsQuery.new() + queryTbl.all_docs = MatchAllDocsQuery.new() - function Query.term(t) + function queryTbl.term(t) local iter = pairs(t) local field, value = iter() field and value or error "missing term" @@ -77,7 +77,7 @@ return TermQuery.new(Term.new(field,value)) end - function Query.boolean(t) + function queryTbl.boolean(t) local boolean_query = BooleanQuery.new() for query, occur_string in pairs(t) do local occur = BooleanClause.Occur.valueOf( occur_string.upper() ) @@ -87,31 +87,31 @@ end -- and list - function Query.all(t) + function queryTbl.all(t) local bt = {} for key, query in pairs(t) do if type(key)=="string" then - query = Query.term{[key]=query} + query = queryTbl.term{[key]=query} end bt[query] = "MUST" end - return Query.boolean(bt) + return queryTbl.boolean(bt) end -- or list - function Query.any(t) + function queryTbl.any(t) local bt = {} for key, query in pairs(t) do if type(key)=="string" then - query = Query.term{[key]=query} + query = queryTbl.term{[key]=query} end bt[query] = "SHOULD" end - return Query.boolean(bt) + return queryTbl.boolean(bt) end - function Query.sort(fields) + function queryTbl.sort(fields) #fields > 0 or error "list of sort fields expected" local a = {} for _, f in ipairs(fields) do
--- a/lucene/src/luan/modules/lucene/Web_search.luan Sun May 03 16:21:25 2015 -0600 +++ b/lucene/src/luan/modules/lucene/Web_search.luan Sun May 03 21:28:49 2015 -0600 @@ -129,9 +129,9 @@ form() return end - local query = load(query_string,"<query>",{Query=index.Query},true)() + local query = load(query_string,"<query>",{Query=index.query},true)() local rows = to_number(Http.request.parameters.rows) - local sort = load(Http.request.parameters.sort,"<sort>",{Query=index.Query},true)() + local sort = load(Http.request.parameters.sort,"<sort>",{Query=index.query},true)() index.Searcher( function(searcher) local results, length, total_hits = searcher.search(query,rows,sort) local headers = {}
--- a/scripts/test.luan Sun May 03 16:21:25 2015 -0600 +++ b/scripts/test.luan Sun May 03 21:28:49 2015 -0600 @@ -12,18 +12,18 @@ end function Io.schemes.site(path) - return Io.Uri( "luan:web"..path ) + return Io.uri( "luan:web"..path ) end Http.init_for_test() Http.request.parameters.code = "require('luan:Io').print 'hi'" -page = Http.get_page "/web_run" +page = Http.get_page "/run" assert( page.trim() == "hi" ) Http.init_for_test() Http.request.parameters.cmd = "'ab'..'cd'" -page = Http.get_page "/web_shell" +page = Http.get_page "/shell" assert( page.find "abcd" ) @@ -33,7 +33,7 @@ this_dir = this_file.parent() lucene_dir = this_dir.parent().child("build").child("lucene_test") --print(lucene_dir.to_string()) -db = Lucene.Index(lucene_dir.to_string()) +db = Lucene.index(lucene_dir.to_string()) db.delete_all() ab_testing = Ab_testing.of(db)
--- a/web/src/luan/modules/web/Server.luan Sun May 03 16:21:25 2015 -0600 +++ b/web/src/luan/modules/web/Server.luan Sun May 03 21:28:49 2015 -0600 @@ -73,14 +73,14 @@ dir = dir.gsub("/$","") -- remove trailing '/' if any Http.dir = dir function Io.schemes.site(path) - return Io.Uri( dir..path ) + return Io.uri( dir..path ) end authentication_handler.setPassword(private_password) local base = dir if base.match("^classpath:") ~= nil then base = dir.."#"..welcome_file.."#"..welcome_file..".luan" end - resource_handler.setResourceBase(Io.Uri(base).to_string()) + resource_handler.setResourceBase(Io.uri(base).to_string()) resource_handler.setWelcomeFiles {welcome_file} luan_handler.setWelcomeFile(welcome_file) handlers.addHandler(NotFound.new())