# Maintainer: Andrew Sun <adsun701@gmail.com>

_realname=native-package-installer
pkgbase=mingw-w64-ruby-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-ruby-${_realname}")
pkgver=1.1.9
pkgrel=2
pkgdesc="A helper to install native packages on gem install (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url="https://github.com/ruby-gnome2/native-package-installer"
msys2_references=(
  'purl: pkg:gem/native-package-installer'
)
license=('spdx:LGPL-3.0-or-later')
depends=("${MINGW_PACKAGE_PREFIX}-ruby")
source=("https://rubygems.org/downloads/${_realname}-${pkgver}.gem")
noextract=("${_realname}-${pkgver}.gem")
sha256sums=('fbb41b6b22750791a4304f0a0aeea3dd837668892117f49c4caf2e8e0f4e792f')

package() {
  local _gemdir="$(ruby -e 'puts Gem.default_dir')"
  _gemdir="$(cygpath -u ${_gemdir})"
  
  gem install --ignore-dependencies --no-user-install --verbose \
    -i "${pkgdir}/${_gemdir}" -n "${pkgdir}${MINGW_PREFIX}/bin" \
    "${_realname}-${pkgver}.gem"
  
  rm "${pkgdir}/${_gemdir}/cache/${_realname}-${pkgver}.gem"
}
