# Maintainer: Antoine Martin (ayakael) <dev@ayakael.net>
# Contributor: Antoine Martin (ayakael) <dev@ayakael.net>
# Contributor: omni <omni+alpine@hack.org>
# Contributor: Jakub Jirutka <jakub@jirutka.cz>

pkgname=ruby3.0-webrick
_gemname=webrick
pkgver=1.7.0
pkgrel=1
pkgdesc="HTTP server toolkit for Ruby"
url="https://github.com/ruby/webrick"
arch="noarch"
license="BSD-2-Clause"
depends="ruby3.0"
checkdepends="ruby3.0-rake ruby3.0-test-unit"
makedepends="ruby3.0-rdoc"
subpackages="$pkgname-doc"
source="https://github.com/ruby/webrick/archive/v$pkgver/ruby-webrick-$pkgver.tar.gz
	gemspec.patch
	"
builddir="$srcdir/$_gemname-$pkgver"

prepare() {
	default_prepare
	sed -i '/require .bundler/d' Rakefile
}

build() {
	gem build $_gemname.gemspec
}

check() {
	rake test
}

package() {
	local gemdir="$pkgdir/$(ruby -e 'puts Gem.default_dir')"

	gem install \
		--local \
		--install-dir "$gemdir" \
		--ignore-dependencies \
		--document ri \
		--verbose \
		$_gemname

	# Remove unnessecary files
	cd "$gemdir"
	rm -rf build_info cache extensions plugins
}

doc() {
	pkgdesc="$pkgdesc (ri docs)"

	amove "$(ruby -e 'puts Gem.default_dir')"/doc
}

sha512sums="
785e8c6af6e2f8ac497bab6d0ad0e9383fa4c4ac8dee6ceee38e20c5e9b631b805ec3c8f5438ebea651ee4113698de1a370ae506927bdc04e512ea6cac433cd1  ruby-webrick-1.7.0.tar.gz
ddfd7ec0b7b4c7b2dea9d3ed45f8a8353bbbb7c61f5c11a9c52116402fcba8626a446dcf18b9fee1ac9a267ccc3b534a1dbd113d02959e612f034b15b47a786e  gemspec.patch
"
