# Maintainer: Will Sinatra <wpsinatra@gmail.com>
pkgname=ruby-json
_gemname=${pkgname#ruby-}
pkgver=2.7.2
pkgrel=0
pkgdesc="This is a JSON implementation as a Ruby extension in C."
url="https://rubygems.org/gems/json"
arch="all"
license="RUBY"
makedepends="ruby-dev"
checkdepends="ruby-rake ruby-test-unit ruby-test-unit-ruby-core"
depends="ruby"
source="$pkgname-$pkgver.tar.gz::https://github.com/flori/json/archive/refs/tags/v$pkgver.tar.gz"
builddir="$srcdir/$_gemname-$pkgver"

prepare() {
	default_prepare

	sed -i '/spec.signing_key/d' $_gemname.gemspec
}

build() {
	gem build $_gemname.gemspec
}

check() {
	rake test
}

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

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

	find "$gemdir"/extensions/ -name mkmf.log -delete
	rm -r "$gemdir"/cache \
		"$gemdir"/build_info \
		"$gemdir"/doc \
		"$geminstdir"/ext \
		"$geminstdir"/*.md
}

sha512sums="
5c432c293eed69b9810b5d0ca782383ba3f206d561641c354515e357c663ed4a4fb5ae35d3336d48605f9e82156d2f14a7ec6fa26642351214f60d91bac84f0e  ruby-json-2.7.2.tar.gz
"
