Sha256: f495942f50ebeb6805dec1c1faa0fd70b5c627fefe8458a527a6bdba908c9c0f

Contents?: true

Size: 1.48 KB

Versions: 19

Compression:

Stored size: 1.48 KB

Contents

module Cucumber
  module Parser
    # TIP: When you hack on the grammar, just delete table.rb in this directory.
    # Also make sure you have uninstalled all cucumber gems (don't forget xxx-cucumber
    # github gems).
    #
    # Treetop will then generate the parser in-memory. When you're happy, just generate
    # the rb file with tt feature.tt
    grammar Table
      include Common

      rule table
        table_row+ {
          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(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

      rule table_row
        space* '|' cells:(cell '|')+ space* (eol+ / eof) {
          def at_line?(line)
            cells.line == line
          end

          def build
            row = cells.elements.map do |elt| 
              value = elt.cell.text_value.strip
              value
            end

            class << row
              attr_accessor :line
            end
            row.line = cells.line

            row
          end
        }
      end

      rule cell
        (!('|' / eol) .)*
      end

    end
  end
end

Version data entries

19 entries across 19 versions & 5 rubygems

Version Path
cucumber-0.6.4 lib/cucumber/parser/table.tt
cucumber-0.6.3 lib/cucumber/parser/table.tt
davidtrogers-cucumber-0.6.2 lib/cucumber/parser/table.tt
cucumber-0.6.2 lib/cucumber/parser/table.tt
cucumber-0.6.1 lib/cucumber/parser/table.tt
cucumber-0.6.0 lib/cucumber/parser/table.tt
cucumber-0.5.3 lib/cucumber/parser/table.tt
cucumber-0.5.2 lib/cucumber/parser/table.tt
cucumber-0.5.1 lib/cucumber/parser/table.tt
cucumber-0.5.0 lib/cucumber/parser/table.tt
cucumber-0.4.5.rc2 lib/cucumber/parser/table.tt
kbaum-cucumber-0.4.5.pre lib/cucumber/parser/table.tt
cucumber-0.4.5.rc1 lib/cucumber/parser/table.tt
middleman-0.10.17 vendor/gems/gems/cucumber-0.4.4/lib/cucumber/parser/table.tt
middleman-0.10.16 vendor/gems/gems/cucumber-0.4.4/lib/cucumber/parser/table.tt
middleman-0.10.15 vendor/gems/gems/cucumber-0.4.4/lib/cucumber/parser/table.tt
rackjour-0.1.8 vendor/gems/gems/cucumber-0.4.4/lib/cucumber/parser/table.tt
middleman-0.10.14 vendor/gems/gems/cucumber-0.4.4/lib/cucumber/parser/table.tt
cucumber-0.4.4 lib/cucumber/parser/table.tt