Sha256: ccfc6bacd5f8ea49bec0a453809b5cb7d33aec3fff6397d684a2b367e2993c79

Contents?: true

Size: 1004 Bytes

Versions: 5

Compression:

Stored size: 1004 Bytes

Contents

module CukeModeler

  # A class modeling a tag.

  class Tag < Model

    include Parsed
    include Sourceable


    # The name of the tag
    attr_accessor :name


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

      if source_text
        parsed_tag_data = parse_source(source_text)
        populate_tag(self, parsed_tag_data)
      end
    end

    # Returns a string representation of this model. For a tag model,
    # this will be Gherkin text that is equivalent to the tag being modeled.
    def to_s
      name || ''
    end


    private


    def parse_source(source_text)
      base_file_string = "\nFeature: Fake feature to parse"
      source_text = source_text + base_file_string

      parsed_file = Parsing::parse_text(source_text, 'cuke_modeler_stand_alone_tag.feature')

      parsed_file.first['tags'].first
    end

  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
cuke_modeler-1.0.4 lib/cuke_modeler/models/tag.rb
cuke_modeler-1.0.3 lib/cuke_modeler/models/tag.rb
cuke_modeler-1.0.2 lib/cuke_modeler/models/tag.rb
cuke_modeler-1.0.1 lib/cuke_modeler/models/tag.rb
cuke_modeler-1.0.0 lib/cuke_modeler/models/tag.rb