Method: CleanFiles::Cleaner#files

Defined in:
lib/clean_files/cleaner.rb

#filesObject



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/clean_files/cleaner.rb', line 32

def files
  if paths.any?{|path| path.include?('*')}
    paths.map!{|path| Dir.glob(path)}
    paths.flatten!
  end
  @_files ||= paths.map do |file_path|
    begin
      SimpleFile.new(file_path, File.stat(file_path))
    rescue Errno::EOPNOTSUPP
      nil
    rescue Errno::ENOENT => e
      puts e.to_s
      exit -2
    end
  end.compact.select do |file|
    file.file? || (options[:recursive] && file.directory?)
  end.sort_by(&:ctime)
end