Class: CukeModeler::FeatureFile

Inherits:
Model
  • Object
show all
Includes:
Parsed
Defined in:
lib/cuke_modeler/models/feature_file.rb

Overview

A class modeling a feature file in a Cucumber suite.

Instance Attribute Summary collapse

Attributes included from Parsed

#parsing_data

Attributes included from Nested

#parent_model

Instance Method Summary collapse

Methods included from Containing

#each_descendant, #each_model

Methods included from Nested

#get_ancestor

Constructor Details

#initialize(file_path = nil) ⇒ FeatureFile

Creates a new FeatureFile object and, if file_path is provided, populates the object.



22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/cuke_modeler/models/feature_file.rb', line 22

def initialize(file_path = nil)
  @path = file_path
  @comments = []

  super(file_path)

  if file_path
    raise(ArgumentError, "Unknown file: #{file_path.inspect}") unless File.exists?(file_path)

    processed_feature_file_data = process_feature_file(file_path)
    populate_featurefile(self, processed_feature_file_data)
  end

end

Instance Attribute Details

#commentsObject

The comment models contained by the modeled feature file



11
12
13
# File 'lib/cuke_modeler/models/feature_file.rb', line 11

def comments
  @comments
end

#featureObject

The feature model contained by the modeled feature file



14
15
16
# File 'lib/cuke_modeler/models/feature_file.rb', line 14

def feature
  @feature
end

#pathObject

The file path of the modeled feature file



17
18
19
# File 'lib/cuke_modeler/models/feature_file.rb', line 17

def path
  @path
end

Instance Method Details

#childrenObject

Returns the model objects that belong to this model.



43
44
45
# File 'lib/cuke_modeler/models/feature_file.rb', line 43

def children
  @feature ? [@feature] : []
end

#nameObject

Returns the name of the modeled feature file.



38
39
40
# File 'lib/cuke_modeler/models/feature_file.rb', line 38

def name
  File.basename(@path.gsub('\\', '/')) if @path
end

#to_sObject

Returns a string representation of this model. For a feature file model, this will be the path of the modeled feature file.



49
50
51
# File 'lib/cuke_modeler/models/feature_file.rb', line 49

def to_s
  path.to_s
end