Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Updated lub to 1.0.2 #1

Closed
wants to merge 15 commits into from

2 participants

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
24 .travis.yml
@@ -11,18 +11,23 @@ env:
- TOOL="clang" # Use clang
- TOOL="i686-w64-mingw32" # 32bit MinGW
- TOOL="x86_64-w64-mingw32" # 64bit MinGW
- - TOOL="arm-linux-gnueabihf" # ARM hard-float (hf), linux
+# This will always fail because lvm.c fails
+# - TOOL="arm-linux-gnueabihf" # ARM hard-float (hf), linux
-# Crosscompile builds may fail
-matrix:
- allow_failures:
- - env: TOOL="i686-w64-mingw32"
- - env: TOOL="x86_64-w64-mingw32"
- - env: TOOL="arm-linux-gnueabihf"
+# Crosscompile builds may notfail
+# matrix:
+# allow_failures:
+# - env: TOOL="i686-w64-mingw32"
+# - env: TOOL="x86_64-w64-mingw32"
+# - env: TOOL="arm-linux-gnueabihf"
# Install dependencies
install:
- git clone git://github.com/LuaDist/Tools.git ~/_tools
+ # For testing "lub" depends on "lut"
+ - git clone git://github.com/lubyk/lut.git ~/_lut
+ - ln -sf ~/_lut/lut lut
+ - ln -sf ~/_lut/lut/init.lua lut.lua
- ~/_tools/travis/travis install
# Bootstap
@@ -31,7 +36,8 @@ before_script:
# Build the module
script:
- - ~/_tools/travis/travis build
+ - ~/_tools/travis/travis build && (test -e ~/build/lubyk/lub/_test/bin/lua.exe || ~/build/lubyk/lub/_test/bin/lua test/all.lua)
+
# Execute additional tests or commands
after_script:
@@ -45,7 +51,7 @@ branches:
# Notify the LuaDist Dev group if needed
notifications:
recipients:
- - luadist-dev@googlegroups.com
+ - gaspard@teti.ch
email:
on_success: change
on_failure: always
View
2  CMakeLists.txt
@@ -7,7 +7,7 @@ include ( lua )
install (
DIRECTORY lub/
- DESTINATION ${INSTALL_LMOD}/lub
+ DESTINATION ${INSTALL_LMOD}/lub
COMPONENT Runtime
)
View
2  README.md
@@ -1,4 +1,4 @@
-lub
+lub [![Build Status](https://travis-ci.org/lubyk/lub.png)](https://travis-ci.org/lubyk/lub)
===
Lubyk core library (provides autoloading, helpers).
View
2  dist.info
@@ -1,7 +1,7 @@
--- This file is part of Lubyk project
name = "lub"
-version = "1.0.0"
+version = "1.0.2"
desc = "Lubyk base module (autoload, template, helpers)"
author = "Gaspard Bucher"
View
13 doc/index.html
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<html lang="en">
+ <head>
+ <title>lub</title>
+ </head>
+ <body>
+ <h3>Online documentation</h3>
+ <p><a href='http://doc.lubyk.org/lub.html'>doc.lubyk.org/lub.html</a></h1></p>
+
+ <h3>Generate</h3>
+ <pre>$ lua scripts/makedoc.lua</pre>
+ </body>
+</html>
View
34 lub-1.0.0-1.rockspec
@@ -1,34 +0,0 @@
-package = "Lub"
-version = "1.0.0-1"
-source = {
- url = "http://lubyk.org/archive/REL-1.0.0.tar.gz",
- dir = 'lub-REL-1.0.0',
-}
-description = {
- summary = "Lubyk base module.",
- detailed = [[
- lub: helper code, class declaration.
-
- lub.Autoload: autoloading classes in modules.
-
- lub.Dir: a simple directory traversal class.
-
- lub.Template: a simple templating class.
- ]],
- -- lub.Test: A simple yet powerful unit testing framework.
- homepage = "http://lubyk.org",
- license = "MIT"
-}
-dependencies = {
- "lua ~> 5.1",
- "luafilesystem >= 1.5.0",
-}
-build = {
- type = 'builtin',
- modules = {
- ['lub.Autoload'] = 'lub/Autoload.lua',
- ['lub.Dir'] = 'lub/Dir.lua',
- ['lub' ] = 'lub/init.lua',
- ['lub.Template'] = 'lub/Template.lua',
- },
-}
View
33 lub-1.0.2-1.rockspec
@@ -0,0 +1,33 @@
+package = "lub"
+version = "1.0.2-1"
+source = {
+ url = "http://lubyk.org/archive/lub-REL-1.0.2.tar.gz",
+ dir = 'lub-REL-1.0.2',
+}
+description = {
+ summary = "Lubyk base module.",
+ detailed = [[
+ lub: helper code, class declaration.
+
+ lub.Autoload: autoloading classes in modules.
+
+ lub.Dir: a simple directory traversal class.
+
+ lub.Template: a simple templating class.
+ ]],
+ homepage = "http://lubyk.org",
+ license = "MIT"
+}
+dependencies = {
+ "lua >= 5.1, < 5.3",
+ "luafilesystem >= 1.5.0",
+}
+build = {
+ type = 'builtin',
+ modules = {
+ ['lub' ] = 'lub/init.lua',
+ ['lub.Autoload' ] = 'lub/Autoload.lua',
+ ['lub.Dir' ] = 'lub/Dir.lua',
+ ['lub.Template' ] = 'lub/Template.lua',
+ },
+}
View
36 lub/Template.lua
@@ -29,6 +29,7 @@
--]]------------------------------------------------------
local lub = require 'lub'
local lib = lub.class 'lub.Template'
+local NO_FENV = not rawget(_G, 'setfenv')
local private = {}
-- Create a new template object ready to produce output by calling #run. The
@@ -45,12 +46,7 @@ function lib.new(source)
file:close()
end
setmetatable(self, lib)
- self.lua = private.parse(self, self.source)
- self.func, self.err = loadstring(self.lua)
- if self.err then
- print(self.err)
- assert(false, self.err)
- end
+ private.makeFunction(self, source)
return self
end
@@ -66,17 +62,37 @@ function lib:run(env)
buffer_ = buffer_ .. indent .. string.gsub(str, '\n', indent)
end
setmetatable(env, {__index = _G})
- setfenv(self.func, env)
- self.func()
+ local ok, err = pcall(function() self.func(env) end)
+ if not ok then
+ print(self.lua)
+ assert(false, err)
+ end
return buffer_
end
+
+function private:makeFunction(source)
+ local res = 'local function _fun_(env)\n'
+ if NO_FENV then
+ res = res..' local _ENV = env\n'
+ else
+ res = res..' setfenv(1, env)\n'
+ end
+ self.lua = res..private.parse(self, source)..'\nend\nreturn _fun_'
+ self.func, self.err = loadstring(self.lua)
+ if self.err then
+ print(self.lua)
+ assert(false, self.err)
+ end
+ -- We compile as a function so that we can pass 'env' as parameter.
+ self.func = self.func()
+end
-- (internal). Return Lua code from the template string. The generated code
-- outputs content by calling `env._out_` function.
function private:parse(source)
local res = ''
+
local eat_next_newline
- --for text, block in string.gmatch(tmpl, "([^{]-)(%b{})") do
-- Find balanced {
for text, block in string.gmatch(source .. '{{}}', '([^{]-)(%b{})') do
if text ~= '' then
@@ -110,7 +126,7 @@ function private:parse(source)
text = text .. '{'
block_text = private.parse(self, string.sub(block, 2, -1))
end
- if text then
+ if text and text ~= '' then
res = res .. string.format("_out_([=[%s]=])\n", text) .. block_text
else
res = res .. block_text
View
12 lub/init.lua
@@ -10,11 +10,11 @@ local gsub = string.gsub
local sub = string.sub
local match = string.match
local len = string.len
+local TAIL_CALL = rawget(_G, 'setfenv') and '%(tail call%)' or '%(%.%.%.tail calls%.%.%.%)'
local CALL_TO_NEW = {__call = function(lib, ...) return lib.new(...) end}
local lib = {}
-lub = lib
--[[------------------------------------------------------
@@ -28,9 +28,9 @@ lub = lib
-- + lfs: luafilesystem
local lfs = require 'lfs'
--- Current version for 'lub' module. Minor version numbers are never released
--- and are used during development.
-lib.VERSION = '1.0.0'
+-- Current version for 'lub' module. Odd minor version numbers are never
+-- released and are used during development.
+lib.VERSION = '1.0.2'
-- # Class management
--
@@ -112,7 +112,7 @@ function lib.path(path, level)
local chr = sub(path, 1, 1)
if chr == '|' or chr == '&' then
local src = debug.getinfo(level).source
- if src == '=(tail call)' then
+ if src:match(TAIL_CALL) then
src = debug.getinfo(level + 1).source
end
local s = match(src, '^@(.*)$')
@@ -456,7 +456,7 @@ end
function lib.log(...)
local trace = lib.split(debug.traceback(), '\n\t')
local part = trace[3]
- if part:match('%(tail call%)') then
+ if part:match(TAIL_CALL) then
part = trace[4]
end
local file, line = match(part, '^([^:]+):([^:]+):')
View
4 scripts/CMakeLists.txt.in
@@ -6,8 +6,10 @@ cmake_minimum_required ( VERSION 2.8 )
include ( cmake/dist.cmake )
include ( lua )
-install(DIRECTORY {{mod.type}}
+install (
+ DIRECTORY {{mod.type}}/
DESTINATION ${INSTALL_LMOD}/{{mod.type}}
+ COMPONENT Runtime
)
install_data ( README.md LICENSE )
View
4 scripts/dist.info.in
@@ -1,7 +1,7 @@
{% mod = require 'lub' %}
--- This file is part of Lubyk project
-name = "Lub"
+name = "{{mod.type}}"
version = "{{mod.VERSION}}"
desc = "Lubyk base module (autoload, template, helpers)"
@@ -11,6 +11,6 @@ url = "http://lubyk.org"
maintainer = "Gaspard Bucher"
depends = {
- "lua ~> 5.1",
+ "lua ~> 5.1",
"luafilesystem >= 1.5.0",
}
View
9 scripts/makedoc.lua
@@ -1,17 +1,16 @@
-local lub = require 'lub'
-lub.Doc.make {
+local lut = require 'lut'
+lut.Doc.make {
sources = {
'lub',
},
- head = '<meta name="google-site-verification" content="p1ZrKNheIo5xMhrMOo9MxKaY2hL9LlyuPYyRnEl2QuM" />',
target = 'doc',
format = 'html',
- header = [[ <a href='http://lubyk.org'><img alt='lubyk logo' src='img/lubyk.png'/></a> <h1><a href='http://doc.lubyk.org'>Lubyk documentation</a></h1></a> ]],
+ header = [[<h1><a href='http://doc.lubyk.org'>Lubyk documentation</a></h1></a> ]],
index = [=[
--[[--
# Lubyk documentation
- ## List of available modules in lubyk
+ ## List of available modules
--]]--
]=]
}
View
36 scripts/rockspec.in
@@ -1,37 +1,35 @@
{% mod = lub %}
-package = "Lub"
+package = "{{mod.type}}"
version = "{{mod.VERSION}}-1"
source = {
- url = "http://lubyk.org/archive/REL-{{mod.VERSION}}.tar.gz",
- dir = '{{mod.type}}-REL-{{mod.VERSION}}',
+ url = "http://lubyk.org/archive/{{mod.type}}-REL-{{mod.VERSION}}.tar.gz",
+ dir = '{{mod.type}}-REL-{{mod.VERSION}}',
}
description = {
- summary = "Lubyk base module.",
- detailed = [[
- lub: helper code, class declaration.
+ summary = "Lubyk base module.",
+ detailed = [[
+ lub: helper code, class declaration.
- lub.Autoload: autoloading classes in modules.
+ lub.Autoload: autoloading classes in modules.
- lub.Dir: a simple directory traversal class.
+ lub.Dir: a simple directory traversal class.
- lub.Template: a simple templating class.
- ]],
- -- lub.Test: A simple yet powerful unit testing framework.
- homepage = "http://lubyk.org",
- license = "MIT"
+ lub.Template: a simple templating class.
+ ]],
+ homepage = "http://lubyk.org",
+ license = "MIT"
}
dependencies = {
- "lua ~> 5.1",
- "luafilesystem >= 1.5.0",
+ "lua >= 5.1, < 5.3",
+ "luafilesystem >= 1.5.0",
}
build = {
type = 'builtin',
modules = {
+ {{string.format("[%-17s] = '%s/%s.lua'", "'"..mod.type.."'", mod.type, 'init')}},
{% for file in lfs.dir(mod.type) do %}
-{% if file == 'init.lua' then %}
- ['{{mod.type}}' ] = '{{mod.type}}/init.lua',
-{% elseif file:match('.lua$') then file = file:sub(1, -5) %}
- ['{{mod.type}}.{{file}}'] = '{{mod.type}}/{{file}}.lua',
+{% if file ~= 'init.lua' and file:match('.lua$') then file = file:sub(1, -5) %}
+ {{string.format("[%-17s] = '%s/%s.lua'", "'"..mod.type..'.'..file.."'", mod.type, file)}},
{% end %}
{% end %}
},
View
9 test/Dir_test.lua
@@ -1,13 +1,10 @@
--[[------------------------------------------------------
- lk.Dir test
- --------
-
- ...
+ # lub.Dir test
--]]------------------------------------------------------
-require 'lut'
-
+local lub = require 'lub'
+local lut = require 'lut'
local should = lut.Test 'lub.Dir'
function should.listFilesMatchingPattern()
View
6 test/Template_test.lua
@@ -1,10 +1,10 @@
--[[------------------------------------------------------
- lub.Template test
+ # lub.Template test
--]]------------------------------------------------------
-require 'lut'
--- Run the test with the lub directory as current path.
+local lub = require 'lub'
+local lut = require 'lut'
local should = lut.Test 'lub.Template'
--=============================================== TESTS
View
3  test/all.lua
@@ -1,4 +1,5 @@
-require 'lut'
+local lub = require 'lub'
+local lut = require 'lut'
lut.Test.files(lub.path '|')
View
8 test/lub_test.lua
@@ -1,4 +1,10 @@
-require 'lut'
+--[[------------------------------------------------------
+
+ # lub test
+
+--]]------------------------------------------------------
+local lub = require 'lub'
+local lut = require 'lut'
local should = lut.Test 'lub'
function should.readAll()
Something went wrong with that request. Please try again.