# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
# TODO: Fix to not compile .so lib twice (in build and test).
pkgname=ruby-escape_utils
_gemname=${pkgname#ruby-}
pkgver=1.3.0
pkgrel=2
pkgdesc="Faster string escaping routines for your Ruby apps"
url="https://github.com/brianmario/escape_utils"
arch="all"
license="MIT"
makedepends="ruby-dev"
checkdepends="
	ruby
	ruby-activesupport
	ruby-minitest
	ruby-rake-compiler
	"
source="$pkgname-$pkgver.tar.gz::https://github.com/brianmario/escape_utils/archive/v$pkgver.tar.gz
	gemspec.patch
	test-without-actionview.patch
	"
builddir="$srcdir/$_gemname-$pkgver"

prepare() {
	default_prepare

	sed -i '/require .bundler/d' Rakefile

	# Requires gem activeview which we don't have in aports yet.
	rm -rf test/javascript
}

build() {
	gem build $_gemname.gemspec
	gem install --local \
		--install-dir dist \
		--ignore-dependencies \
		--no-document \
		--verbose \
		$_gemname
}

check() {
	rake test
}

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

	mkdir -p "$gemdir"
	cp -r extensions gems specifications "$gemdir"/

	# Remove unnecessary files.
	rm -r "$gemdir"/gems/$_gemname-$pkgver/ext
}

sha512sums="
6d492192ffdf1309366ae545d2c282f7d10d6618a4a0a4b5148a4c2a62d8f9dbd5e821dc04e0a12bec5ad4e2bb11fab60b26592c35f9d1d2f046163db2c27957  ruby-escape_utils-1.3.0.tar.gz
fd5ef02273b3aa93d18a3d1c86f6d9c47163f9adf5ca236eef3fe556c2ba84d5ada15ae2a37f121a6e273aa39bbdcdb47bcfa5d5bcac6dd80a84e0b279c91825  gemspec.patch
1add3df7b4f8c9acb56a9c76407ef1d25a127bf24ed167d65a0c167068d0bf7bdec699c413f03963e6b617404fa10c5ec6e82a7c6d784c5e5a8b1bc16fd54252  test-without-actionview.patch
"
