gluon-core: make Lua files proper modules

This commit is contained in:
Matthias Schiffer 2014-05-14 17:24:57 +02:00
parent bf7a2c974e
commit ee307ec1de
2 changed files with 24 additions and 8 deletions

View File

@ -6,4 +6,16 @@ local function loader()
end end
-- setfenv doesn't work with Lua 5.2 anymore, but we're using 5.1 -- setfenv doesn't work with Lua 5.2 anymore, but we're using 5.1
return setfenv(assert(load(coroutine.wrap(loader), 'site.conf')), {})() local site_config = setfenv(assert(load(coroutine.wrap(loader), 'site.conf')), {})()
local setmetatable = setmetatable
module 'gluon.site_config'
setmetatable(_M,
{
__index = site_config,
}
)
return _M

View File

@ -17,11 +17,15 @@ local function set(_, name, val)
f:close() f:close()
end end
local sysconfig = {} local setmetatable = setmetatable
local mt = {
__index = get,
__newindex = set,
}
setmetatable(sysconfig, mt) module 'gluon.sysconfig'
return sysconfig
setmetatable(_M,
{
__index = get,
__newindex = set,
}
)
return _M