lib/vx/builder/script_builder/ruby.rb in vx-builder-0.5.15 vs lib/vx/builder/script_builder/ruby.rb in vx-builder-0.5.16

- old
+ new

@@ -2,27 +2,29 @@ module Builder class ScriptBuilder class Ruby < Base - DEFAULT_RUBY = '1.9.3' + DEFAULT_RUBY = '2.0.0' + DEFAULT_BUNDLE_INSTALL_ARGS = "--clean --retry=3 --jobs=4" 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 RAILS_ENV=test") + i << trace_sh_command("export RACK_ENV=test") i << trace_sh_command("export BUNDLE_GEMFILE=${PWD}/#{gemfile(env)}") i << trace_sh_command('export GEM_HOME=~/.rubygems') end do_announce(env) do |i| @@ -30,13 +32,12 @@ 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 + bundler_args = env.source.bundler_args.first || DEFAULT_BUNDLE_INSTALL_ARGS 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 @@ -45,13 +46,35 @@ do_cached_directories(env) do |i| i << "~/.rubygems" end end + if auto_build?(env) + vxvm_install(env, 'ruby', DEFAULT_RUBY) + + do_init(env) do |i| + src = File.read(File.expand_path("../../../../../bin/vx_ruby_auto_build", __FILE__)) + i << upload_sh_command("~/vx_ruby_auto_build", src) + i << "sudo chmod 0755 ~/vx_ruby_auto_build" + end + + do_script(env) do |i| + i << "~/vx_ruby_auto_build" + end + + do_cached_directories(env) do |i| + i << "~/.rubygems" + end + end + app.call(env) end private + + def auto_build?(env) + env.source.empty? + end def enabled?(env) env.source.rvm.first || env.source.language == 'ruby' end