# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=ruby-rake-compiler
_gemname=${pkgname#ruby-}
pkgver=1.0.4
pkgrel=2
pkgdesc="Provide a standard and simplified way to build and package Ruby extensions"
url="https://github.com/rake-compiler/rake-compiler"
arch="noarch"
license="MIT"
depends="ruby ruby-rake"
checkdepends="ruby-rspec"
source="$pkgname-$pkgver.tar.gz::https://github.com/rake-compiler/$_gemname/archive/v$pkgver.tar.gz
	0001-extract-gemspec.patch
	gemfile-remove-unwanted-files.patch"
builddir="$srcdir/$_gemname-$pkgver"

build() {
	cd "$builddir"
	gem build $_gemname.gemspec
}

check() {
	cd "$builddir"
	rspec spec
}

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

	cd "$builddir"

	gem install --local \
		--install-dir "$gemdir" \
		--bindir "$pkgdir/usr/bin" \
		--ignore-dependencies \
		--no-document \
		--verbose \
		$_gemname

	# Remove unnecessary files and empty directories.
	cd "$gemdir"
	rm -r cache build_info doc
}

sha512sums="fc015d8f6dcc2ba380dbc3eb2959b068f3582e0efcdc765570f5b2c97737db2ba38fb324b9b5bb63d3af822843139561a36758408db637e7716afb3a6074251c  ruby-rake-compiler-1.0.4.tar.gz
ea218d90f5651bdf46a96eaca2bc34f27ace9ff22752f5ce6ad9bb0d8bede110b212f797f1accd1fa3bd76ee093003269d8fcfc1490124bfa54785e92443a1dc  0001-extract-gemspec.patch
e68672541d62898bc72fb7e40f16bc75ed1d46eabedd18da60a6f0673d67bf63d990e191fb41d6034e3f6361662807030cbd8f0c817223a5d03c46a3a664f855  gemfile-remove-unwanted-files.patch"
