Skip to content
This repository was archived by the owner on Apr 27, 2023. It is now read-only.

Commit 46085c3

Browse files
committed
Merge pull request #9 from endel/luarocks
Return public struct interface. add rockspec and publish script.
2 parents 9473847 + ab71d49 commit 46085c3

File tree

3 files changed

+72
-2
lines changed

3 files changed

+72
-2
lines changed

lua-struct.rockspec

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package = "lua-struct"
2+
version = "@VERSION@-@REVISION@"
3+
4+
source = {
5+
url = "git://github.com/iryont/lua-struct.git"
6+
}
7+
8+
description = {
9+
summary = "Implementation of binary packing/unpacking in pure lua",
10+
detailed = [[
11+
Implementation of binary packing/unpacking in pure lua
12+
You can use it to pack and unpack binary data in pure lua. The idea is very similar to PHP unpack and pack functions."
13+
]],
14+
homepage = "https://github.com/iryont/lua-struct",
15+
license = "MIT/X11"
16+
}
17+
18+
dependencies = {}
19+
20+
build = {
21+
type = 'none',
22+
install = {
23+
lua = {
24+
['struct'] = 'struct.lua'
25+
}
26+
}
27+
}

publish

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# version=$(git tag -l | tail -1)
2+
3+
version="1.0.0"
4+
rev="1" # rev="1"
5+
6+
name="lua-struct-$version-$rev"
7+
8+
tmp="$TEMPDIR"
9+
if [ -z "$tmp" ]; then
10+
tmp="$HOME"
11+
fi
12+
13+
src="$(cd "$(dirname $0)" && pwd)"
14+
15+
cd $tmp
16+
rm -f "$name"
17+
ln -sf "$src" "$name"
18+
19+
echo "Creating $tmp/$name.src.rock"
20+
tar -czvpf "$name.src.rock" \
21+
--dereference \
22+
--exclude "$name/.git*" \
23+
--exclude "$name/*.o" \
24+
--exclude "$name/*.so" \
25+
--exclude "$name/lua-struct.rockspec" \
26+
--exclude "$name/rockspecs" \
27+
--exclude "$name/server" \
28+
--exclude "$name/coronasdk-example" \
29+
--exclude "$name/example" \
30+
--exclude "$name/*~" \
31+
--exclude "$name/.DS_Store" \
32+
--exclude "$name/publish" \
33+
--exclude "$name/$(basename $0)" \
34+
"$name"
35+
36+
echo "Creating $tmp/$name.rockspec"
37+
cat "$src/lua-struct.rockspec" | \
38+
sed \
39+
-e s/@VERSION@/$version/ \
40+
-e s/@REVISION@/$rev/ > \
41+
"$name.rockspec"

struct.lua

+4-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ function struct.pack(format, ...)
3030
local sign = 0
3131

3232
if val < 0 then
33-
sign = 1
34-
val = -val
33+
sign = 1
34+
val = -val
3535
end
3636

3737
local mantissa, exponent = math.frexp(val)
@@ -167,3 +167,5 @@ function struct.unpack(format, stream)
167167

168168
return unpack(vars)
169169
end
170+
171+
return struct

0 commit comments

Comments
 (0)