class Widow::Exclude

Public Class Methods

new(root_dir, logger) click to toggle source
# 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

Public Instance Methods

ignored?(file) click to toggle source
# File lib/widow.rb, line 135
def ignored? file
        return @patterns.any? do |pattern|
                file.to_s =~ pattern
        end
end
ignored_patterns() click to toggle source
# File lib/widow.rb, line 141
def ignored_patterns
        return @patterns.map &:to_s
end
to_s() click to toggle source
# File lib/widow.rb, line 145
def to_s
        return ignored_patterns.join "\n"
end