Class: CucumberAnalytics::Directory

Inherits:
Object
  • Object
show all
Includes:
Containing, Nested
Defined in:
lib/cucumber_analytics/directory.rb

Overview

A class modeling a directory containing .feature files.

Instance Attribute Summary collapse

Attributes included from Nested

#parent_element

Instance Method Summary collapse

Methods included from Nested

#get_ancestor

Constructor Details

#initialize(directory_parsed = nil) ⇒ Directory

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



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

def initialize(directory_parsed = nil)
  @directory = directory_parsed

  @feature_files = []
  @directories = []

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

Instance Attribute Details

#directoriesObject

The Directory objects contained by the Directory



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

def directories
  @directories
end

#feature_filesObject

The FeatureFile objects contained by the Directory



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

def feature_files
  @feature_files
end

Instance Method Details

#containsObject

Returns the immediate child elements of the directory (i.e. its Directory and FeatureFile objects).



54
55
56
# File 'lib/cucumber_analytics/directory.rb', line 54

def contains
  @feature_files + @directories
end

#directory_countObject

Returns the number of sub-directories contained in the directory.



43
44
45
# File 'lib/cucumber_analytics/directory.rb', line 43

def directory_count
  @directories.count
end

#feature_file_countObject

Returns the number of features files contained in the directory.



48
49
50
# File 'lib/cucumber_analytics/directory.rb', line 48

def feature_file_count
  @feature_files.count
end

#nameObject

Returns the name of the directory.



33
34
35
# File 'lib/cucumber_analytics/directory.rb', line 33

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

#pathObject

Returns the path of the directory.



38
39
40
# File 'lib/cucumber_analytics/directory.rb', line 38

def path
  @directory
end

#to_sObject

Returns the path of the directory.



59
60
61
# File 'lib/cucumber_analytics/directory.rb', line 59

def to_s
  path.to_s
end