Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

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  
    1010  def self.download(from, to) 
    1111    unless File.exist?(to) 
    1212      $stderr.puts "Downloading #{from} to #{to}" 
    13       unless File.exists?(File.dirname(to)) 
     13      unless File.exist?(File.dirname(to)) 
    1414        system "mkdir -p #{File.dirname(to)}" 
    1515      end 
    1616      open(from) do |source| 
     
    3131  end unless ''.respond_to?(:ui) 
    3232end 
    3333 
    34 Dir.mkdir(CACHE_DIR) unless File.exists?(CACHE_DIR) 
     34Dir.mkdir(CACHE_DIR) unless File.exist?(CACHE_DIR) 
    3535Downloader.download(UNIDATA_URL + UNIDATA_FILE, CACHE_DIR + UNIDATA_FILE) 
    3636 
    3737module ConformanceTest 
  • activerecord/test/aaa_create_tables_test.rb

    old new  
    3333  private 
    3434    def use_migrations? 
    3535      unittest_sql_filename = ActiveRecord::Base.connection.adapter_name.downcase + ".sql" 
    36       not File.exists? "#{@base_path}/#{unittest_sql_filename}" 
     36      not File.exist? "#{@base_path}/#{unittest_sql_filename}" 
    3737    end 
    3838 
    3939    def use_migrations_for_courses? 
    4040      unittest2_sql_filename = ActiveRecord::Base.connection.adapter_name.downcase + "2.sql" 
    41       not File.exists? "#{@base_path}/#{unittest2_sql_filename}" 
     41      not File.exist? "#{@base_path}/#{unittest2_sql_filename}" 
    4242    end 
    4343 
    4444    def recreate(base, suffix = nil) 
  • activerecord/test/associations_test.rb

    old new  
    5555  def test_storing_in_pstore 
    5656    require "tmpdir" 
    5757    store_filename = File.join(Dir.tmpdir, "ar-pstore-association-test") 
    58     File.delete(store_filename) if File.exists?(store_filename) 
     58    File.delete(store_filename) if File.exist?(store_filename) 
    5959    require "pstore" 
    6060    apple = Firm.create("name" => "Apple") 
    6161    natural = Client.new("name" => "Natural Company") 
  • actionpack/test/template/asset_tag_helper_test.rb

    old new  
    234234      javascript_include_tag(:all, :cache => true) 
    235235    ) 
    236236 
    237     assert File.exists?(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'all.js')) 
     237    assert File.exist?(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'all.js')) 
    238238     
    239239    assert_dom_equal( 
    240240      %(<script src="http://a2.example.com/javascripts/money.js" type="text/javascript"></script>), 
    241241      javascript_include_tag(:all, :cache => "money") 
    242242    ) 
    243243 
    244     assert File.exists?(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'money.js')) 
     244    assert File.exist?(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'money.js')) 
    245245 
    246246  ensure 
    247247    File.delete(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'all.js')) 
     
    258258      javascript_include_tag(:all, :cache => "cache/money") 
    259259    ) 
    260260 
    261     assert File.exists?(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'cache', 'money.js')) 
     261    assert File.exist?(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'cache', 'money.js')) 
    262262  ensure 
    263263    File.delete(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'cache', 'money.js')) 
    264264  end 
     
    272272      javascript_include_tag(:all, :cache => true) 
    273273    ) 
    274274 
    275     assert !File.exists?(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'all.js')) 
     275    assert !File.exist?(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'all.js')) 
    276276     
    277277    assert_dom_equal( 
    278278      %(<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>), 
    279279      javascript_include_tag(:all, :cache => "money") 
    280280    ) 
    281281 
    282     assert !File.exists?(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'money.js')) 
     282    assert !File.exist?(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'money.js')) 
    283283  end 
    284284 
    285285  def test_caching_stylesheet_link_tag_when_caching_on 
     
    292292      stylesheet_link_tag(:all, :cache => true) 
    293293    ) 
    294294 
    295     assert File.exists?(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'all.css')) 
     295    assert File.exist?(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'all.css')) 
    296296 
    297297    assert_dom_equal( 
    298298      %(<link href="http://a3.example.com/stylesheets/money.css" media="screen" rel="stylesheet" type="text/css" />), 
    299299      stylesheet_link_tag(:all, :cache => "money") 
    300300    ) 
    301301 
    302     assert File.exists?(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'money.css')) 
     302    assert File.exist?(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'money.css')) 
    303303  ensure 
    304304    File.delete(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'all.css')) 
    305305    File.delete(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'money.css')) 
     
    314314      stylesheet_link_tag(:all, :cache => true) 
    315315    ) 
    316316 
    317     assert !File.exists?(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'all.css')) 
     317    assert !File.exist?(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'all.css')) 
    318318     
    319319    assert_dom_equal( 
    320320      %(<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" />), 
    321321      stylesheet_link_tag(:all, :cache => "money") 
    322322    ) 
    323323 
    324     assert !File.exists?(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'money.css')) 
     324    assert !File.exist?(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'money.css')) 
    325325  end 
    326326end 
    327327 
  • actionpack/lib/action_controller/caching.rb

    old new  
    8181          return unless perform_caching 
    8282 
    8383          benchmark "Expired page: #{page_cache_file(path)}" do 
    84             File.delete(page_cache_path(path)) if File.exists?(page_cache_path(path)) 
     84            File.delete(page_cache_path(path)) if File.exist?(page_cache_path(path)) 
    8585          end 
    8686        end 
    8787 
     
    552552          end 
    553553 
    554554          def ensure_cache_path(path) 
    555             FileUtils.makedirs(path) unless File.exists?(path) 
     555            FileUtils.makedirs(path) unless File.exist?(path) 
    556556          end 
    557557 
    558558          def search_dir(dir, &callback) 
  • actionpack/lib/action_controller/rescue.rb

    old new  
    154154      def render_optional_error_file(status_code) 
    155155        status = interpret_status(status_code) 
    156156        path = "#{RAILS_ROOT}/public/#{status[0,3]}.html" 
    157         if File.exists?(path) 
     157        if File.exist?(path) 
    158158          render :file => path, :status => status 
    159159        else 
    160160          head status 
  • railties/test/generators/rails_model_generator_test.rb

    old new  
    4646else 
    4747  RAILS_ROOT=tmp_dir 
    4848end 
    49 Dir.mkdir(RAILS_ROOT) unless File.exists?(RAILS_ROOT) 
     49Dir.mkdir(RAILS_ROOT) unless File.exist?(RAILS_ROOT) 
    5050 
    5151$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../../lib" 
    5252require 'rails_generator' 
     
    5757 
    5858  def setup 
    5959    ActiveRecord::Base.pluralize_table_names = true 
    60     Dir.mkdir("#{RAILS_ROOT}/app") unless File.exists?("#{RAILS_ROOT}/app") 
    61     Dir.mkdir("#{RAILS_ROOT}/app/views") unless File.exists?("#{RAILS_ROOT}/app/views") 
    62     Dir.mkdir("#{RAILS_ROOT}/app/views/layouts") unless File.exists?("#{RAILS_ROOT}/app/views/layouts") 
    63     Dir.mkdir("#{RAILS_ROOT}/config") unless File.exists?("#{RAILS_ROOT}/config") 
    64     Dir.mkdir("#{RAILS_ROOT}/db") unless File.exists?("#{RAILS_ROOT}/db") 
    65     Dir.mkdir("#{RAILS_ROOT}/test") unless File.exists?("#{RAILS_ROOT}/test") 
    66     Dir.mkdir("#{RAILS_ROOT}/test/fixtures") unless File.exists?("#{RAILS_ROOT}/test/fixtures") 
    67     Dir.mkdir("#{RAILS_ROOT}/public") unless File.exists?("#{RAILS_ROOT}/public") 
    68     Dir.mkdir("#{RAILS_ROOT}/public/stylesheets") unless File.exists?("#{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") 
    6969    File.open("#{RAILS_ROOT}/config/routes.rb", 'w') do |f| 
    7070      f<<"ActionController::Routing::Routes.draw do |map|\n\nend\n" 
    7171    end 
  • railties/test/generators/rails_scaffold_generator_test.rb

    old new  
    4848else 
    4949  RAILS_ROOT=tmp_dir 
    5050end 
    51 Dir.mkdir(RAILS_ROOT) unless File.exists?(RAILS_ROOT) 
     51Dir.mkdir(RAILS_ROOT) unless File.exist?(RAILS_ROOT) 
    5252 
    5353$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../../lib" 
    5454require 'rails_generator' 
     
    6060 
    6161  def setup 
    6262    ActiveRecord::Base.pluralize_table_names = true 
    63     Dir.mkdir("#{RAILS_ROOT}/app") unless File.exists?("#{RAILS_ROOT}/app") 
    64     Dir.mkdir("#{RAILS_ROOT}/app/views") unless File.exists?("#{RAILS_ROOT}/app/views") 
    65     Dir.mkdir("#{RAILS_ROOT}/app/views/layouts") unless File.exists?("#{RAILS_ROOT}/app/views/layouts") 
    66     Dir.mkdir("#{RAILS_ROOT}/config") unless File.exists?("#{RAILS_ROOT}/config") 
    67     Dir.mkdir("#{RAILS_ROOT}/db") unless File.exists?("#{RAILS_ROOT}/db") 
    68     Dir.mkdir("#{RAILS_ROOT}/test") unless File.exists?("#{RAILS_ROOT}/test") 
    69     Dir.mkdir("#{RAILS_ROOT}/test/fixtures") unless File.exists?("#{RAILS_ROOT}/test/fixtures") 
    70     Dir.mkdir("#{RAILS_ROOT}/public") unless File.exists?("#{RAILS_ROOT}/public") 
    71     Dir.mkdir("#{RAILS_ROOT}/public/stylesheets") unless File.exists?("#{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") 
    7272    File.open("#{RAILS_ROOT}/config/routes.rb", 'w') do |f| 
    7373      f<<"ActionController::Routing::Routes.draw do |map|\n\nend\n" 
    7474    end 
  • railties/test/generators/generator_test_helper.rb

    old new  
    7777 
    7878  # asserts that the given file exists 
    7979  def assert_file_exists(path) 
    80     assert File.exists?("#{RAILS_ROOT}/#{path}"),"The file '#{path}' should exist" 
     80    assert File.exist?("#{RAILS_ROOT}/#{path}"),"The file '#{path}' should exist" 
    8181  end 
    8282 
    8383  # asserts that the given class source file was generated. 
     
    158158  # It takes the name of the migration as a parameter. 
    159159  def assert_skipped_migration(name) 
    160160    migration_file = "#{RAILS_ROOT}/db/migrate/001_#{name.to_s.underscore}.rb" 
    161     assert !File.exists?(migration_file), "should not create migration #{migration_file}" 
     161    assert !File.exist?(migration_file), "should not create migration #{migration_file}" 
    162162  end 
    163163 
    164164  # asserts that the given resource was added to the routes. 
  • railties/test/generators/rails_resource_generator_test.rb

    old new  
    4646else 
    4747  RAILS_ROOT=tmp_dir 
    4848end 
    49 Dir.mkdir(RAILS_ROOT) unless File.exists?(RAILS_ROOT) 
     49Dir.mkdir(RAILS_ROOT) unless File.exist?(RAILS_ROOT) 
    5050 
    5151$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../../lib" 
    5252require 'rails_generator' 
     
    5757 
    5858  def setup 
    5959    ActiveRecord::Base.pluralize_table_names = true 
    60     Dir.mkdir("#{RAILS_ROOT}/app") unless File.exists?("#{RAILS_ROOT}/app") 
    61     Dir.mkdir("#{RAILS_ROOT}/app/views") unless File.exists?("#{RAILS_ROOT}/app/views") 
    62     Dir.mkdir("#{RAILS_ROOT}/app/views/layouts") unless File.exists?("#{RAILS_ROOT}/app/views/layouts") 
    63     Dir.mkdir("#{RAILS_ROOT}/config") unless File.exists?("#{RAILS_ROOT}/config") 
    64     Dir.mkdir("#{RAILS_ROOT}/db") unless File.exists?("#{RAILS_ROOT}/db") 
    65     Dir.mkdir("#{RAILS_ROOT}/test") unless File.exists?("#{RAILS_ROOT}/test") 
    66     Dir.mkdir("#{RAILS_ROOT}/test/fixtures") unless File.exists?("#{RAILS_ROOT}/test/fixtures") 
    67     Dir.mkdir("#{RAILS_ROOT}/public") unless File.exists?("#{RAILS_ROOT}/public") 
    68     Dir.mkdir("#{RAILS_ROOT}/public/stylesheets") unless File.exists?("#{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") 
    6969    File.open("#{RAILS_ROOT}/config/routes.rb", 'w') do |f| 
    7070      f<<"ActionController::Routing::Routes.draw do |map|\n\nend\n" 
    7171    end 
  • railties/environments/boot.rb

    old new  
    2323    def vendor_rails? 
    2424      File.exist?("#{RAILS_ROOT}/vendor/rails") 
    2525    end 
    26  
     26     
     27    # FIXME : Ruby 1.9 
    2728    def preinitialize 
    2829      load(preinitializer_path) if File.exists?(preinitializer_path) 
    2930    end 
  • railties/lib/rails_generator/commands.rb

    old new  
    207207          # Determine full paths for source and destination files. 
    208208          source              = source_path(relative_source) 
    209209          destination         = destination_path(relative_destination) 
    210           destination_exists  = File.exists?(destination) 
     210          destination_exists  = File.exist?(destination) 
    211211 
    212212          # If source and destination are identical then we're done. 
    213213          if destination_exists and identical?(source, destination, &block) 
     
    306306        # Always directories which exist. 
    307307        def directory(relative_path) 
    308308          path = destination_path(relative_path) 
    309           if File.exists?(path) 
     309          if File.exist?(path) 
    310310            logger.exists relative_path 
    311311          else 
    312312            logger.create relative_path 
     
    415415        # Remove a file if it exists and is a file. 
    416416        def file(relative_source, relative_destination, file_options = {}) 
    417417          destination = destination_path(relative_destination) 
    418           if File.exists?(destination) 
     418          if File.exist?(destination) 
    419419            logger.rm relative_destination 
    420420            unless options[:pretend] 
    421421              if options[:svn] 
     
    450450          until parts.empty? 
    451451            partial = File.join(parts) 
    452452            path = destination_path(partial) 
    453             if File.exists?(path) 
     453            if File.exist?(path) 
    454454              if Dir[File.join(path, '*')].empty? 
    455455                logger.rmdir partial 
    456456                unless options[:pretend] 
  • railties/lib/rails_generator/secret_key_generator.rb

    old new  
    141141      end 
    142142 
    143143      def self.supports_urandom? 
    144         File.exists?('/dev/urandom') 
     144        File.exist?('/dev/urandom') 
    145145      end 
    146146 
    147147      def self.supports_openssl? 
  • railties/lib/rails_generator/generators/applications/app/app_generator.rb

    old new  
    128128    end 
    129129 
    130130    def mysql_socket_location 
    131       MYSQL_SOCKET_LOCATIONS.find { |f| File.exists?(f) } unless RUBY_PLATFORM =~ /(:?mswin|mingw)/ 
     131      MYSQL_SOCKET_LOCATIONS.find { |f| File.exist?(f) } unless RUBY_PLATFORM =~ /(:?mswin|mingw)/ 
    132132    end 
    133133 
    134134 
  • railties/lib/commands/plugin.rb

    old new  
    214214 
    215215    def run_install_hook 
    216216      install_hook_file = "#{rails_env.root}/vendor/plugins/#{name}/install.rb" 
    217       load install_hook_file if File.exists? install_hook_file 
     217      load install_hook_file if File.exist? install_hook_file 
    218218    end 
    219219 
    220220    def run_uninstall_hook 
    221221      uninstall_hook_file = "#{rails_env.root}/vendor/plugins/#{name}/uninstall.rb" 
    222       load uninstall_hook_file if File.exists? uninstall_hook_file 
     222      load uninstall_hook_file if File.exist? uninstall_hook_file 
    223223    end 
    224224 
    225225    def install_using_export(options = {}) 
  • railties/lib/commands/runner.rb

    old new  
    4141if code_or_file.nil? 
    4242  $stderr.puts "Run '#{$0} -h' for help." 
    4343  exit 1 
    44 elsif File.exists?(code_or_file) 
     44elsif File.exist?(code_or_file) 
    4545  eval(File.read(code_or_file)) 
    4646else 
    4747  eval(code_or_file) 
  • railties/builtin/rails_info/rails/info.rb

    old new  
    3232      end 
    3333 
    3434      def freeze_edge_version 
    35         if File.exists?(rails_vendor_root) 
     35        if File.exist?(rails_vendor_root) 
    3636          begin 
    3737            Dir[File.join(rails_vendor_root, 'REVISION_*')].first.scan(/_(\d+)$/).first.first 
    3838          rescue