# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=ruby-pygments
_gemname=pygments.rb
pkgver=1.2.1
pkgrel=1
pkgdesc="Pygments syntax highlighting in Ruby"
url="https://github.com/tmm1/pygments.rb"
arch="noarch"
license="MIT"
depends="python2 py2-pygments ruby ruby-json ruby-multi_json"
checkdepends="ruby-test-unit"
makedepends="ruby-bundler ruby-rake"
source="$pkgname-$pkgver.tar.gz::https://github.com/tmm1/$_gemname/archive/v$pkgver.tar.gz
	use-system-pygments-only.patch
	fix-rakefile.patch"
builddir="$srcdir/$_gemname-$pkgver"

prepare() {
	default_prepare

	cd "$builddir"

	# Specify files to be installed.
	sed -i 's|`git ls-files.*|Dir["lib/**/*", "lexers"]|' $_gemname.gemspec

	# Remove bundled dependencies.
	rm -r vendor
}

build() {
	cd "$builddir"

	rake lexers
	gem build $_gemname.gemspec
}

check() {
	cd "$builddir"
	rake test
}

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

	cd "$builddir"
	gem install --local \
		--install-dir "$gemdir" \
		--ignore-dependencies \
		--no-document \
		--verbose \
		$_gemname-$pkgver.gem
}

sha512sums="370cd762cfcd14884f14bdf7e9c891507da155eb37eb0004ce31c9ea1030110d8e32642cf1a2c1eb254629a27f7f38f9a2a6c41133f13655024d2741bff6c5f4  ruby-pygments-1.2.1.tar.gz
a8e5d64d8209dacb5090378e8507095359b38ef55ac6896f5bd95fa9676691beb278d6d19eb47cbc51fac843b326b8e21fbf1dd9ed39e123ed0943293b0a82ca  use-system-pygments-only.patch
18174eb21397dca7213d55c1d0af5eebba25c974aa60ff7142aa045f591b23099cc4e221be87bca1c96ea61f97a45fb9714166ea858ab36b6cc04643bf88577e  fix-rakefile.patch"
