Class: CukeModeler::Directory

Inherits:
Model
  • Object
show all
Defined in:
lib/cuke_modeler/models/directory.rb

Overview

A class modeling a directory in a Cucumber suite.

Instance Attribute Summary collapse

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(directory_path = nil) ⇒ Directory

Creates a new Directory object and, if directory_path is provided, populates the object.



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

def initialize(directory_path = nil)
  @path = directory_path
  @feature_files = []
  @directories = []

  super(directory_path)

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

    processed_directory_data = process_directory(directory_path)
    populate_directory(self, processed_directory_data)
  end
end

Instance Attribute Details

#directoriesObject

The directory models contained by the modeled directory



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

def directories
  @directories
end

#feature_filesObject

The feature file models contained by the modeled directory



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

def feature_files
  @feature_files
end

#pathObject

The file path of the modeled directory



15
16
17
# File 'lib/cuke_modeler/models/directory.rb', line 15

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/directory.rb', line 41

def children
  @feature_files + @directories
end

#nameObject

Returns the name of the modeled directory.



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

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

#to_sObject

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



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

def to_s
  path.to_s
end