class CucumberAnalytics::Tag

A class modeling a Tag.

Attributes

name[RW]

The name of the Tag

Public Class Methods

new(source = nil) click to toggle source

Creates a new Tag object and, if source is provided, populates the object.

# File lib/cucumber_analytics/tag.rb, line 18
def initialize(source = nil)
  parsed_tag = process_source(source)

  build_tag(parsed_tag) if parsed_tag
end

Public Instance Methods

to_s() click to toggle source

Returns gherkin representation of the tag.

# File lib/cucumber_analytics/tag.rb, line 25
def to_s
  name || ''
end

Private Instance Methods

build_tag(parsed_tag) click to toggle source
# File lib/cucumber_analytics/tag.rb, line 51
def build_tag(parsed_tag)
  populate_name(parsed_tag)
  populate_raw_element(parsed_tag)
  populate_element_source_line(parsed_tag)
end
parse_tag(source_text) click to toggle source
# File lib/cucumber_analytics/tag.rb, line 42
def parse_tag(source_text)
  base_file_string = "\nFeature: Fake feature to parse"
  source_text = source_text + base_file_string

  parsed_file = Parsing::parse_text(source_text)

  parsed_file.first['tags'].first
end
populate_name(parsed_tag) click to toggle source
# File lib/cucumber_analytics/tag.rb, line 57
def populate_name(parsed_tag)
  @name = parsed_tag['name']
end
process_source(source) click to toggle source
# File lib/cucumber_analytics/tag.rb, line 33
def process_source(source)
  case
    when source.is_a?(String)
      parse_tag(source)
    else
      source
  end
end