Class: CukeModeler::FeatureFile

Inherits:
Model
  • Object
show all
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 Nested

#parent_model

Instance Method Summary collapse

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.



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/cuke_modeler/models/feature_file.rb', line 17

def initialize(file_path = nil)
  @path = file_path

  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

#featureObject

The feature model contained by the modeled feature file



9
10
11
# File 'lib/cuke_modeler/models/feature_file.rb', line 9

def feature
  @feature
end

#pathObject

The file path of the modeled feature file



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

def path
  @path
end

Instance Method Details

#childrenObject

Returns the model objects that belong to this model.



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

def children
  [@feature]
end

#nameObject

Returns the name of the modeled feature file.



32
33
34
# File 'lib/cuke_modeler/models/feature_file.rb', line 32

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.



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

def to_s
  path.to_s
end