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

Changeset 8365

Show
Ignore:
Timestamp:
12/10/07 05:54:46 (2 years ago)
Author:
bitsweat
Message:

Ruby 1.9 compat: File.exists\? -> File.exist\? en masse. References #1689 [Pratik Naik]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/actionpack/lib/action_controller/caching.rb

    r8307 r8365  
    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 
     
    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 
  • trunk/actionpack/lib/action_controller/rescue.rb

    r8301 r8365  
    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 
  • trunk/actionpack/test/template/asset_tag_helper_test.rb

    r8110 r8365  
    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( 
     
    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 
     
    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')) 
     
    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( 
     
    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 
     
    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( 
     
    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')) 
     
    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( 
     
    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 
  • trunk/activerecord/test/aaa_create_tables_test.rb

    r7972 r8365  
    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 
  • trunk/activerecord/test/associations_test.rb

    r8347 r8365  
    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") 
  • trunk/activesupport/test/multibyte_conformance.rb

    r5223 r8365  
    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 
     
    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 
  • trunk/railties/builtin/rails_info/rails/info.rb

    r7914 r8365  
    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 
  • trunk/railties/environments/boot.rb

    r8358 r8365  
    2525    end 
    2626 
     27    # FIXME : Ruby 1.9 
    2728    def preinitialize 
    2829      load(preinitializer_path) if File.exists?(preinitializer_path) 
  • trunk/railties/lib/commands/plugin.rb

    r8175 r8365  
    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 
  • trunk/railties/lib/commands/runner.rb

    r5203 r8365  
    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 
  • trunk/railties/lib/rails_generator/commands.rb

    r7963 r8365  
    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. 
     
    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 
     
    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] 
     
    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 
  • trunk/railties/lib/rails_generator/generators/applications/app/app_generator.rb

    r8229 r8365  
    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 
  • trunk/railties/lib/rails_generator/secret_key_generator.rb

    r8229 r8365  
    142142 
    143143      def self.supports_urandom? 
    144         File.exists?('/dev/urandom') 
     144        File.exist?('/dev/urandom') 
    145145      end 
    146146 
  • trunk/railties/test/generators/generator_test_helper.rb

    r8301 r8365  
    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 
     
    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 
  • trunk/railties/test/generators/rails_model_generator_test.rb

    r7840 r8365  
    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" 
     
    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" 
  • trunk/railties/test/generators/rails_resource_generator_test.rb

    r7839 r8365  
    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" 
     
    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" 
  • trunk/railties/test/generators/rails_scaffold_generator_test.rb

    r7108 r8365  
    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" 
     
    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"