class Ferver::FerverDirectory

A wrapper around the directory specified by config

Attributes

configuration[R]

Public Class Methods

new(configuration) click to toggle source
# File lib/ferver/ferver_directory.rb, line 5
def initialize(configuration)
  path = configuration.directory_path
  raise ArgumentError, "No path is specified" if path.empty?
  raise DirectoryNotFoundError unless Dir.exist?(path)

  @configuration = configuration
end

Public Instance Methods

found_files() click to toggle source
# File lib/ferver/ferver_directory.rb, line 21
def found_files
  find_files
end
full_path() click to toggle source
# File lib/ferver/ferver_directory.rb, line 17
def full_path
  @_full_path ||= File.expand_path(path)
end
path() click to toggle source
# File lib/ferver/ferver_directory.rb, line 13
def path
  configuration.directory_path
end

Private Instance Methods

find_files() click to toggle source

Iterate through files in specified dir for valid files

# File lib/ferver/ferver_directory.rb, line 31
def find_files
  [].tap do |results|
    Dir.foreach(full_path) do |file_name|
      next if file_name == "." || file_name == ".."
      next if file_name =~ /^\./ && !configuration.serve_hidden?

      found_file = FoundFile.new(full_path, file_name)
      results << found_file if found_file.valid?
    end
  end
end