Class: Cukedep::FeatureRep

Inherits:
Object
  • Object
show all
Defined in:
lib/cukedep/feature-rep.rb

Overview

A FeatureRep is the internal representation of a Gherkin feature.

Constant Summary collapse

FeatureIdPrefix =

Constant that specifies how feature identifier tags should begin

/^feature:/
DependencyPrefix =

Constant that specifies how dependency tags should begin

/^depends_on:/

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(theTags) ⇒ FeatureRep

Returns a new instance of FeatureRep.

Parameters:

  • theTags (Array<String>)

    the tags objects from the Gherkin parser



23
24
25
26
27
28
29
# File 'lib/cukedep/feature-rep.rb', line 23

def initialize(theTags)
  # Strip first character of tag literal.
  @tags = theTags.map { |t| t[1..-1] }

  @identifier = tags.find { |tg| tg =~ FeatureIdPrefix }
  @identifier = @identifier.sub(FeatureIdPrefix, '') unless identifier.nil?
end

Instance Attribute Details

#identifierObject (readonly)

The identifier of the feature. It comes from a tag with the following syntax '@feature:' + identifier. Note that the @feature: prefix is removed.



19
20
21
# File 'lib/cukedep/feature-rep.rb', line 19

def identifier
  @identifier
end

#tagsObject (readonly)

The sorted list of all tags of the feature. The @ prefix is stripped from each tag text.



14
15
16
# File 'lib/cukedep/feature-rep.rb', line 14

def tags
  @tags
end

Instance Method Details

#anonymous?Boolean

Return true iff the identifier of the feature is nil.

Returns:

  • (Boolean)


38
39
40
# File 'lib/cukedep/feature-rep.rb', line 38

def anonymous?
  return identifier.nil?
end

#dependency_tagsObject

The list of all feature identifiers retrieved from the dependency tags



32
33
34
35
# File 'lib/cukedep/feature-rep.rb', line 32

def dependency_tags
  dep_tags = tags.select { |t| t =~ DependencyPrefix }
  return dep_tags.map { |t| t.sub(DependencyPrefix, '') }
end