Class: ERB::Formatter::IgnoreList

Inherits:
Object
  • Object
show all
Defined in:
lib/erb/formatter/ignore_list.rb

Instance Method Summary collapse

Constructor Details

#initialize(contents: nil, base_dir: Dir.pwd) ⇒ IgnoreList

Returns a new instance of IgnoreList.



2
3
4
5
6
# File 'lib/erb/formatter/ignore_list.rb', line 2

def initialize(contents: nil, base_dir: Dir.pwd)
  ignore_list_path = "#{base_dir}/.format-erb-ignore"
  @contents = contents || (File.exist?(ignore_list_path) ? File.read(ignore_list_path) : '')
  @ignore_list = @contents.lines
end

Instance Method Details

#should_ignore_file?(path) ⇒ Boolean

Returns:

  • (Boolean)


8
9
10
11
12
13
# File 'lib/erb/formatter/ignore_list.rb', line 8

def should_ignore_file?(path)
  path = File.expand_path(path, @base_dir)
  @ignore_list.any? do |line|
    File.fnmatch? File.expand_path(line.chomp, @base_dir), path
  end
end