# POWER Maintainer: Alexander Baldeck <alex.bldck@gmail.com>
# Maintainer: Tim Meusel <tim@bastelfreak.de>
# Contributor: Felix Yan <felixonmars@archlinux.org>
# Contributor: Anatol Pomozov <anatol.pomozov@gmail.com>
# Contributor: Alfredo Palhares <masterkorp@masterkorp.net>
# Contributor: Jochen Schalanda <jochen+aur@schalanda.name>

_gemname=power_assert
pkgname="ruby-${_gemname}"
pkgver=2.0.3
pkgrel=5
pkgdesc='Power Assert for Ruby'
arch=(any)
url="https://github.com/ruby/${_gemname}"
license=('custom:BSDL')
depends=('ruby')
makedepends=('ruby-rdoc' 'ruby-rake')
checkdepends=('ruby-test-unit' 'ruby-irb')
options=('!emptydirs')
source=("${url}/archive/refs/tags/v${pkgver}/${pkgname}-${pkgver}.tar.gz")
sha512sums=('f5658d18b3b78e7757ddfc1ccdabc011076c009a7343eaad2748ca7aeb4d112bf19c70621cb938e7dcf1582c8bb7c5512017885ea51503b3ed274980b7d7c0b1')

prepare() {
  cd "${_gemname}-${pkgver}"
  sed --in-place 's|`git ls-files -z`|`find . -print0`|' "${_gemname}.gemspec"
  sed --in-place '/bundler/d' Rakefile
}

build() {
  cd "${_gemname}-${pkgver}"
  gem build "${_gemname}.gemspec"
}

check() {
  cd "${_gemname}-${pkgver}"
  rake test
}

package() {
  cd "${_gemname}-${pkgver}"
  local _gemdir="$(gem env gemdir)"
  gem install --verbose --ignore-dependencies --no-user-install --install-dir "${pkgdir}/${_gemdir}" --bindir "${pkgdir}/usr/bin" "${_gemname}-${pkgver}.gem"

  rm -rf "${pkgdir}/${_gemdir}/cache"
  rm -rf "${pkgdir}/${_gemdir}/gems/${_gemname}-${pkgver}/.github"

  install -Dm 644 README.md  -t "${pkgdir}/usr/share/doc/${pkgname}"
  install -Dm 644 BSDL COPYING LEGAL -t "${pkgdir}/usr/share/licenses/${pkgname}"
}

# vim: ts=2 sw=2 et:
