# Maintainer: Tim Meusel <tim@bastelfreak.de>
# Contributor: Artem Vorotnikov <artem@vorotnikov.me>
# Contributor: Tim Meusel <tim@bastelfreak.de>
# Contributor: Mario Finelli <mario at finel dot li>

_gemname='minitar'
pkgname="ruby-${_gemname}"
pkgver=0.12
pkgrel=1
pkgdesc='A pure-Ruby library that provides the ability to deal with POSIX tar(1) archive files'
arch=('any')
url='https://github.com/halostatue/minitar/'
license=('Ruby' 'BSD-2-Clause')
makedepends=('ruby-rdoc' 'ruby-rake' 'ruby-hoe' 'ruby-minitest' 'ruby-base64')
depends=(ruby)
source=("https://github.com/halostatue/minitar/archive/v${pkgver}/${pkgname}-v${pkgver}.tar.gz")
options=("!emptydirs")
sha512sums=('33ffc428fb9425cd5cd835c45bffc81d407c08c2052f44dc1322df06a6d5b810ab28e49f22b0b9363bc59e4f28f5de7db3833d2ad04bc993076f8ff9c3cfc575')

# update the gemspec to allow newer versions of rake
# remove references to cloud CI pipelines (they require more gems and don't bring any value)
prepare() {
  cd "${_gemname}-${pkgver}"
  sed --in-place 's|~>|>=|g' "${_gemname}.gemspec"
  sed --in-place "/Rake::Task\['travis'\].*/d" Rakefile
  sed --in-place '/minitest\/focus/d' test/minitest_helper.rb
  rm -f Gemfile
}

build() {
  cd "${_gemname}-${pkgver}"
  #gem build "${_gemname}.gemspec"
  rake gem
}

check() {
  cd "${_gemname}-${pkgver}"
  rake test
}

package() {
  cd "${_gemname}-${pkgver}"
  local _gemdir="$(gem env gemdir)"
  gem install --verbose --ignore-dependencies --no-user-install --install-dir "${pkgdir}/${_gemdir}" --bindir "${pkgdir}/usr/bin" "pkg/${_gemname}-${pkgver}.gem"

  install -Dm 644 Licence.md -t "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
  install -Dm 644 Code-of-Conduct.md Contributing.md History.md README.rdoc -t "${pkgdir}/usr/share/doc/${pkgname}"

  rm -rf "${pkgdir}/${_gemdir}/cache"
}

# vim: ts=2 sw=2 et:
