# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4

PortSystem          1.0
PortGroup           ruby 1.0

ruby.branches       1.9 2.3 2.4 2.5
ruby.setup          bundler 2.2.15 gem
checksums           rmd160  709edc8f045fd2e558491909945059493f09ce33 \
                    sha256  9295b52d6744076497b86a7dfe03ffa4599942f245558c98071b8a05e3535835 \
                    size    389120

license             MIT
categories-append   www devel
platforms           any
maintainers         {kimuraw @kimuraw} openmaintainer
supported_archs     noarch
homepage            https://bundler.io

description         Bundler provides a consistent environment for Ruby \
                    projects by tracking and installing the exact gems and \
                    versions that are needed.

long_description    {*}${description}\
                    \nBundler is an exit from dependency hell, and ensures \
                    that the gems you need are present in development, \
                    staging, and production. Starting work on a project is as \
                    simple as bundle install.

# Note: ruby contains bundler since 2.6.
#       bundler 2.0 requires ruby-2.3 and rubygems-2.5 or later.
if {${ruby.branch} eq "1.9"} {
    ruby.setup          bundler 1.17.3 gem
    checksums           rmd160  dc0597bea59ff9f7f1feeec140898363e3747cac \
                        sha1    b5f0a9bffd4ff9b983b536704973fbe1cf49f015 \
                        sha256  bc4bf75b548b27451aa9f443b18c46a739dd22ad79f7a5f90b485376a67dc352 \
                        size    364032
}

post-destroot {
    # bundler expects the name of gem command is "gem",
    # this causes failure of `rake build` when write a new gem with bundler.
    if {$subport ne $name} {
        # sh "gem build ..." -> sh "gem2.3 build ..."
        reinplace -E "s/(gem) (build|install|push)/gem${ruby.branch} \\2/g" \
            ${destroot}${ruby.gemdir}/gems/bundler-${version}/lib/bundler/gem_helper.rb
    }
}
