Sha256: 9261f7ef7dc22f4775405fdc05fec3874f3f395ec57d0d1200a4e129273c3e9e

Contents?: true

Size: 1.74 KB

Versions: 11

Compression:

Stored size: 1.74 KB

Contents

module Vx
  module Builder
    class ScriptBuilder

      class Ruby < Base

        DEFAULT_RUBY = '1.9.3'

        ALIASES = {
          'jruby-19mode' => 'jruby'
        }

        def call(env)
          if enabled?(env)

            vxvm_install(env, 'ruby', ruby_version(env))

            do_cache_key(env) do |i|
              i << "rvm-#{ruby_version env}"
              i << gemfile(env)
            end

            do_before_install(env) do |i|
              i << trace_sh_command("export BUNDLE_GEMFILE=${PWD}/#{gemfile(env)}")
              i << trace_sh_command('export GEM_HOME=~/.rubygems')
            end

            do_announce(env) do |i|
              i << trace_sh_command("ruby --version")
              i << trace_sh_command("gem --version")
              i << trace_sh_command("bundle --version")
            end

            do_install(env) do |i|
              bundler_args = env.source.bundler_args.first
              i << trace_sh_command("bundle install #{bundler_args}")
              i << trace_sh_command("bundle clean --force")
            end

            do_script(env) do |i|
              script = "if [ -f Rakefile ] ; then \n #{trace_sh_command "bundle exec rake"}\nfi"
              i << script
            end

            do_cached_directories(env) do |i|
              i << "~/.rubygems"
            end
          end

          app.call(env)
        end

        private

          def enabled?(env)
            env.source.rvm.first || env.source.language == 'ruby'
          end

          def ruby_version(env)
            v = env.source.rvm.first || DEFAULT_RUBY
            ALIASES[v] || v
          end

          def gemfile(env)
            env.source.gemfile.first || "Gemfile"
          end

      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
vx-builder-0.5.15 lib/vx/builder/script_builder/ruby.rb
vx-builder-0.5.14 lib/vx/builder/script_builder/ruby.rb
vx-builder-0.5.13 lib/vx/builder/script_builder/ruby.rb
vx-builder-0.5.12 lib/vx/builder/script_builder/ruby.rb
vx-builder-0.5.11 lib/vx/builder/script_builder/ruby.rb
vx-builder-0.5.10 lib/vx/builder/script_builder/ruby.rb
vx-builder-0.5.9 lib/vx/builder/script_builder/ruby.rb
vx-builder-0.5.8 lib/vx/builder/script_builder/ruby.rb
vx-builder-0.5.7 lib/vx/builder/script_builder/ruby.rb
vx-builder-0.5.6 lib/vx/builder/script_builder/ruby.rb
vx-builder-0.5.5 lib/vx/builder/script_builder/ruby.rb