lib/cucumber/parser/table.rb in kosmas58-cucumber-0.2.2.1 vs lib/cucumber/parser/table.rb in kosmas58-cucumber-0.2.3.3

- old
+ new

@@ -12,16 +12,24 @@ def root @root || :table end module Table0 - def build + def at_line?(line) + elements.detect{|table_row| table_row.at_line?(line)} + end + + def build(filter=nil) Ast::Table.new(raw) end - def raw - elements.map{|e| e.build} + def raw(filter=nil, scenario_outline=nil) + elements.map do |table_row| + if(filter.nil? || table_row == elements[0] || filter.at_line?(table_row) || (scenario_outline && filter.outline_at_line?(scenario_outline))) + table_row.build + end + end.compact end end def _nt_table start_index = index @@ -42,11 +50,11 @@ end if s0.empty? self.index = i0 r0 = nil else - r0 = SyntaxNode.new(input, i0...index, s0) + r0 = instantiate_node(SyntaxNode,input, i0...index, s0) r0.extend(Table0) end node_cache[:table][start_index] = r0 @@ -66,10 +74,14 @@ end end module TableRow2 + def at_line?(line) + cells.line == line + end + def build row = cells.elements.map do |elt| value = elt.cell.text_value.strip value.empty? ? nil : value end @@ -99,15 +111,15 @@ s1 << r2 else break end end - r1 = SyntaxNode.new(input, i1...index, s1) + r1 = instantiate_node(SyntaxNode,input, i1...index, s1) s0 << r1 if r1 if input.index('|', index) == index - r3 = (SyntaxNode).new(input, index...(index + 1)) + r3 = instantiate_node(SyntaxNode,input, index...(index + 1)) @index += 1 else terminal_parse_failure('|') r3 = nil end @@ -118,20 +130,20 @@ i5, s5 = index, [] r6 = _nt_cell s5 << r6 if r6 if input.index('|', index) == index - r7 = (SyntaxNode).new(input, index...(index + 1)) + r7 = instantiate_node(SyntaxNode,input, index...(index + 1)) @index += 1 else terminal_parse_failure('|') r7 = nil end s5 << r7 end if s5.last - r5 = (SyntaxNode).new(input, i5...index, s5) + r5 = instantiate_node(SyntaxNode,input, i5...index, s5) r5.extend(TableRow0) else self.index = i5 r5 = nil end @@ -143,11 +155,11 @@ end if s4.empty? self.index = i4 r4 = nil else - r4 = SyntaxNode.new(input, i4...index, s4) + r4 = instantiate_node(SyntaxNode,input, i4...index, s4) end s0 << r4 if r4 s8, i8 = [], index loop do @@ -156,11 +168,11 @@ s8 << r9 else break end end - r8 = SyntaxNode.new(input, i8...index, s8) + r8 = instantiate_node(SyntaxNode,input, i8...index, s8) s0 << r8 if r8 i10 = index s11, i11 = [], index loop do @@ -173,11 +185,11 @@ end if s11.empty? self.index = i11 r11 = nil else - r11 = SyntaxNode.new(input, i11...index, s11) + r11 = instantiate_node(SyntaxNode,input, i11...index, s11) end if r11 r10 = r11 else r13 = _nt_eof @@ -192,11 +204,11 @@ end end end end if s0.last - r0 = (SyntaxNode).new(input, i0...index, s0) + r0 = instantiate_node(SyntaxNode,input, i0...index, s0) r0.extend(TableRow1) r0.extend(TableRow2) else self.index = i0 r0 = nil @@ -222,11 +234,11 @@ loop do i1, s1 = index, [] i2 = index i3 = index if input.index('|', index) == index - r4 = (SyntaxNode).new(input, index...(index + 1)) + r4 = instantiate_node(SyntaxNode,input, index...(index + 1)) @index += 1 else terminal_parse_failure('|') r4 = nil end @@ -243,25 +255,25 @@ end if r3 r2 = nil else self.index = i2 - r2 = SyntaxNode.new(input, index...index) + r2 = instantiate_node(SyntaxNode,input, index...index) end s1 << r2 if r2 if index < input_length - r6 = (SyntaxNode).new(input, index...(index + 1)) + r6 = instantiate_node(SyntaxNode,input, index...(index + 1)) @index += 1 else terminal_parse_failure("any character") r6 = nil end s1 << r6 end if s1.last - r1 = (SyntaxNode).new(input, i1...index, s1) + r1 = instantiate_node(SyntaxNode,input, i1...index, s1) r1.extend(Cell0) else self.index = i1 r1 = nil end @@ -269,11 +281,11 @@ s0 << r1 else break end end - r0 = SyntaxNode.new(input, i0...index, s0) + r0 = instantiate_node(SyntaxNode,input, i0...index, s0) node_cache[:cell][start_index] = r0 return r0 end @@ -285,11 +297,11 @@ @index = cached.interval.end if cached return cached end if input.index(Regexp.new('[ \\t]'), index) == index - r0 = (SyntaxNode).new(input, index...(index + 1)) + r0 = instantiate_node(SyntaxNode,input, index...(index + 1)) @index += 1 else r0 = nil end @@ -309,45 +321,45 @@ return cached end i0 = index if input.index("\n", index) == index - r1 = (SyntaxNode).new(input, index...(index + 1)) + r1 = instantiate_node(SyntaxNode,input, index...(index + 1)) @index += 1 else terminal_parse_failure("\n") r1 = nil end if r1 r0 = r1 else i2, s2 = index, [] if input.index("\r", index) == index - r3 = (SyntaxNode).new(input, index...(index + 1)) + r3 = instantiate_node(SyntaxNode,input, index...(index + 1)) @index += 1 else terminal_parse_failure("\r") r3 = nil end s2 << r3 if r3 if input.index("\n", index) == index - r5 = (SyntaxNode).new(input, index...(index + 1)) + r5 = instantiate_node(SyntaxNode,input, index...(index + 1)) @index += 1 else terminal_parse_failure("\n") r5 = nil end if r5 r4 = r5 else - r4 = SyntaxNode.new(input, index...index) + r4 = instantiate_node(SyntaxNode,input, index...index) end s2 << r4 end if s2.last - r2 = (SyntaxNode).new(input, i2...index, s2) + r2 = instantiate_node(SyntaxNode,input, i2...index, s2) r2.extend(Eol0) else self.index = i2 r2 = nil end @@ -372,20 +384,20 @@ return cached end i0 = index if index < input_length - r1 = (SyntaxNode).new(input, index...(index + 1)) + r1 = instantiate_node(SyntaxNode,input, index...(index + 1)) @index += 1 else terminal_parse_failure("any character") r1 = nil end if r1 r0 = nil else self.index = i0 - r0 = SyntaxNode.new(input, index...index) + r0 = instantiate_node(SyntaxNode,input, index...index) end node_cache[:eof][start_index] = r0 return r0 \ No newline at end of file