update moon library to not use module

This commit is contained in:
leaf corcoran 2013-06-07 23:34:03 -07:00
parent e65ac4946d
commit 2f4066d9bb
4 changed files with 32 additions and 20 deletions

View File

@ -1,3 +1,5 @@
moon = moon or { } local moon = require("moon")
moon.inject = true for k, v in pairs(moon) do
return require("moon.init") _G[k] = v
end
return moon

View File

@ -1,8 +1,6 @@
-- install moon into global scope
-- insert all moon library functions into requiring scope moon = require "moon"
for k,v in pairs moon
export moon _G[k] = v
moon = moon or {} moon
moon.inject = true
require "moon.init"

View File

@ -1,11 +1,9 @@
if not moon or not moon.inject then
module("moon", package.seeall)
end
local util = require("moonscript.util") local util = require("moonscript.util")
local lua = { local lua = {
debug = debug, debug = debug,
type = type type = type
} }
local dump, p, is_object, type, debug, run_with_scope, bind_methods, defaultbl, extend, copy, mixin, mixin_object, mixin_table, fold
dump = util.dump dump = util.dump
p = function(...) p = function(...)
return print(dump(...)) return print(dump(...))
@ -161,4 +159,19 @@ fold = function(items, fn)
return items[1] return items[1]
end end
end end
return nil return {
dump = dump,
p = p,
is_object = is_object,
type = type,
debug = debug,
run_with_scope = run_with_scope,
bind_methods = bind_methods,
defaultbl = defaultbl,
extend = extend,
copy = copy,
mixin = mixin,
mixin_object = mixin_object,
mixin_table = mixin_table,
fold = fold
}

View File

@ -1,12 +1,8 @@
if not moon or not moon.inject
module "moon", package.seeall
util = require "moonscript.util" util = require "moonscript.util"
lua = { :debug, :type } lua = { :debug, :type }
export * local *
dump = util.dump dump = util.dump
@ -134,4 +130,7 @@ fold = (items, fn)->
else else
items[1] items[1]
nil {
:dump, :p, :is_object, :type, :debug, :run_with_scope, :bind_methods,
:defaultbl, :extend, :copy, :mixin, :mixin_object, :mixin_table, :fold
}