Class: Widow::Exclude
- Inherits:
-
Object
- Object
- Widow::Exclude
- Defined in:
- lib/widow.rb
Instance Method Summary collapse
- #ignored?(file) ⇒ Boolean
- #ignored_patterns ⇒ Object
-
#initialize(root_dir, logger) ⇒ Exclude
constructor
A new instance of Exclude.
- #to_s ⇒ Object
Constructor Details
#initialize(root_dir, logger) ⇒ Exclude
Returns a new instance of Exclude.
124 125 126 127 128 129 130 131 132 133 |
# File 'lib/widow.rb', line 124 def initialize root_dir, logger @patterns = Pathname.glob("#{root_dir}/**/.widowignore").map do |file| next [file, File.readlines(file)] end.to_h.map do |file, lines| lines.map do |line| /^#{file.dirname}\/#{line.sub /\s*$/, ''}/ unless line =~ /^\s*$/ end.compact end.flatten(1) << /.*\/\.widowignore$/ logger.info "ignoring:\n#{to_s}" end |
Instance Method Details
#ignored?(file) ⇒ Boolean
135 136 137 138 139 |
# File 'lib/widow.rb', line 135 def ignored? file return @patterns.any? do |pattern| file.to_s =~ pattern end end |
#ignored_patterns ⇒ Object
141 142 143 |
# File 'lib/widow.rb', line 141 def ignored_patterns return @patterns.map &:to_s end |
#to_s ⇒ Object
145 146 147 |
# File 'lib/widow.rb', line 145 def to_s return ignored_patterns.join "\n" end |