Class: Vx::Builder::Script::Ruby

Inherits:
Struct
  • Object
show all
Includes:
Helper::TraceShCommand
Defined in:
lib/vx/builder/script/ruby.rb

Constant Summary collapse

DEFAULT_RUBY =
'1.9.3'

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helper::TraceShCommand

#trace_sh_command

Instance Attribute Details

#appObject

Returns the value of attribute app

Returns:

  • (Object)

    the current value of app



5
6
7
# File 'lib/vx/builder/script/ruby.rb', line 5

def app
  @app
end

Instance Method Details

#call(env) ⇒ Object



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/ruby.rb', line 11

def call(env)
  if enabled?(env)
    env.cache_key << "rvm-#{ruby env}"
    env.cache_key << gemfile(env)

    env.before_install.tap 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

    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|
      bundler_args = env.source.bundler_args.first
      i << trace_sh_command("bundle install #{bundler_args}")
      i << trace_sh_command("bundle clean --force")
    end

    if env.source.script.empty?
      script = "test -f Rakefile && #{trace_sh_command "bundle exec rake"} || true"
      env.script << script
    end

    if env.source.cached_directories != false
      env.cached_directories.push "~/.rubygems"
    end
  end

  app.call(env)
end