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.
1861 1862 1863 1864 1865 1866 |
# File 'lib/oktest.rb', line 1861 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.
1868 1869 1870 |
# File 'lib/oktest.rb', line 1868 def negative @negative end |
#spec_pattern ⇒ Object (readonly)
Returns the value of attribute spec_pattern.
1868 1869 1870 |
# File 'lib/oktest.rb', line 1868 def spec_pattern @spec_pattern end |
#tag_pattern ⇒ Object (readonly)
Returns the value of attribute tag_pattern.
1868 1869 1870 |
# File 'lib/oktest.rb', line 1868 def tag_pattern @tag_pattern end |
#topic_pattern ⇒ Object (readonly)
Returns the value of attribute topic_pattern.
1868 1869 1870 |
# File 'lib/oktest.rb', line 1868 def topic_pattern @topic_pattern end |
Class Method Details
.create_from(pattern) ⇒ Object
ex: ‘topic=name’, ‘spec=“pat”’
1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 |
# File 'lib/oktest.rb', line 1870 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
1929 1930 1931 |
# File 'lib/oktest.rb', line 1929 def filter_children!(node) _filter_children!(node) end |
#scope_match?(scope) ⇒ Boolean Also known as: visit_scope
1887 1888 1889 1890 1891 |
# File 'lib/oktest.rb', line 1887 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
1903 1904 1905 1906 1907 1908 1909 |
# File 'lib/oktest.rb', line 1903 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
1894 1895 1896 1897 1898 1899 1900 |
# File 'lib/oktest.rb', line 1894 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 |