Sha256: 27645b1e76a3527629bca67f0c1879279131d5fa89bdbab6329c84f5e756d6b2

Contents?: true

Size: 1.24 KB

Versions: 4

Compression:

Stored size: 1.24 KB

Contents

module CucumberAnalytics

  # A class modeling a Cucumber Examples table row.

  class Row

    include Sourceable
    include Raw
    include Nested


    # The cells that make up the row
    attr_accessor :cells


    # Creates a new Row object and, if *source* is provided, populates
    # the object.
    def initialize(source = nil)
      parsed_row = process_source(source)

      @cells = []

      build_row(parsed_row) if parsed_row
    end


    private


    def process_source(source)
      case
        when source.is_a?(String)
          parse_row(source)
        else
          source
      end
    end

    def parse_row(source_text)
      base_file_string = "Feature: Fake feature to parse\nScenario Outline:\n* fake step\nExamples: fake examples\n"
      source_text = base_file_string + source_text

      parsed_file = Parsing::parse_text(source_text)

      parsed_file.first['elements'].first['examples'].first['rows'].first
    end

    def build_row(parsed_row)
      populate_element_source_line(parsed_row)
      populate_row_cells(parsed_row)
      populate_raw_element(parsed_row)
    end

    def populate_row_cells(parsed_row)
      @cells = parsed_row['cells']
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
cucumber_analytics-1.4.2 lib/cucumber_analytics/row.rb
cucumber_analytics-1.4.1 lib/cucumber_analytics/row.rb
cucumber_analytics-1.4.0 lib/cucumber_analytics/row.rb
cucumber_analytics-1.3.0 lib/cucumber_analytics/row.rb