Sha256: 5fd7ae63cb6243d7f6896a8bbd9154153cb7241384c7cdecabe5d30e742dd7c5
Contents?: true
Size: 1.42 KB
Versions: 3
Compression:
Stored size: 1.42 KB
Contents
module CucumberAnalytics # A class modeling the table of a Step. class Table include Containing include Raw include Nested # The contents of the table attr_accessor :contents # The row elements that make up the table attr_accessor :row_elements # Creates a new Table object and, if *source* is provided, populates # the object. def initialize(source = nil) @contents = [] @row_elements = [] parsed_table = process_source(source) build_table(parsed_table) if parsed_table end private def process_source(source) case when source.is_a?(String) parse_table(source) else source end end def parse_table(source_text) base_file_string = "Feature:\nScenario:\n* step\n" source_text = base_file_string + source_text parsed_file = Parsing::parse_text(source_text) parsed_file.first['elements'].first['steps'].first['rows'] end def build_table(table) populate_contents(table) populate_row_elements(table) populate_raw_element(table) end def populate_contents(table) @contents = table.collect { |row| row['cells'] } end def populate_row_elements(table) table.each do |row| @row_elements << build_child_element(TableRow, row) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
cucumber_analytics-1.4.2 | lib/cucumber_analytics/table.rb |
cucumber_analytics-1.4.1 | lib/cucumber_analytics/table.rb |
cucumber_analytics-1.4.0 | lib/cucumber_analytics/table.rb |