Ticket #1689: file_exist.patch
| File file_exist.patch, 20.3 kB (added by lifofifo, 7 months ago) |
|---|
-
activesupport/test/multibyte_conformance.rb
old new 10 10 def self.download(from, to) 11 11 unless File.exist?(to) 12 12 $stderr.puts "Downloading #{from} to #{to}" 13 unless File.exist s?(File.dirname(to))13 unless File.exist?(File.dirname(to)) 14 14 system "mkdir -p #{File.dirname(to)}" 15 15 end 16 16 open(from) do |source| … … 31 31 end unless ''.respond_to?(:ui) 32 32 end 33 33 34 Dir.mkdir(CACHE_DIR) unless File.exist s?(CACHE_DIR)34 Dir.mkdir(CACHE_DIR) unless File.exist?(CACHE_DIR) 35 35 Downloader.download(UNIDATA_URL + UNIDATA_FILE, CACHE_DIR + UNIDATA_FILE) 36 36 37 37 module ConformanceTest -
activerecord/test/aaa_create_tables_test.rb
old new 33 33 private 34 34 def use_migrations? 35 35 unittest_sql_filename = ActiveRecord::Base.connection.adapter_name.downcase + ".sql" 36 not File.exist s? "#{@base_path}/#{unittest_sql_filename}"36 not File.exist? "#{@base_path}/#{unittest_sql_filename}" 37 37 end 38 38 39 39 def use_migrations_for_courses? 40 40 unittest2_sql_filename = ActiveRecord::Base.connection.adapter_name.downcase + "2.sql" 41 not File.exist s? "#{@base_path}/#{unittest2_sql_filename}"41 not File.exist? "#{@base_path}/#{unittest2_sql_filename}" 42 42 end 43 43 44 44 def recreate(base, suffix = nil) -
activerecord/test/associations_test.rb
old new 55 55 def test_storing_in_pstore 56 56 require "tmpdir" 57 57 store_filename = File.join(Dir.tmpdir, "ar-pstore-association-test") 58 File.delete(store_filename) if File.exist s?(store_filename)58 File.delete(store_filename) if File.exist?(store_filename) 59 59 require "pstore" 60 60 apple = Firm.create("name" => "Apple") 61 61 natural = Client.new("name" => "Natural Company") -
actionpack/test/template/asset_tag_helper_test.rb
old new 234 234 javascript_include_tag(:all, :cache => true) 235 235 ) 236 236 237 assert File.exist s?(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'all.js'))237 assert File.exist?(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'all.js')) 238 238 239 239 assert_dom_equal( 240 240 %(<script src="http://a2.example.com/javascripts/money.js" type="text/javascript"></script>), 241 241 javascript_include_tag(:all, :cache => "money") 242 242 ) 243 243 244 assert File.exist s?(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'money.js'))244 assert File.exist?(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'money.js')) 245 245 246 246 ensure 247 247 File.delete(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'all.js')) … … 258 258 javascript_include_tag(:all, :cache => "cache/money") 259 259 ) 260 260 261 assert File.exist s?(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'cache', 'money.js'))261 assert File.exist?(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'cache', 'money.js')) 262 262 ensure 263 263 File.delete(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'cache', 'money.js')) 264 264 end … … 272 272 javascript_include_tag(:all, :cache => true) 273 273 ) 274 274 275 assert !File.exist s?(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'all.js'))275 assert !File.exist?(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'all.js')) 276 276 277 277 assert_dom_equal( 278 278 %(<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>), 279 279 javascript_include_tag(:all, :cache => "money") 280 280 ) 281 281 282 assert !File.exist s?(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'money.js'))282 assert !File.exist?(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'money.js')) 283 283 end 284 284 285 285 def test_caching_stylesheet_link_tag_when_caching_on … … 292 292 stylesheet_link_tag(:all, :cache => true) 293 293 ) 294 294 295 assert File.exist s?(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'all.css'))295 assert File.exist?(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'all.css')) 296 296 297 297 assert_dom_equal( 298 298 %(<link href="http://a3.example.com/stylesheets/money.css" media="screen" rel="stylesheet" type="text/css" />), 299 299 stylesheet_link_tag(:all, :cache => "money") 300 300 ) 301 301 302 assert File.exist s?(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'money.css'))302 assert File.exist?(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'money.css')) 303 303 ensure 304 304 File.delete(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'all.css')) 305 305 File.delete(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'money.css')) … … 314 314 stylesheet_link_tag(:all, :cache => true) 315 315 ) 316 316 317 assert !File.exist s?(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'all.css'))317 assert !File.exist?(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'all.css')) 318 318 319 319 assert_dom_equal( 320 320 %(<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" />), 321 321 stylesheet_link_tag(:all, :cache => "money") 322 322 ) 323 323 324 assert !File.exist s?(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'money.css'))324 assert !File.exist?(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'money.css')) 325 325 end 326 326 end 327 327 -
actionpack/lib/action_controller/caching.rb
old new 81 81 return unless perform_caching 82 82 83 83 benchmark "Expired page: #{page_cache_file(path)}" do 84 File.delete(page_cache_path(path)) if File.exist s?(page_cache_path(path))84 File.delete(page_cache_path(path)) if File.exist?(page_cache_path(path)) 85 85 end 86 86 end 87 87 … … 552 552 end 553 553 554 554 def ensure_cache_path(path) 555 FileUtils.makedirs(path) unless File.exist s?(path)555 FileUtils.makedirs(path) unless File.exist?(path) 556 556 end 557 557 558 558 def search_dir(dir, &callback) -
actionpack/lib/action_controller/rescue.rb
old new 154 154 def render_optional_error_file(status_code) 155 155 status = interpret_status(status_code) 156 156 path = "#{RAILS_ROOT}/public/#{status[0,3]}.html" 157 if File.exist s?(path)157 if File.exist?(path) 158 158 render :file => path, :status => status 159 159 else 160 160 head status -
railties/test/generators/rails_model_generator_test.rb
old new 46 46 else 47 47 RAILS_ROOT=tmp_dir 48 48 end 49 Dir.mkdir(RAILS_ROOT) unless File.exist s?(RAILS_ROOT)49 Dir.mkdir(RAILS_ROOT) unless File.exist?(RAILS_ROOT) 50 50 51 51 $LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../../lib" 52 52 require 'rails_generator' … … 57 57 58 58 def setup 59 59 ActiveRecord::Base.pluralize_table_names = true 60 Dir.mkdir("#{RAILS_ROOT}/app") unless File.exist s?("#{RAILS_ROOT}/app")61 Dir.mkdir("#{RAILS_ROOT}/app/views") unless File.exist s?("#{RAILS_ROOT}/app/views")62 Dir.mkdir("#{RAILS_ROOT}/app/views/layouts") unless File.exist s?("#{RAILS_ROOT}/app/views/layouts")63 Dir.mkdir("#{RAILS_ROOT}/config") unless File.exist s?("#{RAILS_ROOT}/config")64 Dir.mkdir("#{RAILS_ROOT}/db") unless File.exist s?("#{RAILS_ROOT}/db")65 Dir.mkdir("#{RAILS_ROOT}/test") unless File.exist s?("#{RAILS_ROOT}/test")66 Dir.mkdir("#{RAILS_ROOT}/test/fixtures") unless File.exist s?("#{RAILS_ROOT}/test/fixtures")67 Dir.mkdir("#{RAILS_ROOT}/public") unless File.exist s?("#{RAILS_ROOT}/public")68 Dir.mkdir("#{RAILS_ROOT}/public/stylesheets") unless File.exist s?("#{RAILS_ROOT}/public/stylesheets")60 Dir.mkdir("#{RAILS_ROOT}/app") unless File.exist?("#{RAILS_ROOT}/app") 61 Dir.mkdir("#{RAILS_ROOT}/app/views") unless File.exist?("#{RAILS_ROOT}/app/views") 62 Dir.mkdir("#{RAILS_ROOT}/app/views/layouts") unless File.exist?("#{RAILS_ROOT}/app/views/layouts") 63 Dir.mkdir("#{RAILS_ROOT}/config") unless File.exist?("#{RAILS_ROOT}/config") 64 Dir.mkdir("#{RAILS_ROOT}/db") unless File.exist?("#{RAILS_ROOT}/db") 65 Dir.mkdir("#{RAILS_ROOT}/test") unless File.exist?("#{RAILS_ROOT}/test") 66 Dir.mkdir("#{RAILS_ROOT}/test/fixtures") unless File.exist?("#{RAILS_ROOT}/test/fixtures") 67 Dir.mkdir("#{RAILS_ROOT}/public") unless File.exist?("#{RAILS_ROOT}/public") 68 Dir.mkdir("#{RAILS_ROOT}/public/stylesheets") unless File.exist?("#{RAILS_ROOT}/public/stylesheets") 69 69 File.open("#{RAILS_ROOT}/config/routes.rb", 'w') do |f| 70 70 f<<"ActionController::Routing::Routes.draw do |map|\n\nend\n" 71 71 end -
railties/test/generators/rails_scaffold_generator_test.rb
old new 48 48 else 49 49 RAILS_ROOT=tmp_dir 50 50 end 51 Dir.mkdir(RAILS_ROOT) unless File.exist s?(RAILS_ROOT)51 Dir.mkdir(RAILS_ROOT) unless File.exist?(RAILS_ROOT) 52 52 53 53 $LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../../lib" 54 54 require 'rails_generator' … … 60 60 61 61 def setup 62 62 ActiveRecord::Base.pluralize_table_names = true 63 Dir.mkdir("#{RAILS_ROOT}/app") unless File.exist s?("#{RAILS_ROOT}/app")64 Dir.mkdir("#{RAILS_ROOT}/app/views") unless File.exist s?("#{RAILS_ROOT}/app/views")65 Dir.mkdir("#{RAILS_ROOT}/app/views/layouts") unless File.exist s?("#{RAILS_ROOT}/app/views/layouts")66 Dir.mkdir("#{RAILS_ROOT}/config") unless File.exist s?("#{RAILS_ROOT}/config")67 Dir.mkdir("#{RAILS_ROOT}/db") unless File.exist s?("#{RAILS_ROOT}/db")68 Dir.mkdir("#{RAILS_ROOT}/test") unless File.exist s?("#{RAILS_ROOT}/test")69 Dir.mkdir("#{RAILS_ROOT}/test/fixtures") unless File.exist s?("#{RAILS_ROOT}/test/fixtures")70 Dir.mkdir("#{RAILS_ROOT}/public") unless File.exist s?("#{RAILS_ROOT}/public")71 Dir.mkdir("#{RAILS_ROOT}/public/stylesheets") unless File.exist s?("#{RAILS_ROOT}/public/stylesheets")63 Dir.mkdir("#{RAILS_ROOT}/app") unless File.exist?("#{RAILS_ROOT}/app") 64 Dir.mkdir("#{RAILS_ROOT}/app/views") unless File.exist?("#{RAILS_ROOT}/app/views") 65 Dir.mkdir("#{RAILS_ROOT}/app/views/layouts") unless File.exist?("#{RAILS_ROOT}/app/views/layouts") 66 Dir.mkdir("#{RAILS_ROOT}/config") unless File.exist?("#{RAILS_ROOT}/config") 67 Dir.mkdir("#{RAILS_ROOT}/db") unless File.exist?("#{RAILS_ROOT}/db") 68 Dir.mkdir("#{RAILS_ROOT}/test") unless File.exist?("#{RAILS_ROOT}/test") 69 Dir.mkdir("#{RAILS_ROOT}/test/fixtures") unless File.exist?("#{RAILS_ROOT}/test/fixtures") 70 Dir.mkdir("#{RAILS_ROOT}/public") unless File.exist?("#{RAILS_ROOT}/public") 71 Dir.mkdir("#{RAILS_ROOT}/public/stylesheets") unless File.exist?("#{RAILS_ROOT}/public/stylesheets") 72 72 File.open("#{RAILS_ROOT}/config/routes.rb", 'w') do |f| 73 73 f<<"ActionController::Routing::Routes.draw do |map|\n\nend\n" 74 74 end -
railties/test/generators/generator_test_helper.rb
old new 77 77 78 78 # asserts that the given file exists 79 79 def assert_file_exists(path) 80 assert File.exist s?("#{RAILS_ROOT}/#{path}"),"The file '#{path}' should exist"80 assert File.exist?("#{RAILS_ROOT}/#{path}"),"The file '#{path}' should exist" 81 81 end 82 82 83 83 # asserts that the given class source file was generated. … … 158 158 # It takes the name of the migration as a parameter. 159 159 def assert_skipped_migration(name) 160 160 migration_file = "#{RAILS_ROOT}/db/migrate/001_#{name.to_s.underscore}.rb" 161 assert !File.exist s?(migration_file), "should not create migration #{migration_file}"161 assert !File.exist?(migration_file), "should not create migration #{migration_file}" 162 162 end 163 163 164 164 # asserts that the given resource was added to the routes. -
railties/test/generators/rails_resource_generator_test.rb
old new 46 46 else 47 47 RAILS_ROOT=tmp_dir 48 48 end 49 Dir.mkdir(RAILS_ROOT) unless File.exist s?(RAILS_ROOT)49 Dir.mkdir(RAILS_ROOT) unless File.exist?(RAILS_ROOT) 50 50 51 51 $LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../../lib" 52 52 require 'rails_generator' … … 57 57 58 58 def setup 59 59 ActiveRecord::Base.pluralize_table_names = true 60 Dir.mkdir("#{RAILS_ROOT}/app") unless File.exist s?("#{RAILS_ROOT}/app")61 Dir.mkdir("#{RAILS_ROOT}/app/views") unless File.exist s?("#{RAILS_ROOT}/app/views")62 Dir.mkdir("#{RAILS_ROOT}/app/views/layouts") unless File.exist s?("#{RAILS_ROOT}/app/views/layouts")63 Dir.mkdir("#{RAILS_ROOT}/config") unless File.exist s?("#{RAILS_ROOT}/config")64 Dir.mkdir("#{RAILS_ROOT}/db") unless File.exist s?("#{RAILS_ROOT}/db")65 Dir.mkdir("#{RAILS_ROOT}/test") unless File.exist s?("#{RAILS_ROOT}/test")66 Dir.mkdir("#{RAILS_ROOT}/test/fixtures") unless File.exist s?("#{RAILS_ROOT}/test/fixtures")67 Dir.mkdir("#{RAILS_ROOT}/public") unless File.exist s?("#{RAILS_ROOT}/public")68 Dir.mkdir("#{RAILS_ROOT}/public/stylesheets") unless File.exist s?("#{RAILS_ROOT}/public/stylesheets")60 Dir.mkdir("#{RAILS_ROOT}/app") unless File.exist?("#{RAILS_ROOT}/app") 61 Dir.mkdir("#{RAILS_ROOT}/app/views") unless File.exist?("#{RAILS_ROOT}/app/views") 62 Dir.mkdir("#{RAILS_ROOT}/app/views/layouts") unless File.exist?("#{RAILS_ROOT}/app/views/layouts") 63 Dir.mkdir("#{RAILS_ROOT}/config") unless File.exist?("#{RAILS_ROOT}/config") 64 Dir.mkdir("#{RAILS_ROOT}/db") unless File.exist?("#{RAILS_ROOT}/db") 65 Dir.mkdir("#{RAILS_ROOT}/test") unless File.exist?("#{RAILS_ROOT}/test") 66 Dir.mkdir("#{RAILS_ROOT}/test/fixtures") unless File.exist?("#{RAILS_ROOT}/test/fixtures") 67 Dir.mkdir("#{RAILS_ROOT}/public") unless File.exist?("#{RAILS_ROOT}/public") 68 Dir.mkdir("#{RAILS_ROOT}/public/stylesheets") unless File.exist?("#{RAILS_ROOT}/public/stylesheets") 69 69 File.open("#{RAILS_ROOT}/config/routes.rb", 'w') do |f| 70 70 f<<"ActionController::Routing::Routes.draw do |map|\n\nend\n" 71 71 end -
railties/environments/boot.rb
old new 23 23 def vendor_rails? 24 24 File.exist?("#{RAILS_ROOT}/vendor/rails") 25 25 end 26 26 27 # FIXME : Ruby 1.9 27 28 def preinitialize 28 29 load(preinitializer_path) if File.exists?(preinitializer_path) 29 30 end -
railties/lib/rails_generator/commands.rb
old new 207 207 # Determine full paths for source and destination files. 208 208 source = source_path(relative_source) 209 209 destination = destination_path(relative_destination) 210 destination_exists = File.exist s?(destination)210 destination_exists = File.exist?(destination) 211 211 212 212 # If source and destination are identical then we're done. 213 213 if destination_exists and identical?(source, destination, &block) … … 306 306 # Always directories which exist. 307 307 def directory(relative_path) 308 308 path = destination_path(relative_path) 309 if File.exist s?(path)309 if File.exist?(path) 310 310 logger.exists relative_path 311 311 else 312 312 logger.create relative_path … … 415 415 # Remove a file if it exists and is a file. 416 416 def file(relative_source, relative_destination, file_options = {}) 417 417 destination = destination_path(relative_destination) 418 if File.exist s?(destination)418 if File.exist?(destination) 419 419 logger.rm relative_destination 420 420 unless options[:pretend] 421 421 if options[:svn] … … 450 450 until parts.empty? 451 451 partial = File.join(parts) 452 452 path = destination_path(partial) 453 if File.exist s?(path)453 if File.exist?(path) 454 454 if Dir[File.join(path, '*')].empty? 455 455 logger.rmdir partial 456 456 unless options[:pretend] -
railties/lib/rails_generator/secret_key_generator.rb
old new 141 141 end 142 142 143 143 def self.supports_urandom? 144 File.exist s?('/dev/urandom')144 File.exist?('/dev/urandom') 145 145 end 146 146 147 147 def self.supports_openssl? -
railties/lib/rails_generator/generators/applications/app/app_generator.rb
old new 128 128 end 129 129 130 130 def mysql_socket_location 131 MYSQL_SOCKET_LOCATIONS.find { |f| File.exist s?(f) } unless RUBY_PLATFORM =~ /(:?mswin|mingw)/131 MYSQL_SOCKET_LOCATIONS.find { |f| File.exist?(f) } unless RUBY_PLATFORM =~ /(:?mswin|mingw)/ 132 132 end 133 133 134 134 -
railties/lib/commands/plugin.rb
old new 214 214 215 215 def run_install_hook 216 216 install_hook_file = "#{rails_env.root}/vendor/plugins/#{name}/install.rb" 217 load install_hook_file if File.exist s? install_hook_file217 load install_hook_file if File.exist? install_hook_file 218 218 end 219 219 220 220 def run_uninstall_hook 221 221 uninstall_hook_file = "#{rails_env.root}/vendor/plugins/#{name}/uninstall.rb" 222 load uninstall_hook_file if File.exist s? uninstall_hook_file222 load uninstall_hook_file if File.exist? uninstall_hook_file 223 223 end 224 224 225 225 def install_using_export(options = {}) -
railties/lib/commands/runner.rb
old new 41 41 if code_or_file.nil? 42 42 $stderr.puts "Run '#{$0} -h' for help." 43 43 exit 1 44 elsif File.exist s?(code_or_file)44 elsif File.exist?(code_or_file) 45 45 eval(File.read(code_or_file)) 46 46 else 47 47 eval(code_or_file) -
railties/builtin/rails_info/rails/info.rb
old new 32 32 end 33 33 34 34 def freeze_edge_version 35 if File.exist s?(rails_vendor_root)35 if File.exist?(rails_vendor_root) 36 36 begin 37 37 Dir[File.join(rails_vendor_root, 'REVISION_*')].first.scan(/_(\d+)$/).first.first 38 38 rescue