Class Buff::Ignore::IgnoreFile
In: lib/buff/ignore/ignore_file.rb
Parent: Object

A Ruby representation of an ignore file

Methods

apply   apply!   ignored?   new  

Constants

COMMENT_OR_WHITESPACE = /^\s*(?:#.*)?$/.freeze   Regular expression to match comments or plain whitespace

@return [Regexp]

Attributes

filepath  [R]  The path to the ignore file

@return [String]

options  [R]  The list of options

@return [Hash]

Public Class methods

Create a new ignore file from the given filepath

@raise [IgnoreFileNotFound]

  if the given filepath does not exist

@param [String, Pathname] filepath

  the path to the ignore file

@param [Hash] options

  a list of options to pass to the ignore file

@option [to_s] options :base

  the base directory to apply ignores from

Public Instance methods

Apply the ignore to the list, returning a new list of filtered files

@example

  files = ['Gemfile', 'Gemfile.lock', 'bacon', 'eggs']
  ignore.apply(files) #=> ['bacon', 'eggs']

@see IgnoreFile#apply!

@param [Array] list

  the list of files to apply the ignore to

@return [Array]

  the sanitized file list

Destructively remove all files from the given list

@param [Array] list

  the list of files to apply the ignore to

@return [Array, nil]

  the elements removed, or nil if none were removed

Determine if a given filename should be ignored

@param [String] filename

  the file to match

@return [Boolean]

  true if the file should be ignored, false otherwise

[Validate]