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

_gemname=ice_nine
pkgname=ruby-$_gemname
pkgver=0.11.2
pkgrel=1
pkgdesc="Deep freeze Ruby objects"
arch=('any')
url="https://github.com/dkubb/ice_nine"
license=('MIT')
depends=('ruby')
makedepends=('ruby-rdoc')
options=('!emptydirs')
source=("https://rubygems.org/downloads/$_gemname-$pkgver.gem")
noextract=("$_gemname-$pkgver.gem")
b2sums=('d70aee3ba5d82719936e355bacd0c157fae262abb494c8d584e8530928218fb3c8a736e15903cdef2acd421fa5d08eafda11a0544651389e8b4b791299f1afca')

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 spec config benchmarks config \
    "$_gemname.gemspec" Gemfile* Rakefile Guardfile TODO

  # 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" LICENSE
}