Class: Take::Project

Inherits:
Object
  • Object
show all
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

Class Method Summary collapse

Instance Method Summary collapse

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

#nameString

The name of the project. This is normally guessed from the directory name.

Returns:

  • (String)


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.

Parameters:

  • name (String?) (defaults to: nil)

    the name of the project. If it is not given, it is assumed from the directory name.

Returns:



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

#callObject



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

#envObject



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

#pathPathname

The path to the project.

Returns:

  • (Pathname)


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_makefileString

Creates a Makefile syntax-based string of the project.

Returns:

  • (String)


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