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

Ticket #1689: 1.9_case_file_exist_compat.diff

File 1.9_case_file_exist_compat.diff, 4.8 kB (added by chuyeow, 7 months ago)

switch statement compat + more File.exists? -> File.exist?

  • railties/test/boot_test.rb

    old new  
    3636 
    3737  def test_boot_vendor_rails_by_default 
    3838    Rails.expects(:booted?).returns(false) 
     39    Rails.expects(:preinitialize) 
    3940    File.expects(:exist?).with("#{RAILS_ROOT}/vendor/rails").returns(true) 
    4041    Rails::VendorBoot.any_instance.expects(:run).returns('result') 
    4142    assert_equal 'result', Rails.boot! 
     
    4344 
    4445  def test_boot_gem_rails_otherwise 
    4546    Rails.expects(:booted?).returns(false) 
     47    Rails.expects(:preinitialize) 
    4648    File.expects(:exist?).with("#{RAILS_ROOT}/vendor/rails").returns(false) 
    4749    Rails::GemBoot.any_instance.expects(:run).returns('result') 
    4850    assert_equal 'result', Rails.boot! 
  • railties/environments/boot.rb

    old new  
    2424      File.exist?("#{RAILS_ROOT}/vendor/rails") 
    2525    end 
    2626 
    27     # FIXME : Ruby 1.9 
    2827    def preinitialize 
    29       load(preinitializer_path) if File.exists?(preinitializer_path) 
     28      load(preinitializer_path) if File.exist?(preinitializer_path) 
    3029    end 
    3130 
    3231    def preinitializer_path 
  • railties/dispatches/gateway.cgi

    old new  
    3131  File.expand_path(File.join(File.dirname(__FILE__), "../log/drb_gateway/listener_#{number}.sock")) 
    3232end 
    3333 
    34 unless File.exists? TrackerSocket 
     34unless File.exist? TrackerSocket 
    3535  message "Starting tracker and #{Listeners} listeners" 
    3636  fork do 
    3737    Process.setsid 
     
    6262  ready = false 
    6363  10.times do 
    6464    sleep 0.5 
    65     break if (ready = File.exists?(TrackerSocket) && File.exists?(listener_socket(0))) 
     65    break if (ready = File.exist?(TrackerSocket) && File.exist?(listener_socket(0))) 
    6666  end 
    6767 
    6868  if ready 
  • railties/lib/tasks/documentation.rake

    old new  
    6565        options << '-T html' 
    6666 
    6767        files.include("#{plugin_base}/lib/**/*.rb") 
    68         if File.exists?("#{plugin_base}/README") 
     68        if File.exist?("#{plugin_base}/README") 
    6969          files.include("#{plugin_base}/README")     
    7070          options << "--main '#{plugin_base}/README'" 
    7171        end 
    72         files.include("#{plugin_base}/CHANGELOG") if File.exists?("#{plugin_base}/CHANGELOG") 
     72        files.include("#{plugin_base}/CHANGELOG") if File.exist?("#{plugin_base}/CHANGELOG") 
    7373 
    7474        options << files.to_s 
    7575 
  • railties/lib/tasks/framework.rake

    old new  
    105105      require 'railties_path'   
    106106      project_dir = RAILS_ROOT + '/public/javascripts/' 
    107107      scripts = Dir[RAILTIES_PATH + '/html/javascripts/*.js'] 
    108       scripts.reject!{|s| File.basename(s) == 'application.js'} if File.exists?(project_dir + 'application.js') 
     108      scripts.reject!{|s| File.basename(s) == 'application.js'} if File.exist?(project_dir + 'application.js') 
    109109      FileUtils.cp(scripts, project_dir) 
    110110    end 
    111111 
  • railties/lib/tasks/testing.rake

    old new  
    1313 
    1414      # For modified files in app/ run the tests for it. ex. /test/functional/account_controller.rb 
    1515      test = "#{modified_test_path}/#{source_file}_test.rb" 
    16       tests.push test if File.exists?(test) 
     16      tests.push test if File.exist?(test) 
    1717 
    1818      # For modified files in app, run tests in subdirs too. ex. /test/functional/account/*_test.rb 
    1919      test = "#{modified_test_path}/#{File.basename(path, '.rb').sub("_controller","")}" 
    20       FileList["#{test}/*_test.rb"].each { |f| tests.push f } if File.exists?(test) 
     20      FileList["#{test}/*_test.rb"].each { |f| tests.push f } if File.exist?(test) 
    2121                 
    2222      return tests 
    2323 
  • railties/lib/commands/console.rb

    old new  
    1616libs << " -r console_with_helpers" 
    1717 
    1818ENV['RAILS_ENV'] = case ARGV.first 
    19   when "p": "production" 
    20   when "d": "development" 
    21   when "t": "test" 
     19  when "p"; "production" 
     20  when "d"; "development" 
     21  when "t"; "test" 
    2222  else 
    2323    ARGV.first || ENV['RAILS_ENV'] || 'development' 
    2424end