Sha256: 9cdac5ea18f240a4eb776021685518a6f30bebaa1a69f6a283a97df07176ba14
Contents?: true
Size: 754 Bytes
Versions: 4
Compression:
Stored size: 754 Bytes
Contents
# encoding: UTF-8 module Dump module Env # Filter strings by simple pattern: # 'a,b,c' will pass only 'a', 'b' and 'c' # '-a,b,c' will pass everything except 'a', 'b' and 'c' class Filter attr_reader :invert, :values, :transparent def initialize(s, splitter = nil) if s s = s.dup @invert = !!s.sub!(/^-/, '') @values = s.split(splitter || ',').map(&:strip).map(&:downcase).uniq.select(&:present?) else @transparent = true end end def pass?(value) transparent || (invert ^ values.include?(value.to_s.downcase)) end def custom_pass?(&block) transparent || (invert ^ values.any?(&block)) end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
dump-1.1.0 | lib/dump/env/filter.rb |
dump-1.0.8 | lib/dump/env/filter.rb |
dump-1.0.7 | lib/dump/env/filter.rb |
dump-1.0.6 | lib/dump/env/filter.rb |