Class: Take::Project
- Inherits:
-
Object
- Object
- Take::Project
- Defined in:
- lib/take/project.rb,
lib/take/project/file.rb,
lib/take/project/target.rb,
lib/take/project/convert.rb,
lib/take/project/actionable.rb,
lib/take/project/definition.rb,
lib/take/project/requirement.rb,
lib/take/project/requirement/base.rb,
lib/take/project/requirement/header.rb,
lib/take/project/requirement/library.rb,
lib/take/project/requirement/program.rb
Overview
Handles project information for a specific project. Tends to represent an entire directory.
Defined Under Namespace
Modules: Requirement Classes: Actionable, Convert, Definition, File, Target
Instance Attribute Summary collapse
-
#name ⇒ String
The name of the project.
Class Method Summary collapse
-
.create(name = nil, path = nil, &block) ⇒ Project
Creates a new project with the block, and calls #call.
Instance Method Summary collapse
- #call ⇒ Object
- #env ⇒ Object
- #file(name) ⇒ Object
-
#initialize(name = nil, path = nil, &block) ⇒ Project
constructor
Initialize the project.
-
#path ⇒ Pathname
The path to the project.
-
#project(name) ⇒ Object
Set the project name.
-
#to_makefile ⇒ String
Creates a Makefile syntax-based string of the project.
Constructor Details
#initialize(name = nil, path = nil, &block) ⇒ Project
Initialize the project.
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/take/project.rb', line 36 def initialize(name = nil, path = nil, &block) @block = block @name = name @groups = {} @files = {} @targets = [] if path @_path = Pathname.new(path) end end |
Instance Attribute Details
#name ⇒ String
The name of the project. This is normally guessed from the directory name.
20 21 22 |
# File 'lib/take/project.rb', line 20 def name @name end |
Class Method Details
.create(name = nil, path = nil, &block) ⇒ Project
TODO:
FIX
Creates a new project with the block, and calls #call. Returns the created project. A name is not required.
29 30 31 32 33 |
# File 'lib/take/project.rb', line 29 def self.create(name = nil, path = nil, &block) project = new(name, path, &block) project.call project end |
Instance Method Details
#call ⇒ Object
59 60 61 62 63 64 |
# File 'lib/take/project.rb', line 59 def call @definition = Definition.new(self) @definition.instance_exec(&@block) p @definition @definition end |
#env ⇒ Object
81 82 83 84 85 |
# File 'lib/take/project.rb', line 81 def env { cc: "gcc" } end |
#file(name) ⇒ Object
76 77 78 79 |
# File 'lib/take/project.rb', line 76 def file(name) index = File.normalize(name, path) @files[index] ||= File.new(index) end |
#path ⇒ Pathname
The path to the project.
55 56 57 |
# File 'lib/take/project.rb', line 55 def path @_path ||= Pathname.new("/home/homer/projects/dash") end |
#project(name) ⇒ Object
Set the project name.
48 49 50 |
# File 'lib/take/project.rb', line 48 def project(name) @name = name end |
#to_makefile ⇒ String
Creates a Makefile syntax-based string of the project.
69 70 71 72 73 74 |
# File 'lib/take/project.rb', line 69 def to_makefile out = "" out << @targets. map { |target| target.to_makefile(self) }.join("\n\n") out end |