class RubyLint::FileList

The FileList class acts as a small wrapper around `Dir.glob` and is mainly used to turn a list of filenames/directory names into a list of just file names (excluding ones that don't exist).

Public Instance Methods

glob_files(directory) click to toggle source

Returns a list of Ruby files in the given directory. This list includes deeply nested files.

@return [Array]

# File lib/ruby-lint/file_list.rb, line 39
def glob_files(directory)
  return Dir.glob(File.join(directory, '**/*.rb'))
end
process(files) click to toggle source

@param [Array] files @return [Array] @raise [Errno::ENOENT] Raised if a file or directory does not exist.

# File lib/ruby-lint/file_list.rb, line 13
def process(files)
  existing = []

  files.each do |file|
    file = File.expand_path(file)

    if File.file?(file)
      existing << file

    elsif File.directory?(file)
      existing = existing | glob_files(file)

    else
      raise Errno::ENOENT, file
    end
  end

  return existing
end