Class: Detroit::Project
Overview
Base class for more specific Project types.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#log ⇒ Object
readonly
Log directory.
-
#root ⇒ Pathname
readonly
Root directory.
Class Method Summary collapse
-
.factory(root) ⇒ Project
Get a new project instance based on criteria of the project.
- .lookup ⇒ Object
-
.root ⇒ Object
FIXME: Lookup root directory.
Instance Method Summary collapse
-
#config ⇒ Config
Detroit configuration for project.
-
#initialize(root) ⇒ Pathname
constructor
Initialize new instance of Project.
-
#metadata ⇒ Indexer::Metadata
Access to project metadata.
-
#method_missing(s, *a, &b) ⇒ Object
If method is missing see if it is a piece of metadata.
Constructor Details
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(s, *a, &b) ⇒ Object
If method is missing see if it is a piece of metadata.
81 82 83 84 85 |
# 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? .send(s) end |
Instance Attribute Details
#log ⇒ Object (readonly)
Log directory. By defaul this is ‘root/log/`.
59 60 61 |
# File 'lib/detroit/project.rb', line 59 def log @log end |
#root ⇒ Pathname (readonly)
Root directory.
56 57 58 |
# File 'lib/detroit/project.rb', line 56 def root @root end |
Class Method Details
.factory(root) ⇒ Project
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.
34 35 36 37 38 39 40 |
# 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 ⇒ Object
20 21 22 23 24 25 26 27 |
# 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 |
Instance Method Details
#config ⇒ Config
Detroit configuration for project.
64 65 66 |
# File 'lib/detroit/project.rb', line 64 def config @config ||= Config.new(root) end |
#metadata ⇒ Indexer::Metadata
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.
76 77 78 |
# File 'lib/detroit/project.rb', line 76 def @metadata ||= Indexer::Metadata.open(root) end |