1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

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
This commit is contained in:
Jeremy Kemper 2007-12-10 05:54:46 +00:00
parent c81fff2468
commit b1ce7e4d4a
17 changed files with 60 additions and 59 deletions

View file

@ -81,7 +81,7 @@ module ActionController #:nodoc:
return unless perform_caching
benchmark "Expired page: #{page_cache_file(path)}" do
File.delete(page_cache_path(path)) if File.exists?(page_cache_path(path))
File.delete(page_cache_path(path)) if File.exist?(page_cache_path(path))
end
end
@ -552,7 +552,7 @@ module ActionController #:nodoc:
end
def ensure_cache_path(path)
FileUtils.makedirs(path) unless File.exists?(path)
FileUtils.makedirs(path) unless File.exist?(path)
end
def search_dir(dir, &callback)

View file

@ -154,7 +154,7 @@ module ActionController #:nodoc:
def render_optional_error_file(status_code)
status = interpret_status(status_code)
path = "#{RAILS_ROOT}/public/#{status[0,3]}.html"
if File.exists?(path)
if File.exist?(path)
render :file => path, :status => status
else
head status

View file

@ -234,14 +234,14 @@ class AssetTagHelperTest < Test::Unit::TestCase
javascript_include_tag(:all, :cache => true)
)
assert File.exists?(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'all.js'))
assert File.exist?(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'all.js'))
assert_dom_equal(
%(<script src="http://a2.example.com/javascripts/money.js" type="text/javascript"></script>),
javascript_include_tag(:all, :cache => "money")
)
assert File.exists?(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'money.js'))
assert File.exist?(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'money.js'))
ensure
File.delete(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'all.js'))
@ -258,7 +258,7 @@ class AssetTagHelperTest < Test::Unit::TestCase
javascript_include_tag(:all, :cache => "cache/money")
)
assert File.exists?(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'cache', 'money.js'))
assert File.exist?(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'cache', 'money.js'))
ensure
File.delete(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'cache', 'money.js'))
end
@ -272,14 +272,14 @@ class AssetTagHelperTest < Test::Unit::TestCase
javascript_include_tag(:all, :cache => true)
)
assert !File.exists?(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'all.js'))
assert !File.exist?(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'all.js'))
assert_dom_equal(
%(<script src="/javascripts/application.js" type="text/javascript"></script>\n<script src="/javascripts/bank.js" type="text/javascript"></script>\n<script src="/javascripts/robber.js" type="text/javascript"></script>),
javascript_include_tag(:all, :cache => "money")
)
assert !File.exists?(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'money.js'))
assert !File.exist?(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'money.js'))
end
def test_caching_stylesheet_link_tag_when_caching_on
@ -292,14 +292,14 @@ class AssetTagHelperTest < Test::Unit::TestCase
stylesheet_link_tag(:all, :cache => true)
)
assert File.exists?(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'all.css'))
assert File.exist?(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'all.css'))
assert_dom_equal(
%(<link href="http://a3.example.com/stylesheets/money.css" media="screen" rel="stylesheet" type="text/css" />),
stylesheet_link_tag(:all, :cache => "money")
)
assert File.exists?(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'money.css'))
assert File.exist?(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'money.css'))
ensure
File.delete(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'all.css'))
File.delete(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'money.css'))
@ -314,14 +314,14 @@ class AssetTagHelperTest < Test::Unit::TestCase
stylesheet_link_tag(:all, :cache => true)
)
assert !File.exists?(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'all.css'))
assert !File.exist?(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'all.css'))
assert_dom_equal(
%(<link href="/stylesheets/bank.css" media="screen" rel="stylesheet" type="text/css" />\n<link href="/stylesheets/robber.css" media="screen" rel="stylesheet" type="text/css" />),
stylesheet_link_tag(:all, :cache => "money")
)
assert !File.exists?(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'money.css'))
assert !File.exist?(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'money.css'))
end
end

View file

@ -33,12 +33,12 @@ class AAACreateTablesTest < Test::Unit::TestCase
private
def use_migrations?
unittest_sql_filename = ActiveRecord::Base.connection.adapter_name.downcase + ".sql"
not File.exists? "#{@base_path}/#{unittest_sql_filename}"
not File.exist? "#{@base_path}/#{unittest_sql_filename}"
end
def use_migrations_for_courses?
unittest2_sql_filename = ActiveRecord::Base.connection.adapter_name.downcase + "2.sql"
not File.exists? "#{@base_path}/#{unittest2_sql_filename}"
not File.exist? "#{@base_path}/#{unittest2_sql_filename}"
end
def recreate(base, suffix = nil)

View file

@ -55,7 +55,7 @@ class AssociationsTest < Test::Unit::TestCase
def test_storing_in_pstore
require "tmpdir"
store_filename = File.join(Dir.tmpdir, "ar-pstore-association-test")
File.delete(store_filename) if File.exists?(store_filename)
File.delete(store_filename) if File.exist?(store_filename)
require "pstore"
apple = Firm.create("name" => "Apple")
natural = Client.new("name" => "Natural Company")

View file

@ -10,7 +10,7 @@ class Downloader
def self.download(from, to)
unless File.exist?(to)
$stderr.puts "Downloading #{from} to #{to}"
unless File.exists?(File.dirname(to))
unless File.exist?(File.dirname(to))
system "mkdir -p #{File.dirname(to)}"
end
open(from) do |source|
@ -31,7 +31,7 @@ class String
end unless ''.respond_to?(:ui)
end
Dir.mkdir(CACHE_DIR) unless File.exists?(CACHE_DIR)
Dir.mkdir(CACHE_DIR) unless File.exist?(CACHE_DIR)
Downloader.download(UNIDATA_URL + UNIDATA_FILE, CACHE_DIR + UNIDATA_FILE)
module ConformanceTest

View file

@ -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

View file

@ -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

View file

@ -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 = {})

View file

@ -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)

View file

@ -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]

View file

@ -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

View file

@ -141,7 +141,7 @@ module Rails
end
def self.supports_urandom?
File.exists?('/dev/urandom')
File.exist?('/dev/urandom')
end
def self.supports_openssl?

View file

@ -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.

View file

@ -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

View file

@ -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

View file

@ -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