Class: Exegesis::FileSearcher

Inherits:
Object
  • Object
show all
Defined in:
lib/exegesis/file_searcher.rb

Instance Method Summary collapse

Constructor Details

#initialize(parent, fs_interface = File) ⇒ FileSearcher

Create a new FileSearcher on the given path

Parameters:

  • parent (Directory)

    the parent directory to search downward from



23
24
25
26
# File 'lib/exegesis/file_searcher.rb', line 23

def initialize(parent, fs_interface = File)
  @fs_interface = fs_interface
  @parent = parent
end

Instance Method Details

#contentObject

All of the content from the given path



43
44
45
# File 'lib/exegesis/file_searcher.rb', line 43

def content
  Dir[File.join(parent.path, '*')]
end

#directoriesObject

All of the directories in the given path



29
30
31
32
33
# File 'lib/exegesis/file_searcher.rb', line 29

def directories
  content.
    select { |s| fs_interface.directory?(s) }.
    map    { |s| Directory.create(parent, fs_interface.basename(s)) }
end

#filesObject

All of the files in the given path



36
37
38
39
40
# File 'lib/exegesis/file_searcher.rb', line 36

def files
  content.
    select { |s| fs_interface.file?(s) }.
    map    { |s| SourceFile.create(parent, fs_interface.basename(s)) }
end

#inspectObject



47
48
49
# File 'lib/exegesis/file_searcher.rb', line 47

def inspect
  "FileSearcher(#{parent.path.inspect})"
end