class Detroit::Project

Base class for more specific Project types.

Attributes

log[R]

Log directory. By defaul this is ‘{root}/log/`.

root[R]

Root directory.

@return [Pathname]

Public Class Methods

factory(root) click to toggle source

Get a new project instance based on criteria of the project. For instance a project with a ‘*.gemspec` is recognized as a Ruby project and thus returns an instance of {RubyProject}.

@return [Project]

# File lib/detroit/project.rb, line 34
def self.factory(root)
  if RubyProject.project?(root)
    RubyProject.new(root)
  else
    Project.new(root)
  end
end
lookup() click to toggle source
# File lib/detroit/project.rb, line 20
def self.lookup
  dir = Dir.pwd
  while dir != '/' #&& dir != $HOME
    return new(dir) if project?(dir)
    dir = File.dirname(dir)
  end
  return nil
end
new(root) click to toggle source

Initialize new instance of Project.

@param [String,Pathname] root

Root directory of project.

@return [Pathname]

# File lib/detroit/project.rb, line 48
def initialize(root)
  @root = Pathname.new(root)
  @log  = @root + 'log'
end
root() click to toggle source

FIXME: Lookup root directory. How?

# File lib/detroit/project.rb, line 15
def self.root
  Dir.pwd 
end

Public Instance Methods

config() click to toggle source

Detroit configuration for project.

@return [Config]

# File lib/detroit/project.rb, line 64
def config
  @config ||= Config.new(root)
end
metadata() click to toggle source

Access to project metadata. Metadata is handled by Indexer. If a specific project type has different needs then override this method. The return value should work akin to an OpenStruct instance, and if possible it should respond to ‘#to_h` method.

@return [Indexer::Metadata]

# File lib/detroit/project.rb, line 76
def metadata
  @metadata ||= Indexer::Metadata.open(root)
end
method_missing(s, *a, &b) click to toggle source

If method is missing see if it is a piece of metadata.

Calls superclass method
# File lib/detroit/project.rb, line 81
def method_missing(s, *a, &b)
  super(s, *a, &b) unless a.empty?
  super(s, *a, &b) if block_given?
  metadata.send(s)
end