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

_gemname=shellany
pkgname=ruby-$_gemname
pkgver=0.0.1
pkgrel=1
pkgdesc="Simple, somewhat portable command capturing"
arch=('any')
url="https://github.com/guard/shellany"
license=('MIT')
depends=('ruby')
makedepends=('ruby-rdoc')
options=('!emptydirs')
source=("https://rubygems.org/downloads/$_gemname-$pkgver.gem")
noextract=("$_gemname-$pkgver.gem")
b2sums=('8c975a888f1c8ab829d29855594dbfeb7699509fae7c17fbe0b799365e8fc6e1d0728ccca1abc732cd9bde06822683ab347d6c090bc5c299ac32f2ca7db0d506')

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

  # delete unnecessary files & folders
  cd "gems/$_gemname-$pkgver"
  find . -type f -name ".*" -delete
  rm -vrf "$_gemname.gemspec" spec Gemfile Rakefile

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

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