Sha256: 245604b82f4fef5657af2f38510682b82637950ba438cecc6c3dba1be0388a52
Contents?: true
Size: 551 Bytes
Versions: 25
Compression:
Stored size: 551 Bytes
Contents
module Speckle module List class FileContentFilter def initialize(pattern, invert = false) @pattern = pattern @invert = invert end def run(item) return [] unless File.exists?(item) matched = has_content(item, @pattern) if @invert matched = !matched end return [item] if matched return [] end def has_content(item, pattern) regex = Regexp.new(pattern) File.readlines(item).grep(regex).size > 0 end end end end
Version data entries
25 entries across 25 versions & 1 rubygems