Class: Oktest::Filter
Instance Attribute Summary collapse
-
#negative ⇒ Object
readonly
Returns the value of attribute negative.
-
#spec_pattern ⇒ Object
readonly
Returns the value of attribute spec_pattern.
-
#tag_pattern ⇒ Object
readonly
Returns the value of attribute tag_pattern.
-
#topic_pattern ⇒ Object
readonly
Returns the value of attribute topic_pattern.
Class Method Summary collapse
-
.create_from(pattern) ⇒ Object
ex: ‘topic=name’, ‘spec=“pat”’.
Instance Method Summary collapse
- #filter_children!(node) ⇒ Object
-
#initialize(topic_pattern, spec_pattern, tag_pattern, negative: false) ⇒ Filter
constructor
A new instance of Filter.
- #scope_match?(scope) ⇒ Boolean (also: #visit_scope)
- #spec_match?(spec) ⇒ Boolean (also: #visit_spec)
- #topic_match?(topic) ⇒ Boolean (also: #visit_topic)
Methods inherited from Visitor
Constructor Details
#initialize(topic_pattern, spec_pattern, tag_pattern, negative: false) ⇒ Filter
Returns a new instance of Filter.
2224 2225 2226 2227 2228 2229 |
# File 'lib/oktest.rb', line 2224 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 |
Instance Attribute Details
#negative ⇒ Object (readonly)
Returns the value of attribute negative.
2231 2232 2233 |
# File 'lib/oktest.rb', line 2231 def negative @negative end |
#spec_pattern ⇒ Object (readonly)
Returns the value of attribute spec_pattern.
2231 2232 2233 |
# File 'lib/oktest.rb', line 2231 def spec_pattern @spec_pattern end |
#tag_pattern ⇒ Object (readonly)
Returns the value of attribute tag_pattern.
2231 2232 2233 |
# File 'lib/oktest.rb', line 2231 def tag_pattern @tag_pattern end |
#topic_pattern ⇒ Object (readonly)
Returns the value of attribute topic_pattern.
2231 2232 2233 |
# File 'lib/oktest.rb', line 2231 def topic_pattern @topic_pattern end |
Class Method Details
.create_from(pattern) ⇒ Object
ex: ‘topic=name’, ‘spec=“pat”’
2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 |
# File 'lib/oktest.rb', line 2233 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 |
Instance Method Details
#filter_children!(node) ⇒ Object
2292 2293 2294 |
# File 'lib/oktest.rb', line 2292 def filter_children!(node) _filter_children!(node) end |
#scope_match?(scope) ⇒ Boolean Also known as: visit_scope
2250 2251 2252 2253 2254 |
# File 'lib/oktest.rb', line 2250 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 |
#spec_match?(spec) ⇒ Boolean Also known as: visit_spec
2266 2267 2268 2269 2270 2271 2272 |
# File 'lib/oktest.rb', line 2266 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 |
#topic_match?(topic) ⇒ Boolean Also known as: visit_topic
2257 2258 2259 2260 2261 2262 2263 |
# File 'lib/oktest.rb', line 2257 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 |