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