# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=ruby-net-ping
_gemname=net-ping
pkgver=2.0.8
pkgrel=4
pkgdesc="Collection of classes that provide different ways to ping computers"
url="https://github.com/eitoball/net-ping"
arch="noarch"
license="Artistic-2.0"
depends="ruby ruby-cap2"
checkdepends="ruby-bundler ruby-rake ruby-test-unit"
source="https://github.com/eitoball/net-ping/archive/net-ping-$pkgver.tar.gz
	gemspec.patch
	"
builddir="$srcdir/$_gemname-$_gemname-$pkgver"
options="!check"  # tests seems to be broken

build() {
	gem build $_gemname.gemspec
}

check() {
	# TODO: Install from aports after we create aport for fakeweb.
	export GEM_HOME="$(pwd)/.gems"
	bundle install

	"$GEM_HOME"/bin/rake test
}

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

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

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

sha512sums="
f4c3c84e82345a4be9218ae9f71796a992bf66ee21562778c51d6b10bda93489008bd56b4f6d2c3b623cd3f9af0c5d47e57fd5e96994604ead825477783558b0  net-ping-2.0.8.tar.gz
a0cb310704e397d2d65538ba7ebc6a932241441fb75ab55c378ce3e3dec476b64bfe3cca83c82015864273272d7f23c0dc0e87c9113f81999fe8f513e23de853  gemspec.patch
"
