Class: DirTraverser

Inherits:
Object
  • Object
show all
Defined in:
lib/simple-make/dir_traverser.rb

Class Method Summary collapse

Class Method Details

.all_files_in_absolute_path(base, found = []) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/simple-make/dir_traverser.rb', line 2

def self.all_files_in_absolute_path base, found=[]
  Dir.foreach(base) do |each|
    next if(each == "." || each == "..")

    full_name = base + "/" +each
    if File.directory? full_name
      all_files_in_absolute_path(full_name, found)
    else
      found << full_name
    end
  end
  found
end

.all_folders_in_absolute_path(base, found = []) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/simple-make/dir_traverser.rb', line 16

def self.all_folders_in_absolute_path base, found=[]
  Dir.foreach(base) do |each|
    next if(each == "." || each == "..")

    full_name = base + "/" +each
    if File.directory? full_name
      found << full_name
      all_folders_in_absolute_path(full_name, found)
    end
  end
  found
end