Class: Vx::Builder::ScriptBuilder::Ruby

Inherits:
Base
  • Object
show all
Defined in:
lib/vx/builder/script_builder/ruby.rb

Constant Summary collapse

DEFAULT_RUBY =
'1.9.3'

Instance Attribute Summary

Attributes inherited from Base

#app

Instance Method Summary collapse

Methods inherited from Base

#deploy?, #do_after_deploy, #do_announce, #do_before_deploy, #do_before_install, #do_cache_key, #do_cached_directories, #do_deploy_script, #do_install, #do_script

Methods included from Helper::TraceShCommand

#trace_sh_command

Instance Method Details

#call(env) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/vx/builder/script_builder/ruby.rb', line 9

def call(env)
  if enabled?(env)
    do_cache_key(env) do |i|
      i << "rvm-#{ruby env}"
      i << gemfile(env)
    end

    do_before_install(env) do |i|
      i << 'eval "$(rbenv init -)" || true'
      i << "rbenv shell #{make_rbenv_version_command env}"
      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