# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>
# Contributor: David Phillips <dbphillipsnz gmail>
# Contributor: Anatol Pomozov <anatol.pomozov@gmail.com>

_gemname=colorize
pkgname=ruby-colorize
_gitcommit=24ac367347bf403bcddac3d86307670450ded8d1
pkgver=1.0.4
pkgrel=5
pkgdesc='Ruby string class extension to set color, background and text effect using ANSI escape sequences'
url='https://github.com/fazibear/colorize'
arch=('any')
license=('GPL2')
depends=('ruby')
makedepends=('ruby-rdoc')
options=('!emptydirs')
source=(${pkgname}-${pkgver}.tar.gz::https://github.com/fazibear/colorize/archive/${_gitcommit}.tar.gz)
sha256sums=('333694c95a93009ed7942835f9b6daef4f6a6e9f09ddb84c5fb2e009b0e83121')
sha512sums=('ff85cbe76343ca8ef11703742d4a418d64452aa6c38b367f5a1c4948b2875bf1e8e1ab0dd8a8587c57633fa778fb8dfb7a847fc8b1e04e244c6549f9347749db')

prepare() {
  cd ${_gemname}-${_gitcommit}
  sed -r 's|~>|>=|g' -i ${_gemname}.gemspec # don't give a fuck about rubys bla bla
  # remove deprecated `date` element from gemspec. Removing it makes the package reproducible
  sed --in-place '/s\.date/d' "${_gemname}.gemspec"
}

build() {
  cd ${_gemname}-${_gitcommit}
  gem build ${_gemname}.gemspec
}


package() {
  cd ${_gemname}-${_gitcommit}
  local _gemdir="$(gem env gemdir)"
  gem install --ignore-dependencies --no-user-install -i "${pkgdir}/${_gemdir}" -n "${pkgdir}/usr/bin" ${_gemname}-${pkgver}.gem
  install -Dm 644 README.md -t "${pkgdir}/usr/share/doc/${pkgname}"
  rm "${pkgdir}/${_gemdir}/cache/${_gemname}-${pkgver}.gem"
}

# vim: ts=2 sw=2 et:
