# Contributor: Celeste <cielesti@protonmail.com>
# Maintainer: Celeste <cielesti@protonmail.com>
pkgname=emacs-request
pkgver=0.3.2_git20230126
_gitrev=01e338c335c07e4407239619e57361944a82cb8a
pkgrel=0
_pkgreal=request
pkgdesc="Easy HTTP request library"
url="https://github.com/tkf/emacs-request"
arch="noarch"
license="GPL-3.0-or-later"
depends="cmd:emacs"
makedepends="
	emacs-deferred
	emacs-nox
	"
checkdepends="
	curl
	py3-flask
	py3-tornado
	"
options="!check" # fragile tests run a local HTTP server written in Python
subpackages="$pkgname-deferred"
source="https://github.com/tkf/emacs-request/archive/$_gitrev/emacs-request-$_gitrev.tar.gz"
builddir="$srcdir/$pkgname-$_gitrev"

build() {
	emacs -batch -q -no-site-file -L . \
		-eval '(setq byte-compile-error-on-warn t)' \
		-f batch-byte-compile \
		./*.el
}

check() {
	emacs -batch -q -no-site-file -L . -L tests \
		-l test-request -f ert-run-tests-batch-and-exit
}

package() {
	install -Dvm644 ./*.el ./*.elc \
		-t "$pkgdir"/usr/share/emacs/site-lisp/

	cd "$pkgdir"/usr/share/emacs/site-lisp
	emacs -batch -q -no-site-file \
		-eval "(loaddefs-generate \".\" \"$_pkgreal-loaddefs.el\")"
}

deferred() {
	pkgdesc="$pkgdesc returning deferred object"
	depends="$pkgname=$pkgver-r$pkgrel emacs-deferred"

	amove usr/share/emacs/site-lisp/request-deferred.el*
}

sha512sums="
6ba0e28278f02033173ef58942c4b85b69b3d530bf10ff903c872d37eceafec8b1c6b081cd8dec84e48a2a60b38b67ffae6ef8c881b22e67c6f9fbeacd583844  emacs-request-01e338c335c07e4407239619e57361944a82cb8a.tar.gz
"
