Sha256: efd06cd45a6382f0f330f15773c46905f3826a60e30484ddc3595e845aad3fbd

Contents?: true

Size: 1.14 KB

Versions: 1

Compression:

Stored size: 1.14 KB

Contents

module CucumberAnalytics

  # A class modeling a Tag.

  class Tag

    include Raw
    include Sourceable


    # The parent object that contains *self*
    attr_accessor :parent_element

    # The name of the Tag
    attr_accessor :name


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

      build_tag(parsed_tag) if parsed_tag
    end


    private


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

    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

    def build_tag(parsed_tag)
      populate_name(parsed_tag)
      populate_raw_element(parsed_tag)
      populate_element_source_line(parsed_tag)
    end

    def populate_name(parsed_tag)
      @name = parsed_tag['name']
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cucumber_analytics-1.2.0 lib/cucumber_analytics/tag.rb