Class: ERB::Formatter::IgnoreList
- Inherits:
-
Object
- Object
- ERB::Formatter::IgnoreList
- Defined in:
- lib/erb/formatter/ignore_list.rb
Instance Method Summary collapse
-
#initialize(contents: nil, base_dir: Dir.pwd) ⇒ IgnoreList
constructor
A new instance of IgnoreList.
- #should_ignore_file?(path) ⇒ Boolean
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
8 9 10 11 12 13 |
# File 'lib/erb/formatter/ignore_list.rb', line 8 def should_ignore_file?(path) path = File.(path, @base_dir) @ignore_list.any? do |line| File.fnmatch? File.(line.chomp, @base_dir), path end end |