lib/vx/builder/script/ruby.rb in vx-builder-0.1.8 vs lib/vx/builder/script/ruby.rb in vx-builder-0.2.0
- old
+ new
@@ -1,45 +1,50 @@
module Vx
module Builder
class Script
- Ruby = Struct.new(:app) do
+ class Ruby < Base
- include Helper::TraceShCommand
-
DEFAULT_RUBY = '1.9.3'
def call(env)
if enabled?(env)
- env.cache_key << "rvm-#{ruby env}"
- env.cache_key << gemfile(env)
+ do_cache_key(env) do |i|
+ i << "rvm-#{ruby env}"
+ i << gemfile(env)
+ end
- env.before_install.tap do |i|
+ 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
- env.announce.tap do |a|
- a << trace_sh_command("ruby --version")
- a << trace_sh_command("gem --version")
- a << trace_sh_command("bundle --version")
+ do_announce(env) do |i|
+ i << trace_sh_command("ruby --version")
+ i << trace_sh_command("gem --version")
+ i << 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 = "if [ -f Rakefile ] then (#{trace_sh_command "bundle exec rake"}) ; fi"
- env.script << script
+ do_install(env) do |i|
+ i << trace_sh_command("bundle install")
+ i << trace_sh_command("bundle clean --force")
end
- if env.source.cached_directories != false
- env.cached_directories.push "~/.rubygems"
+ 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