# Maintainer: Andreas 'Segaja' Schleifer <segaja at archlinux dot org>
# Contributor: Mario Finelli <mario at finel dot li>
_gemname='racc'
pkgname="ruby-${_gemname}"
pkgver=1.6.2
pkgrel=1
pkgdesc='LALR parser generator written in Ruby itself and generates ruby programs'
arch=('x86_64' 'armv7h')
url="https://github.com/ruby/${_gemname}"
license=('Ruby' 'BSD')
depends=('ruby')
makedepends=('rubygems' 'ruby-rake' 'ruby-rake-compiler' 'ruby-rdoc' 'ruby-bundler')
checkdepends=('ruby-test-unit')
options=('!emptydirs')
source=("${url}/archive/v${pkgver}/${pkgname}-${pkgver}.tar.gz")
sha512sums=('ef577d0da440361702d15cf2127142e57d5af4146f120cd9d94ee8c8b4380810c8913c373a9969f09b50e0850a8ac04ffd22729c4abdab0670765c7379b549f6')
build() {
cd "${_gemname}-${pkgver}"
rake compile
rake build
}
#check() {
# cd "${_gemname}-${pkgver}"
# rake test
#}
package() {
cd "${_gemname}-${pkgver}"
local _gemdir="$(gem env gemdir)"
local _platform="$(gem env platform | cut -d':' -f2)"
local _extension_api_version="$(ruby -e 'puts Gem.extension_api_version')"
gem install \
--local \
--verbose \
--ignore-dependencies \
--no-user-install \
--install-dir "${pkgdir}/${_gemdir}" \
--bindir "${pkgdir}/usr/bin" \
"pkg/${_gemname}-${pkgver}.gem"
install --verbose --directory --mode=0755 \
"${pkgdir}/usr/lib/ruby/${_extension_api_version}/${_platform}" \
"${pkgdir}${_gemdir}/specifications/default"
mv --verbose "${pkgdir}${_gemdir}/specifications/${_gemname}-${pkgver}.gemspec" "${pkgdir}${_gemdir}/specifications/default/${_gemname}-${pkgver}.gemspec"
mv --verbose "${pkgdir}${_gemdir}/gems/${_gemname}-${pkgver}/lib/${_gemname}.rb" "${pkgdir}/usr/lib/ruby/${_extension_api_version}/${_gemname}.rb"
mv --verbose "${pkgdir}${_gemdir}/gems/${_gemname}-${pkgver}/lib/${_gemname}" "${pkgdir}/usr/lib/ruby/${_extension_api_version}/${_gemname}"
mv --verbose "${pkgdir}${_gemdir}/extensions/${_platform}/${_extension_api_version}/${_gemname}-${pkgver}/${_gemname}" "${pkgdir}/usr/lib/ruby/${_extension_api_version}/${_platform}/${_gemname}"
# remove unrepreducible files
rm --force --recursive --verbose \
"${pkgdir}${_gemdir}/cache/" \
"${pkgdir}${_gemdir}/build_info/" \
"${pkgdir}${_gemdir}/extensions/" \
"${pkgdir}${_gemdir}/gems/${_gemname}-${pkgver}/"{doc,ext,ChangeLog,COPYING,*.rdoc,TODO} \
"${pkgdir}${_gemdir}/plugins/" \
"${pkgdir}${_gemdir}/doc/${_gemname}-${pkgver}/ri/ext/"
# conflict w ruby
rm -rf "${pkgdir}/usr/lib/ruby/3.2.0/armv7l-linux-eabihf/racc/cparse.so"
install --verbose -D --mode=0644 COPYING "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
install --verbose -D --mode=0644 ChangeLog README.rdoc --target-directory "${pkgdir}/usr/share/doc/${pkgname}"
}