# Maintainer: George Rawlinson <grawlinson@archlinux.org>

_gemname=unicode-display_width
pkgname=ruby-$_gemname
pkgver=2.1.0
pkgrel=1
pkgdesc="Determines the monospace display width of a string in Ruby"
arch=('any')
url="https://github.com/janlelis/unicode-display_width"
license=('MIT')
depends=('ruby')
makedepends=('ruby-rdoc')
options=('!emptydirs')
source=("https://rubygems.org/downloads/$_gemname-$pkgver.gem")
noextract=("$_gemname-$pkgver.gem")
b2sums=('5352c8ca774925a9022521d17a7f318b888353d6da7b2d93a7f787d31fb7cb82282a5aec33b6b36b401477e47bb7be2be5e15d2951a41f1a44b0d7fa5830f8da')

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

  gem install \
    --verbose \
    --ignore-dependencies \
    --no-user-install \
    --install-dir "$pkgdir/$_gemdir" \
    --bindir "$pkgdir/usr/bin" \
    "$_gemname-$pkgver.gem"

  # delete cache
  cd "$pkgdir/$_gemdir"
  rm -vrf cache

  cd "gems/$_gemname-$pkgver"

  # move documentation
  install -vd "$pkgdir/usr/share/doc/$pkgname"
  mv -vt "$pkgdir/usr/share/doc/$pkgname" *.md

  # move license
  install -vd "$pkgdir/usr/share/licenses/$pkgname"
  mv -vt "$pkgdir/usr/share/licenses/$pkgname" MIT-LICENSE.txt
}