class Oktest::FILTER_CLASS
Attributes
negative[R]
spec_pattern[R]
tag_pattern[R]
topic_pattern[R]
Public Class Methods
create_from(pattern)
click to toggle source
# File lib/oktest.rb, line 2234 def self.create_from(pattern) # ex: 'topic=name', 'spec="*pat*"' #; [!gtpt1] parses 'sid=...' as filter pattern for spec. pattern = "spec#{$1}\\[!#{$2}\\]*" if pattern =~ /\Asid(=|!=)(.*)/ # filter by spec id #; [!xt364] parses 'topic=...' as filter pattern for topic. #; [!53ega] parses 'spec=...' as filter pattern for spec. #; [!go6us] parses 'tag=...' as filter pattern for tag. #; [!cmp6e] raises ArgumentError when invalid argument. pat = {'topic'=>nil, 'spec'=>nil, 'tag'=>nil} pattern =~ /\A(\w+)(=|!=)/ && pat.key?($1) or raise ArgumentError, "#{pattern.inspect}: unexpected pattern string." pat[$1] = $' #; [!5hl7z] parses 'xxx!=...' as negative filter pattern. negative = ($2 == '!=') #; [!9dzmg] returns filter object. return self.new(pat['topic'], pat['spec'], pat['tag'], negative: negative) end
new(topic_pattern, spec_pattern, tag_pattern, negative: false)
click to toggle source
# File lib/oktest.rb, line 2225 def initialize(topic_pattern, spec_pattern, tag_pattern, negative: false) @topic_pattern = topic_pattern @spec_pattern = spec_pattern @tag_pattern = tag_pattern @negative = negative end
Public Instance Methods
filter_children!(node)
click to toggle source
# File lib/oktest.rb, line 2293 def filter_children!(node) _filter_children!(node) end
scope_match?(scope)
click to toggle source
# File lib/oktest.rb, line 2251 def scope_match?(scope) #; [!zkq6r] returns true only if tag name matched to pattern. return true if @tag_pattern && _match_tag?(scope.tag, @tag_pattern) return false end
Also aliased as: visit_scope
spec_match?(spec)
click to toggle source
# File lib/oktest.rb, line 2267 def spec_match?(spec) #; [!k45p3] returns true if spec description matched to pattern. #; [!li3pd] returns true if tag name matched to pattern. return true if @spec_pattern && _match?(spec.desc, @spec_pattern) return true if @tag_pattern && _match_tag?(spec.tag, @tag_pattern) return false end
Also aliased as: visit_spec
topic_match?(topic)
click to toggle source
# File lib/oktest.rb, line 2258 def topic_match?(topic) #; [!jpycj] returns true if topic target name matched to pattern. #; [!6lfp1] returns true if tag name matched to pattern. return true if @topic_pattern && _match?(topic.target.to_s, @topic_pattern) return true if @tag_pattern && _match_tag?(topic.tag, @tag_pattern) return false end
Also aliased as: visit_topic
Private Instance Methods
_match?(str, pattern)
click to toggle source
# File lib/oktest.rb, line 2278 def _match?(str, pattern) #; [!h90x3] returns true if str matched to pattern. return File.fnmatch(pattern, str.to_s, File::FNM_EXTGLOB) end
_match_tag?(tag, pattern)
click to toggle source
# File lib/oktest.rb, line 2283 def _match_tag?(tag, pattern) #; [!lyo18] returns false if tag is nil. #; [!8lxin] returns true if tag matched to pattern. #; [!7wxmh] supports multiple tag names. return false if tag.nil? return [tag].flatten.any? {|tag_| _match?(tag_, pattern) } end