Sha256: 7f3ad991c9ba519918d318f64d1206b7957f78f1f92069addabcc6dfc20da213

Contents?: true

Size: 1.23 KB

Versions: 2

Compression:

Stored size: 1.23 KB

Contents

module CucumberAnalytics
  class ParsedDirectory


    attr_reader :feature_files
    attr_reader :feature_directories


    # Creates a new ParsedDirectory object and, if *directory_parsed* is
    # provided, populates the object.
    def initialize(directory_parsed = nil)
      @directory = directory_parsed

      @feature_files = []
      @feature_directories = []

      scan_directory if directory_parsed
    end

    # Returns the name of the directory.
    def name
      File.basename(@directory.gsub('\\', '/'))
    end

    # Returns the path of the directory.
    def path
      @directory
    end

    # Returns the number of features files contained in the directory.
    def feature_file_count
      @feature_files.count
    end

    def contains
      @feature_files + @feature_directories
    end


    private


    def scan_directory
      entries = Dir.entries(@directory)
      entries.delete '.'
      entries.delete '..'

      entries.each do |entry|
        entry = @directory + '/' + entry
        @feature_directories << ParsedDirectory.new(entry) if File.directory?(entry)
        @feature_files << ParsedFile.new(entry) if entry =~ /\.feature$/
      end
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
cucumber_analytics-0.0.2 lib/cucumber_analytics/parsed_directory.rb
cucumber_analytics-0.0.1 lib/cucumber_analytics/parsed_directory.rb