# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=ruby-listen
_gemname=listen
pkgver=3.9.0
pkgrel=0
pkgdesc="Listens to file modifications and notifies you about the changes"
url="https://github.com/guard/listen"
arch="noarch"
license="MIT"
depends="ruby ruby-rb-inotify"
checkdepends="ruby-rspec"
source="https://github.com/guard/listen/archive/v$pkgver/$_gemname-$pkgver.tar.gz
	tests-remove-unnecessary-requires.patch
	gemspec.patch
	"
builddir="$srcdir/$_gemname-$pkgver"

prepare() {
	default_prepare

	# macOS-only
	rm spec/lib/listen/adapter/darwin_spec.rb

	# CLI requires gem 'thor'
	rm spec/lib/listen/cli_spec.rb
}

build() {
	gem build $_gemname.gemspec
}

check() {
	rspec .
}

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 rubbish...
	# bin/listen requires extra dependency (thor)
	cd "$gemdir"
	rm -r bin cache build_info doc extensions
}

sha512sums="
abec4720db6331da5b3d7ea998a9e2cc77e55ad4919b473c0172f6e852dcb376671379b79cad88fb5a850cd2ba2178d36a3bd2534cd81408186805497d58238f  listen-3.9.0.tar.gz
b9e8589d6695c79060fa6122a54410bb4fc70e76cc93d745cac3ccf40b28600001cd9f39dbc47b52fe19bc9c69f15f95933d51caed263e1255c0b2097d05acd8  tests-remove-unnecessary-requires.patch
07a9d8825c7400db88a1911f39348f51c0132bbbea04c8a029dd86519f013def966c1dd25f352e5b4533e413c569782ae6dfd0ea3fb683b25fcfbf89fd50ae4a  gemspec.patch
"
