summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@digital-scurf.org>2016-06-17 13:14:30 +0100
committerDaniel Silverstone <dsilvers@digital-scurf.org>2016-06-17 13:14:30 +0100
commit4910b68f03bf329eefa21b27277d54d3a0646e8a (patch)
treee134e77919745cc8c5b41aad458c8c0754e30b25
parent26c9c390d2fd6e2527051f66091c70b52d590ecb (diff)
downloadtongue-4910b68f03bf329eefa21b27277d54d3a0646e8a.tar.bz2
Initial bits for Tongue
-rw-r--r--Makefile50
-rw-r--r--README4
-rw-r--r--config.ld6
-rw-r--r--lib/tongue.lua23
-rw-r--r--test/test-tongue.lua60
5 files changed, 141 insertions, 2 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..de7da60
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,50 @@
+all: test doc
+
+MODULES := tongue
+LUA_VER := 5.1
+
+PREFIX ?= /usr/local
+
+INST_BASE := $(PREFIX)
+INST_ROOT := $(DESTDIR)$(INST_BASE)/share/lua/$(LUA_VER)
+
+MOD_FILES := $(patsubst %,%.lua,$(subst .,/,$(MODULES)))
+
+install:
+ mkdir -p $(INST_ROOT)/tongue
+ for MOD in $(sort $(MOD_FILES)); do \
+ cp lib/$${MOD} $(INST_ROOT)/$${MOD}; \
+ done
+
+LUA := LUA_PATH="$(shell pwd)/lib/?.lua;$(shell pwd)/extras/luacov/src/?.lua;;" lua$(LUA_VER)
+
+clean:
+ $(RM) luacov.report.out luacov.stats.out
+ $(RM) -r html
+
+distclean: clean
+ find . -name "*~" -delete
+
+.PHONY: example
+example:
+ $(LUA) example/tongue-example.lua
+
+.PHONY: test
+test:
+ @$(RM) luacov.stats.out
+ @ERR=0; \
+ for MOD in $(sort $(MODULES)); do \
+ echo -n "$${MOD}: "; \
+ $(LUA) test/test-$${MOD}.lua; \
+ test "x$$?" = "x0" || ERR=1; \
+ done; \
+ $(LUA) extras/luacov/src/bin/luacov -X luacov. -X test. $(MODULES); \
+ exit $$ERR
+
+.PHONY: interactive
+interactive:
+ $(LUA) -e'tongue=require"tongue"' -i
+
+doc:
+ @echo "Running LDoc"
+ @ldoc .
diff --git a/README b/README
index 703025b..871f6a5 100644
--- a/README
+++ b/README
@@ -11,5 +11,5 @@ http://git.gitano.org.uk/ -- Enjoy them.
## Dependencies
-Tongue at this time does not have any dependencies outside of stock Lua and
-should work with Lua 5.1, 5.2, and 5.3
+Tongue depends on lua-iconv and should work with Lua 5.1, 5.2, and 5.3.
+
diff --git a/config.ld b/config.ld
new file mode 100644
index 0000000..2f8273b
--- /dev/null
+++ b/config.ld
@@ -0,0 +1,6 @@
+file = {"lib"}
+readme = "README"
+format = "lua-markdown"
+project = "Tongue"
+title = "Tongue - Lua 18N Library"
+dir = "html"
diff --git a/lib/tongue.lua b/lib/tongue.lua
new file mode 100644
index 0000000..9f71be7
--- /dev/null
+++ b/lib/tongue.lua
@@ -0,0 +1,23 @@
+-- lib/tongue.lua
+--
+-- Lua I18N library 'Tongue'
+--
+-- Copyright 2016 Daniel Silverstone <dsilvers@digital-scurf.org>
+--
+-- For licence terms, see COPYING
+--
+
+--- Lua I18N library - Tongue
+--
+
+local _VERSION = 1
+local _ABI = 1
+
+local VERSION = "Tongue Version " .. tostring(_VERSION)
+
+return {
+ _VERSION = _VERSION,
+ VERSION = VERSION,
+ _ABI = _ABI,
+ ABI = ABI,
+}
diff --git a/test/test-tongue.lua b/test/test-tongue.lua
new file mode 100644
index 0000000..1f499d1
--- /dev/null
+++ b/test/test-tongue.lua
@@ -0,0 +1,60 @@
+-- test/test-tongue.lua
+--
+-- Lua I18N library 'Tongue' -- Tests for the core Tongue module
+--
+-- Copyright 2012 Daniel Silverstone <dsilvers@digital-scurf.org>
+--
+-- For Licence terms, see COPYING
+--
+
+-- Step one, start coverage
+
+pcall(require, 'luacov')
+
+local tongue = require 'tongue'
+
+local testnames = {}
+
+local real_assert = assert
+local total_asserts = 0
+local function assert(...)
+ local retval = real_assert(...)
+ total_asserts = total_asserts + 1
+ return retval
+end
+
+local function add_test(suite, name, value)
+ rawset(suite, name, value)
+ testnames[#testnames+1] = name
+end
+
+local suite = setmetatable({}, {__newindex = add_test})
+
+
+function suite.version_present()
+ assert(tongue._VERSION, "Version number is missing")
+end
+
+function suite.abi_present()
+ assert(tongue._ABI, "ABI number is missing")
+end
+
+function suite.version_string_present()
+ assert(tongue.VERSION, "Version string is missing")
+end
+
+local count_ok = 0
+for _, testname in ipairs(testnames) do
+-- print("Run: " .. testname)
+ local ok, err = xpcall(suite[testname], debug.traceback)
+ if not ok then
+ print(err)
+ print()
+ else
+ count_ok = count_ok + 1
+ end
+end
+
+print(tostring(count_ok) .. "/" .. tostring(#testnames) .. " [" .. tostring(total_asserts) .. "] OK")
+
+os.exit(count_ok == #testnames and 0 or 1)