class Detroit::Project
Base class for more specific Project
types.
Attributes
Log directory. By defaul this is ‘{root}/log/`.
Root directory.
@return [Pathname]
Public Class Methods
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
# 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
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
FIXME: Lookup root directory. How?
# File lib/detroit/project.rb, line 15 def self.root Dir.pwd end
Public Instance Methods
Detroit
configuration for project.
@return [Config]
# File lib/detroit/project.rb, line 64 def config @config ||= Config.new(root) end
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
If method is missing see if it is a piece of metadata.
# 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