Sha256: 111df9784936d117d40e00f6c5ff4b405813b255b4b622706729a1874d95a2c5

Contents?: true

Size: 1.7 KB

Versions: 14

Compression:

Stored size: 1.7 KB

Contents

module Evrone
  module CI
    class Router
      class ScriptBuilder

        Ruby = Struct.new(:app) do

          ALIASES = {
            '1.8.7' => "system"
          }

          include Helper::TraceShCommand

          def call(env)
            if rvm env
              env.before_install.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=$HOME/cached/rubygems'
              end

              env.announce.tap do |a|
                a << trace_sh_command("ruby --version")
                a << trace_sh_command("gem --version")
                a << trace_sh_command("bundle --version")
              end

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

            app.call(env)
          end

          private

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

            def make_rbenv_version_command(env)
              select_rbenv_version_by_aliases(env) ||
                select_rbenv_version(env)
            end

            def select_rbenv_version_by_aliases(env)
              ALIASES[rvm(env)]
            end

            def select_rbenv_version(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

14 entries across 14 versions & 1 rubygems

Version Path
evrone-ci-router-0.2.0.pre22 lib/evrone/ci/router/script_builder/ruby.rb
evrone-ci-router-0.2.0.pre21 lib/evrone/ci/router/script_builder/ruby.rb
evrone-ci-router-0.2.0.pre20 lib/evrone/ci/router/script_builder/ruby.rb
evrone-ci-router-0.2.0.pre19 lib/evrone/ci/router/script_builder/ruby.rb
evrone-ci-router-0.2.0.pre17 lib/evrone/ci/router/script_builder/ruby.rb
evrone-ci-router-0.2.0.pre15 lib/evrone/ci/router/script_builder/ruby.rb
evrone-ci-router-0.2.0.pre14 lib/evrone/ci/router/script_builder/ruby.rb
evrone-ci-router-0.2.0.pre13 lib/evrone/ci/router/script_builder/ruby.rb
evrone-ci-router-0.2.0.pre12 lib/evrone/ci/router/script_builder/ruby.rb
evrone-ci-router-0.2.0.pre11 lib/evrone/ci/router/script_builder/ruby.rb
evrone-ci-router-0.2.0.pre10 lib/evrone/ci/router/script_builder/ruby.rb
evrone-ci-router-0.2.0.pre9 lib/evrone/ci/router/script_builder/ruby.rb
evrone-ci-router-0.2.0.pre8 lib/evrone/ci/router/script_builder/ruby.rb
evrone-ci-router-0.2.0.pre7 lib/evrone/ci/router/script_builder/ruby.rb