lib/cucumber/parser/feature.rb in aslakhellesoy-cucumber-0.2.3.3 vs lib/cucumber/parser/feature.rb in aslakhellesoy-cucumber-0.2.3.4

- old
+ new

@@ -54,19 +54,25 @@ end end module Feature2 + def has_tags?(tag_names) + tags.has_tags?(tag_names) + end + def build(filter) - background = bg.respond_to?(:build) ? bg.build : nil - Ast::Feature.new( - background, - comment.build, - tags.build, - header.text_value, - feature_elements.build(background, filter) - ) + if(filter.nil? || feature_elements.accept?(filter)) + background = bg.respond_to?(:build) ? bg.build : nil + Ast::Feature.new( + background, + comment.build, + tags.build, + header.text_value, + feature_elements.build(background, filter) + ) + end end end def _nt_feature start_index = index @@ -207,14 +213,21 @@ module Tags2 def at_line?(line) ts.elements.detect{|e| e.tag.line == line} end + def has_tags?(tags) + tag_names.detect{|tag_name| tags.index(tag_name)} + end + def build - tag_names = ts.elements.map{|e| e.tag.tag_name.text_value} Ast::Tags.new(ts.line, tag_names) end + + def tag_names + ts.elements.map{|e| e.tag.tag_name.text_value} + end end def _nt_tags start_index = index if node_cache[:tags].has_key?(index) @@ -567,10 +580,14 @@ return r0 end module FeatureElements0 + def accept?(filter) + filter.nil? || elements.empty? || elements.detect{|feature_element| filter.accept?(feature_element)} + end + def build(background, filter) elements.map do |feature_element| if filter.nil? || filter.accept?(feature_element) feature_element.build(background, filter) end @@ -654,10 +671,19 @@ scenario_keyword.line == line || steps.at_line?(line) || tags.at_line?(line) end + def has_tags?(tag_names) + feature_tags = self.parent.parent.tags + tags.has_tags?(tag_names) || feature_tags.has_tags?(tag_names) + end + + def matches_name?(name_to_match) + name.text_value == name_to_match + end + def build(background, filter) Ast::Scenario.new( background, comment.build, tags.build, @@ -783,10 +809,19 @@ def outline_at_line?(line) scenario_outline_keyword.line == line || steps.at_line?(line) end + def has_tags?(tag_names) + feature_tags = self.parent.parent.tags + tags.has_tags?(tag_names) || feature_tags.has_tags?(tag_names) + end + + def matches_name?(name_to_match) + name.text_value == name_to_match + end + def build(background, filter) Ast::ScenarioOutline.new( background, comment.build, tags.build, @@ -1042,11 +1077,11 @@ def at_line?(line) elements.detect { |e| e.at_line?(line) } end def build(filter, scenario_outline) - elements.map do |e| + elements.map do |e| if(filter.nil? || filter.accept?(e) || filter.outline_at_line?(scenario_outline)) e.build(filter, scenario_outline) end end.compact end @@ -1103,10 +1138,18 @@ def at_line?(line) examples_keyword.line == line || table.at_line?(line) end + def has_tags?(tag_names) + true + end + + def outline_at_line?(line) + true + end + def build(filter, scenario_outline) [examples_keyword.line, examples_keyword.text_value, name.text_value, table.raw(filter, scenario_outline)] end end @@ -1356,26 +1399,26 @@ return r0 end module OpenPyString0 - def white + def indent elements[0] end def eol elements[3] end end module OpenPyString1 def indentation - white.text_value.length + indent.text_value.length end def line - white.line + indent.line end end def _nt_open_py_string start_index = index @@ -1384,36 +1427,45 @@ @index = cached.interval.end if cached return cached end i0, s0 = index, [] - r1 = _nt_white + s1, i1 = [], index + loop do + r2 = _nt_space + if r2 + s1 << r2 + else + break + end + end + r1 = instantiate_node(SyntaxNode,input, i1...index, s1) s0 << r1 if r1 if input.index('"""', index) == index - r2 = instantiate_node(SyntaxNode,input, index...(index + 3)) + r3 = instantiate_node(SyntaxNode,input, index...(index + 3)) @index += 3 else terminal_parse_failure('"""') - r2 = nil + r3 = nil end - s0 << r2 - if r2 - s3, i3 = [], index + s0 << r3 + if r3 + s4, i4 = [], index loop do - r4 = _nt_space - if r4 - s3 << r4 + r5 = _nt_space + if r5 + s4 << r5 else break end end - r3 = instantiate_node(SyntaxNode,input, i3...index, s3) - s0 << r3 - if r3 - r5 = _nt_eol - s0 << r5 + r4 = instantiate_node(SyntaxNode,input, i4...index, s4) + s0 << r4 + if r4 + r6 = _nt_eol + s0 << r6 end end end if s0.last r0 = instantiate_node(SyntaxNode,input, i0...index, s0) @@ -1542,6 +1594,6 @@ class FeatureParser < Treetop::Runtime::CompiledParser include Feature end end -end \ No newline at end of file +end