# Maintainer: J. Peter Mugaas <jpmugaas@suddenlink.net>

# Note: hpricot was discontinued aboust 6 years ago and it hasn't had a release in 9 years.
# I am only providing this so that we can use the original version of ruby-ronn gem.
#
# The most ideal solution to this situation is to update to ruby-ng but that seems
# to depend upon an old version of mustache (0.7.x) - see: https://github.com/apjanke/ronn-ng/blob/master/ronn-ng.gemspec

_realname=hpricot
pkgbase="mingw-w64-ruby-${_realname}"
pkgname="${MINGW_PACKAGE_PREFIX}-ruby-${_realname}"
pkgver=0.8.6
pkgrel=3
pkgdesc="Manual page formatter that generates man pages from markdown (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64')
url='https://github.com/hpricot/hpricot'
license=('MIT')
depends=("${MINGW_PACKAGE_PREFIX}-ruby")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc")
options=(!emptydirs)
source=(https://rubygems.org/downloads/${_realname}-$pkgver.gem)
noextract=(${_realname}-$pkgver.gem)
sha256sums=('dfe8f4b3414ba8377d7626030f3aa605caadee9de87cffbeadf8a50359eac8ca')

check() {
  local _gemdir="$(ruby -e 'puts Gem.default_dir')"
  _gemdir="$(cygpath -u ${_gemdir})"

  ${MINGW_PREFIX}/bin/gem check --verbose \
    "${_realname}-${pkgver}.gem"
}

package() {
  local _gemdir="$(${MINGW_PREFIX}/bin/ruby -e 'puts Gem.default_dir')"
  _gemdir="$(cygpath -u ${_gemdir})"

  ${MINGW_PREFIX}/bin/gem install --ignore-dependencies --no-user-install --no-document --verbose \
    -i "${pkgdir}${_gemdir}" -n "${pkgdir}${MINGW_PREFIX}/bin" \
    "${_realname}-${pkgver}.gem"

  install -D -m644 "${pkgdir}${_gemdir}/gems/${_realname}-${pkgver}/COPYING" \
    "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING"

  rm "${pkgdir}${_gemdir}/cache/${_realname}-${pkgver}.gem"
  rm -rf "${pkgdir}${_gemdir}/gems/${_realname}-${pkgver}/man"
}
