Class: Reconn::ProjectScanner

Inherits:
Object
  • Object
show all
Defined in:
lib/reconn/util/project_scanner.rb

Class Method Summary collapse

Class Method Details

.scan(proj_path) ⇒ Array<String>

Scans the given directory and all its subdirectories for ruby files

Parameters:

  • proj_path (String)

    path to the project directory

Returns:

  • (Array<String>)

    paths to the ruby files

Raises:

  • (InvalidPathException)

    if it can’t open the directory



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/reconn/util/project_scanner.rb', line 10

def self.scan(proj_path)
  paths = []
  begin
    Find.find(proj_path) do |path|
      if FileTest.directory?(path)
        if File.basename(path)[0] == '.'
          Find.prune
        end
      end
      if File.extname(path) == '.rb'
        paths << path
      end
    end
  rescue
    raise InvalidPathException, "Can't open the directory"
  end

  paths
end