Module: ProjectScout

Defined in:
lib/project_scout.rb,
lib/project_scout/dir.rb

Defined Under Namespace

Classes: Dir

Class Method Summary collapse

Class Method Details

.Dir(path) ⇒ Object



70
71
72
# File 'lib/project_scout/dir.rb', line 70

def Dir(path)
  ProjectScout::Dir.new path
end

.scan(path, options = {}) ⇒ Object

Search recursively from the current working directory up for something that looks like the root directory of a Ruby project.

Returns the path to the first found project dir, if any. Nil otherwise.

Stops looking when it reaches the top of the tree.

By default, it will search for any kind of ruby project, but you can specify exactly how to scan using the optional :for parameter. See ProjectScout::Dir for the kinds of projects you can scan for.

Example Usage: ProjectScout.scan “/some/path” ProjectScout.scan “/some/path”, :for => [ :ruby_rails, :ruby_cucumber ]



20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/project_scout.rb', line 20

def scan(path, options = {})
  unless File.directory? path
    raise RuntimeError.new("#{path} does not exist")
  end

  path = File.expand_path(path)
  while path != '/'
    result = check_path path, options[:for]
    return result unless result.nil?
    path = File.expand_path(path + '/..')
  end
  nil
end