lib/vx/builder/script/ruby.rb in vx-builder-0.0.16 vs lib/vx/builder/script/ruby.rb in vx-builder-0.0.18
- old
+ new
@@ -4,13 +4,16 @@
Ruby = Struct.new(:app) do
include Helper::TraceShCommand
+ DEFAULT_RUBY = '1.9.3'
+
def call(env)
- if rvm env
- env.cache_key << "rvm-#{rvm env}"
+ if enabled?(env)
+ env.cache_key << "rvm-#{ruby env}"
+ env.cache_key << gemfile(env)
env.before_install.tap do |i|
i << "source /etc/profile.d/rbenv.sh"
i << 'eval "$(rbenv init -)" || true'
i << "rbenv shell #{make_rbenv_version_command env}"
@@ -37,14 +40,18 @@
app.call(env)
end
private
- def rvm(env)
- env.source.rvm.first
+ def enabled?(env)
+ env.source.rvm.first || env.source.language == 'ruby'
end
+ def ruby(env)
+ env.source.rvm.first || DEFAULT_RUBY
+ end
+
def gemfile(env)
env.source.gemfile.first || "Gemfile"
end
def make_rbenv_version_command(env)
@@ -55,10 +62,10 @@
%{
$(rbenv versions |
sed -e 's/^\*/ /' |
awk '{print $1}' |
grep -v 'system' |
- grep '#{rvm env}' |
+ grep '#{ruby env}' |
tail -n1)
}.gsub(/\n/, ' ').gsub(/ +/, ' ').strip
end
end