Merge pull request #36 from retroverse/master
[luajson.git] / util / createRock.lua
blob63f0e8b7c558f9532e5b9fb4395f22494372e013
1 local io = require("io")
3 local version = assert((...), "Requires rock version on command-line")
5 local template = [=[
6 package = "luajson"
7 version = %VERSION%
8 source = {
9 url = "git://github.com/harningt/luajson.git",
10 tag = %TAG_VERSION%
12 description = {
13 summary = "customizable JSON decoder/encoder",
14 detailed = [[
15 LuaJSON is a customizable JSON decoder/encoder using
16 LPEG for parsing.
17 ]],
18 homepage = "http://github.com/harningt/luajson",
19 maintainer = "Thomas Harning <harningt@gmail.com>",
20 license = "MIT/X11"
22 dependencies = {
23 "lua >= 5.1",
24 "lpeg >= 0.8.1"
26 build = {
27 type = "module",
28 modules = {
29 %MODULES%
32 ]=]
34 local in_modules = io.popen("find lua -type f -name '*.lua' -not -iname '.*' | sort", "r")
35 local modules = in_modules:read("*a")
36 in_modules:close()
38 modules = modules:gsub("lua/([^\n]*)%.lua", function(module)
39 return "\t\t[" .. ("%q"):format(module:gsub("/",".")) .. "] = " .. ("%q"):format("lua/" .. module .. ".lua") .. ","
40 end)
41 tag_version = version:match("^(.*)[-]")
42 local out = template:gsub("%%(.-)%%", {
43 VERSION = ("%q"):format(version),
44 TAG_VERSION = ("%q"):format(tag_version),
45 MODULES = modules
47 print(out)