# Contributor: Carlo Landmeter <clandmeter@gmail.com>
# Maintainer: Carlo Landmeter <clandmeter@gmail.com>
pkgname=lua-inspect
_rockname=inspect
_pkgname=inspect.lua
pkgver=3.1.0
pkgrel=1
pkgdesc="Human-readable representation of Lua tables"
url="https://github.com/kikito/inspect.lua"
arch="noarch"
license="MIT"
depends=""
makedepends=""
subpackages="$pkgname-doc"
source="$pkgname-$pkgver.tar.gz::https://github.com/kikito/$_pkgname/archive/v$pkgver.tar.gz"
builddir="$srcdir/$_pkgname-$pkgver"

_luaversions="5.1 5.2 5.3"
for _v in $_luaversions; do
	subpackages="$subpackages lua$_v-${pkgname#lua-}:_package"
done

package() {
	cd "$builddir"

	install -Dm644 README.md \
		"${pkgdir}/usr/share/doc/${pkgname}/README.md"
	install -Dm644 MIT-LICENSE.txt \
		"${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
}

_package() {
	local lver="${subpkgname:3:3}"
	pkgdesc="$pkgdesc (for Lua $lver)"
	depends="lua$lver"
	install_if="$pkgname=$pkgver-r$pkgrel lua$lver"
	local rockdir="$subpkgdir/usr/lib/luarocks/rocks-$lver/$_rockname/$pkgver-1"

	install -Dm644 "$builddir"/inspect.lua \
		"$subpkgdir"/usr/share/lua/$lver/inspect.lua

	mkdir -p "$rockdir"
	echo 'rock_manifest = {}' > "$rockdir"/rock_manifest
}

md5sums="d8aa2fb827c5ac91ea31a267a65a5f93  lua-inspect-3.1.0.tar.gz"
sha256sums="ce31e30c423d86b1039bef8f30ab801ebbd9fa8721dbc982f60b6f460a76fbbc  lua-inspect-3.1.0.tar.gz"
sha512sums="77ed06d81d8c4e407915bac6b8b0ca7535ef721dff6ef9d7ca5a76c0f10363aa9700fd40a5fa21745b68bc42d06788217d4a24d629c29f4b16a60e653b1471e5  lua-inspect-3.1.0.tar.gz"
