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.

Raises:

  • (ArgumentError)

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

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

  super(file_path)

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

  processed_feature_file_data = process_feature_file(file_path)
  populate_featurefile(self, processed_feature_file_data)
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.


41
42
43
# File 'lib/cuke_modeler/models/feature_file.rb', line 41

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

#nameObject

Returns the name of the modeled feature file.


36
37
38
# File 'lib/cuke_modeler/models/feature_file.rb', line 36

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.


47
48
49
# File 'lib/cuke_modeler/models/feature_file.rb', line 47

def to_s
  path.to_s
end