class CucumberAnalytics::Directory
A class modeling a directory containing .feature files.
Attributes
feature_files[RW]
The FeatureFile
objects contained by the Directory
Public Class Methods
new(directory_parsed = nil)
click to toggle source
Creates a new Directory
object and, if directory_parsed is provided, populates the object.
# 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
Public Instance Methods
contains()
click to toggle source
Returns the immediate child elements of the directory (i.e. its Directory
and FeatureFile
objects).
# File lib/cucumber_analytics/directory.rb, line 54 def contains @feature_files + @directories end
directory_count()
click to toggle source
Returns the number of sub-directories contained in the directory.
# File lib/cucumber_analytics/directory.rb, line 43 def directory_count @directories.count end
feature_file_count()
click to toggle source
Returns the number of features files contained in the directory.
# File lib/cucumber_analytics/directory.rb, line 48 def feature_file_count @feature_files.count end
name()
click to toggle source
Returns the name of the directory.
# File lib/cucumber_analytics/directory.rb, line 33 def name File.basename(@directory.gsub('\\', '/')) end
path()
click to toggle source
Returns the path of the directory.
# File lib/cucumber_analytics/directory.rb, line 38 def path @directory end
to_s()
click to toggle source
Returns the path of the directory.
# File lib/cucumber_analytics/directory.rb, line 59 def to_s path.to_s end
Private Instance Methods
build_directory()
click to toggle source
# File lib/cucumber_analytics/directory.rb, line 67 def build_directory entries = Dir.entries(@directory) entries.delete '.' entries.delete '..' entries.each do |entry| entry = "#{@directory}/#{entry}" case when File.directory?(entry) @directories << build_child_element(Directory, entry) when entry =~ /\.feature$/ @feature_files << build_child_element(FeatureFile, entry) end end end