From 4b4f45ddd1b8ef1c8d46c7a70e023884f538d143 Mon Sep 17 00:00:00 2001 From: Thorsten Eckel Date: Thu, 30 Apr 2015 19:26:00 +0200 Subject: [PATCH] Corrected with rubocop cop 'Lint/DeprecatedClassMethods'. --- app/models/package.rb | 10 +++++----- config/boot.rb | 2 +- lib/sessions.rb | 10 +++++----- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/app/models/package.rb b/app/models/package.rb index f355adb63..0b01ee5c1 100644 --- a/app/models/package.rb +++ b/app/models/package.rb @@ -71,7 +71,7 @@ class Package < ApplicationModel File.delete( entry ) end backup_file = entry + '.link_backup' - if File.exists?( backup_file ) + if File.exist?( backup_file ) logger.info "Restore backup file of #{backup_file} -> #{entry}." File.rename( backup_file, entry ) end @@ -114,7 +114,7 @@ class Package < ApplicationModel end backup_file = dest.to_s + '.link_backup' - if File.exists?( backup_file ) + if File.exist?( backup_file ) logger.info "Restore backup file of #{backup_file} -> #{dest.to_s}." File.rename( backup_file, dest.to_s ) end @@ -145,7 +145,7 @@ class Package < ApplicationModel dest = @@root + '/' + file if File.directory?( entry.to_s ) - if !File.exists?( dest.to_s ) + if !File.exist?( dest.to_s ) logger.info "Create dir: #{dest.to_s}" FileUtils.mkdir_p( dest.to_s ) end @@ -153,7 +153,7 @@ class Package < ApplicationModel if File.file?( entry.to_s ) && ( File.file?( dest.to_s ) && !File.symlink?( dest.to_s ) ) backup_file = dest.to_s + '.link_backup' - if File.exists?( backup_file ) + if File.exist?( backup_file ) raise "Can't link #{entry.to_s} -> #{dest.to_s}, destination and .link_backup already exists!" else logger.info "Create backup file of #{dest.to_s} -> #{backup_file}." @@ -441,7 +441,7 @@ class Package < ApplicationModel def self.migrate( package, direction = 'normal' ) location = @@root + '/db/addon/' + package.underscore - return true if !File.exists?( location ) + return true if !File.exist?( location ) migrations_done = Package::Migration.where( name: package.underscore ) # get existing migrations diff --git a/config/boot.rb b/config/boot.rb index 4489e5868..f2830ae31 100644 --- a/config/boot.rb +++ b/config/boot.rb @@ -3,4 +3,4 @@ require 'rubygems' # Set up gems listed in the Gemfile. ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) -require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE']) +require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE']) diff --git a/lib/sessions.rb b/lib/sessions.rb index 9d1bf2ab8..05b0df90d 100644 --- a/lib/sessions.rb +++ b/lib/sessions.rb @@ -68,7 +68,7 @@ returns path = @path + '/' # just make sure that spool path exists - if !File::exists?( path ) + if !File::exist?( path ) FileUtils.mkpath path end @@ -270,7 +270,7 @@ returns check = true count = 0 while check - if File::exists?( path + filename ) + if File::exist?( path + filename ) count += 1 filename = filename + '-' + count else @@ -284,7 +284,7 @@ returns file.flock( File::LOCK_UN ) file.close } - return false if !File.exists?( path + 'a-' + filename ) + return false if !File.exist?( path + 'a-' + filename ) FileUtils.mv( path + 'a-' + filename, path + filename ) true end @@ -419,7 +419,7 @@ returns } files.sort.each {|entry| filename = path + '/' + entry - next if !File::exists?( filename ) + next if !File::exist?( filename ) File.open( filename, 'rb' ) { |file| all = file.read spool = JSON.parse( all ) @@ -474,7 +474,7 @@ returns def self.jobs # just make sure that spool path exists - if !File::exists?( @path ) + if !File::exist?( @path ) FileUtils.mkpath @path end