# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=ruby-polyglot
_gemname=polyglot
pkgver=0.3.5
pkgrel=3
pkgdesc="Augment 'require' to load non-ruby file types"
url="https://github.com/cjheath/polyglot"
arch="noarch"
license="MIT"
depends="ruby"
source="https://github.com/cjheath/polyglot/archive/v$pkgver/ruby-polyglot-$pkgver.tar.gz
	https://rubygems.org/downloads/$_gemname-$pkgver.gem
	"
builddir="$srcdir/$_gemname-$pkgver"
options="!check"  # no tests provided

prepare() {
	default_prepare

	# Generate gemspec (there's no gemspec in the source).
	gem specification -l --ruby "$srcdir"/$_gemname-$pkgver.gem \
		> "$builddir"/$_gemname.gemspec
}

build() {
	gem build $_gemname.gemspec
}

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

	# Remove unnecessary files and rubbish...
	cd "$gemdir"
	rm -r cache build_info doc extensions plugins

	cd "$geminstdir"
	rm -f ./*.txt Rakefile
}

sha512sums="
88ba0e4779ae2180271c9b51354b608352d9ae13cd16e17416412bf509dfd7fb1c748a10f00e7a5c00e3b4c7ca1ac78160deb91b5fae43caa19d7a872cd32c15  ruby-polyglot-0.3.5.tar.gz
405790c8edf5a98010334a62f7efeddd60f6dcff91ad5ff599579be3201a7e1b359787da59523a612fed5ccf8385116865316fa8872f0350e33dc078410a54cf  polyglot-0.3.5.gem
"
