Sha256: c525a1ad136cde303a92f36cf636df7e662b6611b5c14e644559381ad38c04ed

Contents?: true

Size: 1.42 KB

Versions: 1

Compression:

Stored size: 1.42 KB

Contents

module Evrone
  module CI
    class Router
      module Middleware::Travis

        Ruby = Struct.new(:app) do

          include Helper::TraceShCommand

          def call(env)
            if rvm env
              env.init.tap do |i|
                i << 'eval "$(rbenv init -)" || true'
                i << "rbenv shell #{make_rbenv_version_command env}"
                i << 'export BUNDLE_GEMFILE=${PWD}/Gemfile'
                i << 'export GEM_HOME=/tmp/.rubygems'
              end

              env.before_install.tap do |b|
                b << "gem query -q -in '^bundler$' > /dev/null || gem install bundler -q --no-rdoc --no-ri"
                b << trace_sh_command("ruby --version")
                b << trace_sh_command("gem --version")
                b << trace_sh_command("bundle --version")
              end

              env.install.tap do |i|
                i << trace_sh_command("bundle install")
              end
            end

            app.call(env)
          end

          private

            def rvm(env)
              env.travis.rvm.last
            end

            def make_rbenv_version_command(env)
              %{
                $(rbenv versions |
                  sed -e 's/^\*/ /' |
                  awk '{print $1}' |
                  grep -v 'system' |
                  grep '#{rvm env}' |
                  tail -n1)
              }.compact
            end

        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
evrone-ci-router-0.2.0.pre0 lib/evrone/ci/router/middleware/travis/ruby.rb