From ab9e4c0eaacba34c9f1d16cf34c82e0e906edad5 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Mon, 17 Dec 2007 18:54:55 +0000 Subject: Ruby 1.9 compatibility. References #1689. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8431 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- railties/CHANGELOG | 5 +++++ railties/dispatches/gateway.cgi | 4 ++-- railties/environments/boot.rb | 3 +-- railties/lib/commands/console.rb | 6 +++--- railties/lib/tasks/documentation.rake | 4 ++-- railties/lib/tasks/framework.rake | 2 +- railties/lib/tasks/testing.rake | 4 ++-- railties/test/boot_test.rb | 2 ++ 8 files changed, 18 insertions(+), 12 deletions(-) diff --git a/railties/CHANGELOG b/railties/CHANGELOG index 1dc848bfb8..1eec091371 100644 --- a/railties/CHANGELOG +++ b/railties/CHANGELOG @@ -1,3 +1,8 @@ +*SVN* + +* Ruby 1.9 compatibility. #1689 [Cheah Chu Yeow] + + *2.0.2* (December 16th, 2007) * Changed the default database from mysql to sqlite3, so now running "rails myapp" will have a config/database.yml that's setup for SQLite3 (which in OS X Leopard is installed by default, so is the gem, so everything Just Works with no database configuration at all). To get a Rails application preconfigured for MySQL, just run "rails -d mysql myapp" [DHH] diff --git a/railties/dispatches/gateway.cgi b/railties/dispatches/gateway.cgi index d21bf0991a..fb1fa22f04 100644 --- a/railties/dispatches/gateway.cgi +++ b/railties/dispatches/gateway.cgi @@ -31,7 +31,7 @@ def listener_socket(number) File.expand_path(File.join(File.dirname(__FILE__), "../log/drb_gateway/listener_#{number}.sock")) end -unless File.exists? TrackerSocket +unless File.exist? TrackerSocket message "Starting tracker and #{Listeners} listeners" fork do Process.setsid @@ -62,7 +62,7 @@ unless File.exists? TrackerSocket ready = false 10.times do sleep 0.5 - break if (ready = File.exists?(TrackerSocket) && File.exists?(listener_socket(0))) + break if (ready = File.exist?(TrackerSocket) && File.exist?(listener_socket(0))) end if ready diff --git a/railties/environments/boot.rb b/railties/environments/boot.rb index 5697cc1bc3..fc8372309b 100644 --- a/railties/environments/boot.rb +++ b/railties/environments/boot.rb @@ -24,9 +24,8 @@ module Rails File.exist?("#{RAILS_ROOT}/vendor/rails") end - # FIXME : Ruby 1.9 def preinitialize - load(preinitializer_path) if File.exists?(preinitializer_path) + load(preinitializer_path) if File.exist?(preinitializer_path) end def preinitializer_path diff --git a/railties/lib/commands/console.rb b/railties/lib/commands/console.rb index edb135ff40..edffe4f1e6 100644 --- a/railties/lib/commands/console.rb +++ b/railties/lib/commands/console.rb @@ -16,9 +16,9 @@ libs << " -r console_sandbox" if options[:sandbox] libs << " -r console_with_helpers" ENV['RAILS_ENV'] = case ARGV.first - when "p": "production" - when "d": "development" - when "t": "test" + when "p"; "production" + when "d"; "development" + when "t"; "test" else ARGV.first || ENV['RAILS_ENV'] || 'development' end diff --git a/railties/lib/tasks/documentation.rake b/railties/lib/tasks/documentation.rake index 41e52f1371..331b2450a3 100644 --- a/railties/lib/tasks/documentation.rake +++ b/railties/lib/tasks/documentation.rake @@ -65,11 +65,11 @@ namespace :doc do options << '-T html' files.include("#{plugin_base}/lib/**/*.rb") - if File.exists?("#{plugin_base}/README") + if File.exist?("#{plugin_base}/README") files.include("#{plugin_base}/README") options << "--main '#{plugin_base}/README'" end - files.include("#{plugin_base}/CHANGELOG") if File.exists?("#{plugin_base}/CHANGELOG") + files.include("#{plugin_base}/CHANGELOG") if File.exist?("#{plugin_base}/CHANGELOG") options << files.to_s diff --git a/railties/lib/tasks/framework.rake b/railties/lib/tasks/framework.rake index ebc24f46af..77f74aa156 100644 --- a/railties/lib/tasks/framework.rake +++ b/railties/lib/tasks/framework.rake @@ -105,7 +105,7 @@ namespace :rails do require 'railties_path' project_dir = RAILS_ROOT + '/public/javascripts/' scripts = Dir[RAILTIES_PATH + '/html/javascripts/*.js'] - scripts.reject!{|s| File.basename(s) == 'application.js'} if File.exists?(project_dir + 'application.js') + scripts.reject!{|s| File.basename(s) == 'application.js'} if File.exist?(project_dir + 'application.js') FileUtils.cp(scripts, project_dir) end diff --git a/railties/lib/tasks/testing.rake b/railties/lib/tasks/testing.rake index f495031b79..dc513108fc 100644 --- a/railties/lib/tasks/testing.rake +++ b/railties/lib/tasks/testing.rake @@ -13,11 +13,11 @@ def recent_tests(source_pattern, test_path, touched_since = 10.minutes.ago) # For modified files in app/ run the tests for it. ex. /test/functional/account_controller.rb test = "#{modified_test_path}/#{source_file}_test.rb" - tests.push test if File.exists?(test) + tests.push test if File.exist?(test) # For modified files in app, run tests in subdirs too. ex. /test/functional/account/*_test.rb test = "#{modified_test_path}/#{File.basename(path, '.rb').sub("_controller","")}" - FileList["#{test}/*_test.rb"].each { |f| tests.push f } if File.exists?(test) + FileList["#{test}/*_test.rb"].each { |f| tests.push f } if File.exist?(test) return tests diff --git a/railties/test/boot_test.rb b/railties/test/boot_test.rb index 36fae307ca..0754777dd6 100644 --- a/railties/test/boot_test.rb +++ b/railties/test/boot_test.rb @@ -36,6 +36,7 @@ class BootTest < Test::Unit::TestCase def test_boot_vendor_rails_by_default Rails.expects(:booted?).returns(false) + Rails.expects(:preinitialize) File.expects(:exist?).with("#{RAILS_ROOT}/vendor/rails").returns(true) Rails::VendorBoot.any_instance.expects(:run).returns('result') assert_equal 'result', Rails.boot! @@ -43,6 +44,7 @@ class BootTest < Test::Unit::TestCase def test_boot_gem_rails_otherwise Rails.expects(:booted?).returns(false) + Rails.expects(:preinitialize) File.expects(:exist?).with("#{RAILS_ROOT}/vendor/rails").returns(false) Rails::GemBoot.any_instance.expects(:run).returns('result') assert_equal 'result', Rails.boot! -- cgit v1.2.3