# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=ruby-addressable
_gemname=addressable
pkgver=2.8.6
pkgrel=1
pkgdesc="An alternative implementation to the URI implementation"
url="https://github.com/sporkmonger/addressable"
arch="noarch"
license="Apache-2.0"
depends="ruby ruby-public_suffix"
checkdepends="ruby-rspec"
source="https://github.com/sporkmonger/addressable/archive/$_gemname-$pkgver.tar.gz"
builddir="$srcdir/$_gemname-$_gemname-$pkgver"
options="!check"  # FIXME: tests require gem rspec-its which we don't have yet

# secfixes:
#   2.8.0-r0:
#     - CVE-2021-32740

prepare() {
	default_prepare

	# Bundler is not necessary.
	sed -i '/require .bundler\/setup/d' spec/spec_helper.rb
}

build() {
	gem build $_gemname.gemspec
}

check() {
	rspec .
}

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

	cd "$geminstdir"
	rm -rf spec tasks test LICENSE* Gemfile Rakefile ./*.md
}

sha512sums="
62f656e74a4ccb2ce3b6dc163bd97d6cc478342d088dafb7fe22607352c6d8408d421300b34faaa1f6c5a0d6aedd991c3aead5f6db79e24aad18028c229e1ed9  addressable-2.8.6.tar.gz
"
