# Maintainer: George Rawlinson <grawlinson@archlinux.org>
# Contributor: Maxime Gauduin <alucryd@archlinux.org>
# Contributor: Julien Nicoulaud <julien.nicoulaud@gmail.com>
# Contributor: Hyacinthe Cartiaux <hyacinthe.cartiaux@free.fr>

pkgname=ruby-tins
_pkgname="${pkgname#ruby-}"
pkgver=1.52.0
pkgrel=1
pkgdesc='All the stuff that is not good/big enough for a real library'
arch=(any)
url='https://github.com/flori/tins'
license=(MIT)
depends=(ruby ruby-bigdecimal ruby-sync ruby-mize)
makedepends=(git ruby-rake)
options=(!emptydirs)
source=("$pkgname::git+$url#tag=v$pkgver")
sha512sums=('09b64c868f0da931eaa87e06a6fd54f233f078e0a701b262deb520f978c9a575e1cdb5839351b2b7e57d9294afcad60b9fb1083ed343eae9936a2dafe246c6a6')
b2sums=('242ac32758d1b50757410fb3cdaefd42a97871527d297f7a3e7e6c91dc0435e881f677548b92f80d470750bd585a4561bf569b705c1ae2312c8076ce26f28c75')

prepare() {
  cd "$pkgname"

  # update gemspec/Gemfile to allow newer version of the dependencies
  sed --in-place --regexp-extended 's|~>|>=|g' tins.gemspec
}

build() {
  cd "$pkgname"

  gem build tins.gemspec
}

package() {
  cd "$pkgname"

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

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

  # license
  install -vDm644 -t "$pkgdir/usr/share/licenses/$pkgname" LICENSE
}
