From 670f6ff45ebb0a2daccaef0427b42fdb63219ee9 Mon Sep 17 00:00:00 2001 From: Bryan Larsen Date: Sun, 28 Feb 2010 12:35:20 -0500 Subject: [PATCH] [#639 state:resolved] error check ruby & rails existence and version in hobo script --- hobo/bin/hobo | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/hobo/bin/hobo b/hobo/bin/hobo index 41fe51987..0fa6b2f6d 100755 --- a/hobo/bin/hobo +++ b/hobo/bin/hobo @@ -7,6 +7,11 @@ require 'rbconfig' RUBY = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name']).sub(/.*\s.*/m, '"\&"') +if RUBY.empty? + puts "ruby not found" + exit 2 +end + Signal.trap("INT") { puts; exit } hobo_src = File.join(File.dirname(__FILE__), "../hobo_files/plugin") @@ -87,11 +92,17 @@ if run_rails opts = [] if rails_version opts << "_#{rails_version}_" -# else -# if `rails -v`.split[1].split(".").slice(0,2)!=['2', '3'] -# puts "Rails 2.3 required!" -# exit 2 -# end + else + v=`#{RUBY} -S rails -v`.split[1].split(".") + unless v.length===3 + puts "rails not found!" + exit 2 + end + unless v[0]=='2' && ['2', '3'].include?(v[1]) + puts "Rails 2.2 or 2.3 required!" + puts "Rails 3 requires Hobo 1.1 or later." + exit 2 + end end opts << "-d #{database_type}" if database_type system("#{RUBY} -S rails #{opts * ' '} #{app_path}")