# 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.17.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=('d2c7a356ea10b33006f0671e10adbcccce1e162d5d8fff89b47166e805520f0877fdc9bedd6adc8af8d510b9bc09c4782b60aa9de2a38c74b76b4cda364fa85e')
b2sums=('5f6a5a644e1e4b6df84046dfbc6d617e2b29fec9f5c4fd3ac5e2cc8db30a44abcbc29225e546f64cb1fbeabb3ad115f69456d0e3d57569c18f839a24540553c6')

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"

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