# POWER Maintainer: Alexander Baldeck <alex.bldck@gmail.com>
# Maintainer: Anatol Pomozov <anatol.pomozov@gmail.com>
# Contributor: Massimiliano Torromeo <massimiliano.torromeo at gmail dot com>
# Contributor: Alexsandr Pavlov <kidoz at mail dot ru>
# Contributor: Andreas 'Segaja' Schleifer <segaja at archlinux dot org>

_gemname=rdiscount
pkgname=ruby-$_gemname
pkgver=2.2.7.3
pkgrel=2.1
pkgdesc="Fast Implementation of Gruber's Markdown in C"
arch=(x86_64 powerpc64le powerpc64 powerpc riscv64)
url='https://dafoster.net/projects/rdiscount/'
license=(BSD)
depends=(ruby)
makedepends=('ruby-rdoc')
options=(!emptydirs)
source=(https://rubygems.org/downloads/$_gemname-$pkgver.gem)
noextract=($_gemname-$pkgver.gem)
sha256sums=('8a4844f930916fc7215dc369932626be85f2da13cdf48185b836055b63126113')

package() {
  local _gemdir="$(ruby -e'puts Gem.default_dir')"
  local _platform="$(gem env platform | cut -d':' -f2)"
  local _extension_api_version="$(ruby -e'puts Gem.extension_api_version')"
  gem install --ignore-dependencies --no-user-install -i "$pkgdir/$_gemdir" -n "$pkgdir/usr/bin" $_gemname-$pkgver.gem
  rm "$pkgdir/$_gemdir/cache/$_gemname-$pkgver.gem" \
      "${pkgdir}/${_gemdir}/extensions/${_platform}/${_extension_api_version}/${_gemname}-${pkgver}/gem_make.out"
  install -D -m644 "$pkgdir/$_gemdir/gems/$_gemname-$pkgver/COPYING" "$pkgdir/usr/share/licenses/$pkgname/COPYING"

  rm -rf "$pkgdir/$_gemdir/gems/$_gemname-$pkgver/ext" \
      "${pkgdir}/${_gemdir}/doc/${_gemname}-${pkgver}/ri/ext"
}
