# Build recipe for asciidoctor.
#
# Copyright (C) 2019 Matias Fonzo, <selk@dragora.org>.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

program=asciidoctor
version=2.0.10
release=1

# Set 'outdir' for a nice and well-organized output directory
outdir="${outdir}/${arch}/modules/ruby"

tarname=${program}-${version}.gem

# Remote source(s)
fetch=http://rubygems.org/downloads/$tarname

description="
Asciidoctor is a fast, open source text processor.

It converts AsciiDoc content to HTML5, DocBook, PDF, and other formats.
Asciidoctor is written in Ruby and runs on all major operating systems.
"

homepage=http://asciidoctor.org
license=MIT

build()
{
    set -e

    # Figure out directory for Ruby Gems
    _gemdir="$(ruby -W0 -e 'puts Gem.default_dir')"

    if test -z "_$gemdir"
    then
        echo "recipe: Error: the _gemdir variable is empty." 1>&2
        exit 1
    fi

    mkdir -p "${destdir}/${_gemdir}" "${destdir}/usr/bin"

    gem install \
     --ignore-dependencies \
     --no-user-install \
     --backtrace --verbose \
     --install-dir "${destdir}/${_gemdir}" \
     --bindir "${destdir}/usr/bin" \
     "${tardir}/$tarname"
}

