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.

Raises:

  • (ArgumentError)

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

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

  super(directory_path)

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

  processed_directory_data = process_directory(directory_path)
  populate_directory(self, processed_directory_data)
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.


40
41
42
# File 'lib/cuke_modeler/models/directory.rb', line 40

def children
  @feature_files + @directories
end

#nameObject

Returns the name of the modeled directory.


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

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.


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

def to_s
  path.to_s
end