Index: railties/lib/rails_generator/generators/applications/app/template_runner.rb =================================================================== --- railties/lib/rails_generator/generators/applications/app/template_runner.rb (revision beb091ea18d0454379fb235308f628a3719154ea) +++ railties/lib/rails_generator/generators/applications/app/template_runner.rb Wed Jun 10 09:31:57 CEST 2009 @@ -78,7 +78,7 @@ run_ruby_script("script/plugin install #{options[:svn] || options[:git]}", false) end else - log "! no git or svn provided for #{name}. skipping..." + log "! no git or svn provided for #{name}. Skipping..." end end @@ -90,7 +90,7 @@ gems_code = "config.gem '#{name}'" if options.any? - opts = options.inject([]) {|result, h| result << [":#{h[0]} => #{h[1].inspect.gsub('"',"'")}"] }.sort.join(", ") + opts = options.inject([]) {|result, h| result << [":#{h[0]} => #{h[1].inspect.gsub('"', "'")}"] }.sort.join(", ") gems_code << ", #{opts}" end @@ -247,8 +247,7 @@ # Executes a ruby script (taking into account WIN32 platform quirks) def run_ruby_script(command, log_action = true) - ruby_command = RUBY_PLATFORM=~ /win32/ ? 'ruby ' : '' - run("#{ruby_command}#{command}", log_action) + run("#{ruby_command} #{command}", log_action) end # Runs the supplied rake task @@ -263,7 +262,7 @@ log 'rake', command env = options[:env] || 'development' sudo = options[:sudo] ? 'sudo ' : '' - in_root { run("#{sudo}rake #{command} RAILS_ENV=#{env}", false) } + in_root { run("#{sudo}#{ruby} rake #{command} RAILS_ENV=#{env}", false) } end # Just run the capify command in root @@ -274,7 +273,7 @@ # def capify! log 'capifying' - in_root { run('capify .', false) } + in_root { run("#{ruby} capify .", false) } end # Add Rails to /vendor/rails @@ -285,7 +284,7 @@ # def freeze!(args = {}) log 'vendor', 'rails edge' - in_root { run('rake rails:freeze:edge', false) } + in_root { run("#{ruby_command} rake rails:freeze:edge", false) } end # Make an entry in Rails routing file conifg/routes.rb @@ -307,6 +306,16 @@ protected + # returns the current ruby command including the path + def ruby_command + @ruby_command ||= Gem.ruby + end + + # + def ruby + @ruby ||= ruby_command =~ /jruby/ ? "#{ruby_command} -S " : ruby_command + end + # Get a user's input # # ==== Example @@ -389,12 +398,13 @@ end def logger - @logger ||= if defined?(Rails::Generator::Base) + @logger ||= + if defined?(Rails::Generator::Base) - Rails::Generator::Base.logger - else - require 'rails_generator/simple_logger' - Rails::Generator::SimpleLogger.new(STDOUT) - end + Rails::Generator::Base.logger + else + require 'rails_generator/simple_logger' + Rails::Generator::SimpleLogger.new(STDOUT) + end end end