aboutsummaryrefslogtreecommitdiffstats
path: root/railties
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2007-12-10 05:54:46 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2007-12-10 05:54:46 +0000
commitb1ce7e4d4ada3eedc361d90b637ca06274a0ac3d (patch)
treeaffedc3593d216a6b5c4d1c27f84a0b3c7b19e46 /railties
parentc81fff2468bbf597457bf57cd599d2d4be77c715 (diff)
downloadrails-b1ce7e4d4ada3eedc361d90b637ca06274a0ac3d.tar.gz
rails-b1ce7e4d4ada3eedc361d90b637ca06274a0ac3d.tar.bz2
rails-b1ce7e4d4ada3eedc361d90b637ca06274a0ac3d.zip
Ruby 1.9 compat: File.exists\? -> File.exist\? en masse. References #1689 [Pratik Naik]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8365 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'railties')
-rw-r--r--railties/builtin/rails_info/rails/info.rb2
-rw-r--r--railties/environments/boot.rb1
-rw-r--r--railties/lib/commands/plugin.rb4
-rw-r--r--railties/lib/commands/runner.rb2
-rw-r--r--railties/lib/rails_generator/commands.rb8
-rw-r--r--railties/lib/rails_generator/generators/applications/app/app_generator.rb2
-rw-r--r--railties/lib/rails_generator/secret_key_generator.rb2
-rw-r--r--railties/test/generators/generator_test_helper.rb4
-rw-r--r--railties/test/generators/rails_model_generator_test.rb20
-rw-r--r--railties/test/generators/rails_resource_generator_test.rb20
-rw-r--r--railties/test/generators/rails_scaffold_generator_test.rb20
11 files changed, 43 insertions, 42 deletions
diff --git a/railties/builtin/rails_info/rails/info.rb b/railties/builtin/rails_info/rails/info.rb
index 176abfc0f8..b73cc13409 100644
--- a/railties/builtin/rails_info/rails/info.rb
+++ b/railties/builtin/rails_info/rails/info.rb
@@ -32,7 +32,7 @@ module Rails
end
def freeze_edge_version
- if File.exists?(rails_vendor_root)
+ if File.exist?(rails_vendor_root)
begin
Dir[File.join(rails_vendor_root, 'REVISION_*')].first.scan(/_(\d+)$/).first.first
rescue
diff --git a/railties/environments/boot.rb b/railties/environments/boot.rb
index 1e9f1b109d..5697cc1bc3 100644
--- a/railties/environments/boot.rb
+++ b/railties/environments/boot.rb
@@ -24,6 +24,7 @@ module Rails
File.exist?("#{RAILS_ROOT}/vendor/rails")
end
+ # FIXME : Ruby 1.9
def preinitialize
load(preinitializer_path) if File.exists?(preinitializer_path)
end
diff --git a/railties/lib/commands/plugin.rb b/railties/lib/commands/plugin.rb
index ecef450ff4..a26f747dfb 100644
--- a/railties/lib/commands/plugin.rb
+++ b/railties/lib/commands/plugin.rb
@@ -214,12 +214,12 @@ class Plugin
def run_install_hook
install_hook_file = "#{rails_env.root}/vendor/plugins/#{name}/install.rb"
- load install_hook_file if File.exists? install_hook_file
+ load install_hook_file if File.exist? install_hook_file
end
def run_uninstall_hook
uninstall_hook_file = "#{rails_env.root}/vendor/plugins/#{name}/uninstall.rb"
- load uninstall_hook_file if File.exists? uninstall_hook_file
+ load uninstall_hook_file if File.exist? uninstall_hook_file
end
def install_using_export(options = {})
diff --git a/railties/lib/commands/runner.rb b/railties/lib/commands/runner.rb
index 62db8b75e1..926bc26344 100644
--- a/railties/lib/commands/runner.rb
+++ b/railties/lib/commands/runner.rb
@@ -41,7 +41,7 @@ require RAILS_ROOT + '/config/environment'
if code_or_file.nil?
$stderr.puts "Run '#{$0} -h' for help."
exit 1
-elsif File.exists?(code_or_file)
+elsif File.exist?(code_or_file)
eval(File.read(code_or_file))
else
eval(code_or_file)
diff --git a/railties/lib/rails_generator/commands.rb b/railties/lib/rails_generator/commands.rb
index 98531d9771..6f90a44b8a 100644
--- a/railties/lib/rails_generator/commands.rb
+++ b/railties/lib/rails_generator/commands.rb
@@ -207,7 +207,7 @@ HELP
# Determine full paths for source and destination files.
source = source_path(relative_source)
destination = destination_path(relative_destination)
- destination_exists = File.exists?(destination)
+ destination_exists = File.exist?(destination)
# If source and destination are identical then we're done.
if destination_exists and identical?(source, destination, &block)
@@ -306,7 +306,7 @@ HELP
# Always directories which exist.
def directory(relative_path)
path = destination_path(relative_path)
- if File.exists?(path)
+ if File.exist?(path)
logger.exists relative_path
else
logger.create relative_path
@@ -415,7 +415,7 @@ end_message
# Remove a file if it exists and is a file.
def file(relative_source, relative_destination, file_options = {})
destination = destination_path(relative_destination)
- if File.exists?(destination)
+ if File.exist?(destination)
logger.rm relative_destination
unless options[:pretend]
if options[:svn]
@@ -450,7 +450,7 @@ end_message
until parts.empty?
partial = File.join(parts)
path = destination_path(partial)
- if File.exists?(path)
+ if File.exist?(path)
if Dir[File.join(path, '*')].empty?
logger.rmdir partial
unless options[:pretend]
diff --git a/railties/lib/rails_generator/generators/applications/app/app_generator.rb b/railties/lib/rails_generator/generators/applications/app/app_generator.rb
index 02d9b0fb88..915b15317f 100644
--- a/railties/lib/rails_generator/generators/applications/app/app_generator.rb
+++ b/railties/lib/rails_generator/generators/applications/app/app_generator.rb
@@ -128,7 +128,7 @@ class AppGenerator < Rails::Generator::Base
end
def mysql_socket_location
- MYSQL_SOCKET_LOCATIONS.find { |f| File.exists?(f) } unless RUBY_PLATFORM =~ /(:?mswin|mingw)/
+ MYSQL_SOCKET_LOCATIONS.find { |f| File.exist?(f) } unless RUBY_PLATFORM =~ /(:?mswin|mingw)/
end
diff --git a/railties/lib/rails_generator/secret_key_generator.rb b/railties/lib/rails_generator/secret_key_generator.rb
index f488f96f32..497df72ce9 100644
--- a/railties/lib/rails_generator/secret_key_generator.rb
+++ b/railties/lib/rails_generator/secret_key_generator.rb
@@ -141,7 +141,7 @@ module Rails
end
def self.supports_urandom?
- File.exists?('/dev/urandom')
+ File.exist?('/dev/urandom')
end
def self.supports_openssl?
diff --git a/railties/test/generators/generator_test_helper.rb b/railties/test/generators/generator_test_helper.rb
index 63780b3dfb..3af5886a01 100644
--- a/railties/test/generators/generator_test_helper.rb
+++ b/railties/test/generators/generator_test_helper.rb
@@ -77,7 +77,7 @@ module GeneratorTestHelper
# asserts that the given file exists
def assert_file_exists(path)
- assert File.exists?("#{RAILS_ROOT}/#{path}"),"The file '#{path}' should exist"
+ assert File.exist?("#{RAILS_ROOT}/#{path}"),"The file '#{path}' should exist"
end
# asserts that the given class source file was generated.
@@ -158,7 +158,7 @@ module GeneratorTestHelper
# It takes the name of the migration as a parameter.
def assert_skipped_migration(name)
migration_file = "#{RAILS_ROOT}/db/migrate/001_#{name.to_s.underscore}.rb"
- assert !File.exists?(migration_file), "should not create migration #{migration_file}"
+ assert !File.exist?(migration_file), "should not create migration #{migration_file}"
end
# asserts that the given resource was added to the routes.
diff --git a/railties/test/generators/rails_model_generator_test.rb b/railties/test/generators/rails_model_generator_test.rb
index 81d57607d6..a1637c4cda 100644
--- a/railties/test/generators/rails_model_generator_test.rb
+++ b/railties/test/generators/rails_model_generator_test.rb
@@ -46,7 +46,7 @@ if defined?(RAILS_ROOT)
else
RAILS_ROOT=tmp_dir
end
-Dir.mkdir(RAILS_ROOT) unless File.exists?(RAILS_ROOT)
+Dir.mkdir(RAILS_ROOT) unless File.exist?(RAILS_ROOT)
$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../../lib"
require 'rails_generator'
@@ -57,15 +57,15 @@ class RailsModelGeneratorTest < Test::Unit::TestCase
def setup
ActiveRecord::Base.pluralize_table_names = true
- Dir.mkdir("#{RAILS_ROOT}/app") unless File.exists?("#{RAILS_ROOT}/app")
- Dir.mkdir("#{RAILS_ROOT}/app/views") unless File.exists?("#{RAILS_ROOT}/app/views")
- Dir.mkdir("#{RAILS_ROOT}/app/views/layouts") unless File.exists?("#{RAILS_ROOT}/app/views/layouts")
- Dir.mkdir("#{RAILS_ROOT}/config") unless File.exists?("#{RAILS_ROOT}/config")
- Dir.mkdir("#{RAILS_ROOT}/db") unless File.exists?("#{RAILS_ROOT}/db")
- Dir.mkdir("#{RAILS_ROOT}/test") unless File.exists?("#{RAILS_ROOT}/test")
- Dir.mkdir("#{RAILS_ROOT}/test/fixtures") unless File.exists?("#{RAILS_ROOT}/test/fixtures")
- Dir.mkdir("#{RAILS_ROOT}/public") unless File.exists?("#{RAILS_ROOT}/public")
- Dir.mkdir("#{RAILS_ROOT}/public/stylesheets") unless File.exists?("#{RAILS_ROOT}/public/stylesheets")
+ Dir.mkdir("#{RAILS_ROOT}/app") unless File.exist?("#{RAILS_ROOT}/app")
+ Dir.mkdir("#{RAILS_ROOT}/app/views") unless File.exist?("#{RAILS_ROOT}/app/views")
+ Dir.mkdir("#{RAILS_ROOT}/app/views/layouts") unless File.exist?("#{RAILS_ROOT}/app/views/layouts")
+ Dir.mkdir("#{RAILS_ROOT}/config") unless File.exist?("#{RAILS_ROOT}/config")
+ Dir.mkdir("#{RAILS_ROOT}/db") unless File.exist?("#{RAILS_ROOT}/db")
+ Dir.mkdir("#{RAILS_ROOT}/test") unless File.exist?("#{RAILS_ROOT}/test")
+ Dir.mkdir("#{RAILS_ROOT}/test/fixtures") unless File.exist?("#{RAILS_ROOT}/test/fixtures")
+ Dir.mkdir("#{RAILS_ROOT}/public") unless File.exist?("#{RAILS_ROOT}/public")
+ Dir.mkdir("#{RAILS_ROOT}/public/stylesheets") unless File.exist?("#{RAILS_ROOT}/public/stylesheets")
File.open("#{RAILS_ROOT}/config/routes.rb", 'w') do |f|
f<<"ActionController::Routing::Routes.draw do |map|\n\nend\n"
end
diff --git a/railties/test/generators/rails_resource_generator_test.rb b/railties/test/generators/rails_resource_generator_test.rb
index 7aa06b645d..63cd284d35 100644
--- a/railties/test/generators/rails_resource_generator_test.rb
+++ b/railties/test/generators/rails_resource_generator_test.rb
@@ -46,7 +46,7 @@ if defined?(RAILS_ROOT)
else
RAILS_ROOT=tmp_dir
end
-Dir.mkdir(RAILS_ROOT) unless File.exists?(RAILS_ROOT)
+Dir.mkdir(RAILS_ROOT) unless File.exist?(RAILS_ROOT)
$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../../lib"
require 'rails_generator'
@@ -57,15 +57,15 @@ class RailsResourceGeneratorTest < Test::Unit::TestCase
def setup
ActiveRecord::Base.pluralize_table_names = true
- Dir.mkdir("#{RAILS_ROOT}/app") unless File.exists?("#{RAILS_ROOT}/app")
- Dir.mkdir("#{RAILS_ROOT}/app/views") unless File.exists?("#{RAILS_ROOT}/app/views")
- Dir.mkdir("#{RAILS_ROOT}/app/views/layouts") unless File.exists?("#{RAILS_ROOT}/app/views/layouts")
- Dir.mkdir("#{RAILS_ROOT}/config") unless File.exists?("#{RAILS_ROOT}/config")
- Dir.mkdir("#{RAILS_ROOT}/db") unless File.exists?("#{RAILS_ROOT}/db")
- Dir.mkdir("#{RAILS_ROOT}/test") unless File.exists?("#{RAILS_ROOT}/test")
- Dir.mkdir("#{RAILS_ROOT}/test/fixtures") unless File.exists?("#{RAILS_ROOT}/test/fixtures")
- Dir.mkdir("#{RAILS_ROOT}/public") unless File.exists?("#{RAILS_ROOT}/public")
- Dir.mkdir("#{RAILS_ROOT}/public/stylesheets") unless File.exists?("#{RAILS_ROOT}/public/stylesheets")
+ Dir.mkdir("#{RAILS_ROOT}/app") unless File.exist?("#{RAILS_ROOT}/app")
+ Dir.mkdir("#{RAILS_ROOT}/app/views") unless File.exist?("#{RAILS_ROOT}/app/views")
+ Dir.mkdir("#{RAILS_ROOT}/app/views/layouts") unless File.exist?("#{RAILS_ROOT}/app/views/layouts")
+ Dir.mkdir("#{RAILS_ROOT}/config") unless File.exist?("#{RAILS_ROOT}/config")
+ Dir.mkdir("#{RAILS_ROOT}/db") unless File.exist?("#{RAILS_ROOT}/db")
+ Dir.mkdir("#{RAILS_ROOT}/test") unless File.exist?("#{RAILS_ROOT}/test")
+ Dir.mkdir("#{RAILS_ROOT}/test/fixtures") unless File.exist?("#{RAILS_ROOT}/test/fixtures")
+ Dir.mkdir("#{RAILS_ROOT}/public") unless File.exist?("#{RAILS_ROOT}/public")
+ Dir.mkdir("#{RAILS_ROOT}/public/stylesheets") unless File.exist?("#{RAILS_ROOT}/public/stylesheets")
File.open("#{RAILS_ROOT}/config/routes.rb", 'w') do |f|
f<<"ActionController::Routing::Routes.draw do |map|\n\nend\n"
end
diff --git a/railties/test/generators/rails_scaffold_generator_test.rb b/railties/test/generators/rails_scaffold_generator_test.rb
index 4de175b45e..16588affab 100644
--- a/railties/test/generators/rails_scaffold_generator_test.rb
+++ b/railties/test/generators/rails_scaffold_generator_test.rb
@@ -48,7 +48,7 @@ if defined?(RAILS_ROOT)
else
RAILS_ROOT=tmp_dir
end
-Dir.mkdir(RAILS_ROOT) unless File.exists?(RAILS_ROOT)
+Dir.mkdir(RAILS_ROOT) unless File.exist?(RAILS_ROOT)
$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../../lib"
require 'rails_generator'
@@ -60,15 +60,15 @@ class RailsScaffoldGeneratorTest < Test::Unit::TestCase
def setup
ActiveRecord::Base.pluralize_table_names = true
- Dir.mkdir("#{RAILS_ROOT}/app") unless File.exists?("#{RAILS_ROOT}/app")
- Dir.mkdir("#{RAILS_ROOT}/app/views") unless File.exists?("#{RAILS_ROOT}/app/views")
- Dir.mkdir("#{RAILS_ROOT}/app/views/layouts") unless File.exists?("#{RAILS_ROOT}/app/views/layouts")
- Dir.mkdir("#{RAILS_ROOT}/config") unless File.exists?("#{RAILS_ROOT}/config")
- Dir.mkdir("#{RAILS_ROOT}/db") unless File.exists?("#{RAILS_ROOT}/db")
- Dir.mkdir("#{RAILS_ROOT}/test") unless File.exists?("#{RAILS_ROOT}/test")
- Dir.mkdir("#{RAILS_ROOT}/test/fixtures") unless File.exists?("#{RAILS_ROOT}/test/fixtures")
- Dir.mkdir("#{RAILS_ROOT}/public") unless File.exists?("#{RAILS_ROOT}/public")
- Dir.mkdir("#{RAILS_ROOT}/public/stylesheets") unless File.exists?("#{RAILS_ROOT}/public/stylesheets")
+ Dir.mkdir("#{RAILS_ROOT}/app") unless File.exist?("#{RAILS_ROOT}/app")
+ Dir.mkdir("#{RAILS_ROOT}/app/views") unless File.exist?("#{RAILS_ROOT}/app/views")
+ Dir.mkdir("#{RAILS_ROOT}/app/views/layouts") unless File.exist?("#{RAILS_ROOT}/app/views/layouts")
+ Dir.mkdir("#{RAILS_ROOT}/config") unless File.exist?("#{RAILS_ROOT}/config")
+ Dir.mkdir("#{RAILS_ROOT}/db") unless File.exist?("#{RAILS_ROOT}/db")
+ Dir.mkdir("#{RAILS_ROOT}/test") unless File.exist?("#{RAILS_ROOT}/test")
+ Dir.mkdir("#{RAILS_ROOT}/test/fixtures") unless File.exist?("#{RAILS_ROOT}/test/fixtures")
+ Dir.mkdir("#{RAILS_ROOT}/public") unless File.exist?("#{RAILS_ROOT}/public")
+ Dir.mkdir("#{RAILS_ROOT}/public/stylesheets") unless File.exist?("#{RAILS_ROOT}/public/stylesheets")
File.open("#{RAILS_ROOT}/config/routes.rb", 'w') do |f|
f<<"ActionController::Routing::Routes.draw do |map|\n\nend\n"
end