# Maintainer: George Rawlinson <grawlinson@archlinux.org>
# Maintainer: Robin Candau <antiz@archlinux.org>
# Contributor: Eric Berquist <eric dot berquist at gmail dot com>

pkgname=markdownlint
_pkgname=mdl
pkgver=0.15.0
pkgrel=1
pkgdesc='A lint tool to check markdown files and flag style issues'
arch=(any)
url='https://github.com/markdownlint/markdownlint'
license=(MIT)
depends=(
  ruby
  ruby-kramdown
  ruby-kramdown-parser-gfm
  ruby-mixlib-cli
  ruby-mixlib-config
  ruby-mixlib-shellout
)
makedepends=(git ruby-rdoc)
provides=(ruby-mdl)
replaces=(ruby-mdl)
options=(!emptydirs)
source=("$pkgname::git+$url#tag=v$pkgver")
sha512sums=('30023b7aa848fe9f8100dbd59a4c788b5f2fcf8432ca4447c9e8bce5b6743d8a44dad9bed05da1ef211f398ab14af7b5bd0657f1a5c297541d5cc354aaf5da79')
b2sums=('b6dc56e36b50bddec81c1a819945820726ee8268493688e0e8f7c1ed10a55e7122759f2f1562054509a378934f6e5b439fac7e980f260c2891e46de9b1451d3c')

prepare() {
  cd "$pkgname"

  # we do not do version pinning
  sed --regexp-extended 's,~>,>=,g' --in-place *.gemspec Gemfile Rakefile
}

build() {
  cd "$pkgname"

  gem build "$_pkgname.gemspec"
}

package() {
  local _gemdir="$(ruby -e'puts Gem.default_dir')"

  gem install \
    --local \
    --verbose \
    --ignore-dependencies \
    --no-user-install \
    --no-document \
    --install-dir "$pkgdir/$_gemdir" \
    --bindir "$pkgdir/usr/bin" \
    "$pkgname/$_pkgname-$pkgver.gem"

  # delete cache
  rm -vrf "$pkgdir/$_gemdir/cache"

  # license
  install -vDm644 -t "$pkgdir/usr/share/licenses/$pkgname" "$pkgname/LICENSE.txt"
}
