Sha256: 3d3498e7fc83ed360f0227729f37f7ad54405137ad8a07dd0971ae19a855bd9c

Contents?: true

Size: 1.34 KB

Versions: 7

Compression:

Stored size: 1.34 KB

Contents

# File: feature-rep.rb

module Cukedep # This module is used as a namespace


# A FeatureRep is the internal representation of a Gherkin feature.
class FeatureRep
  # Constant that specifies how feature identifier tags should begin
  FeatureIdPrefix = /^feature:/
  
  # Constant that specifies how dependency tags should begin
  DependencyPrefix = /^depends_on:/
  
  # The sorted list of all tags of the feature.
  # The @ prefix is stripped from each tag text.
  attr_reader(:tags)
  
  # The identifier of the feature. 
  # It comes from a tag with the following syntax '@feature_' + identifier.
  # Note that the @feature_ prefix is removed.
  attr_reader(:identifier)


  # theTags the tags objects from the Gherkin parser
  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
  
  public
  # The list of all feature identifiers retrieved from the dependency tags
  def dependency_tags()
    dep_tags = tags.select { |t| t =~ DependencyPrefix }
    return dep_tags.map { |t| t.sub(DependencyPrefix, '') }
  end
  
  # Return true iff the identifier of the feature is nil.
  def anonymous?()
    return identifier.nil?
  end

end # class

end # module

# End of file

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
cukedep-0.0.8 lib/cukedep/feature-rep.rb
cukedep-0.0.7 lib/cukedep/feature-rep.rb
cukedep-0.0.6 lib/cukedep/feature-rep.rb
cukedep-0.0.5 lib/cukedep/feature-rep.rb
cukedep-0.0.4 lib/cukedep/feature-rep.rb
cukedep-0.0.3 lib/cukedep/feature-rep.rb
cukedep-0.0.1 lib/cukedep/feature-rep.rb