Class: Paperwork::Tasks::Base
- Inherits:
-
Object
- Object
- Paperwork::Tasks::Base
show all
- Defined in:
- lib/paperwork/tasks/base.rb
Overview
base class for all task generators. takes care that every task is registered and executed during build
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(name, *dependencies) ⇒ Base
Returns a new instance of Base.
15
16
17
18
19
|
# File 'lib/paperwork/tasks/base.rb', line 15
def initialize(name, *dependencies)
@name = name
@dependencies = dependencies.compact
self.register(self)
end
|
Instance Attribute Details
#dependencies ⇒ Object
Returns the value of attribute dependencies.
13
14
15
|
# File 'lib/paperwork/tasks/base.rb', line 13
def dependencies
@dependencies
end
|
#name ⇒ Object
Returns the value of attribute name.
13
14
15
|
# File 'lib/paperwork/tasks/base.rb', line 13
def name
@name
end
|
Class Method Details
.explain ⇒ Object
39
40
41
42
43
44
|
# File 'lib/paperwork/tasks/base.rb', line 39
def self.explain
list = @@registered_tasks.map do |_name, task|
"\t#{task.class}: #{task.name} => #{task.dependencies}"
end
list.join("\n")
end
|
Instance Method Details
#create_tasks ⇒ Object
33
34
35
36
37
|
# File 'lib/paperwork/tasks/base.rb', line 33
def create_tasks
registered_tasks.each do |_name, task|
task.tasks
end
end
|
#register(task) ⇒ Object
21
22
23
|
# File 'lib/paperwork/tasks/base.rb', line 21
def register(task)
registered_tasks[task.name] = task unless registered?(task.name)
end
|
#registered?(name) ⇒ Boolean
29
30
31
|
# File 'lib/paperwork/tasks/base.rb', line 29
def registered?(name)
registered_tasks.keys.include?(name)
end
|
#registered_tasks ⇒ Object
25
26
27
|
# File 'lib/paperwork/tasks/base.rb', line 25
def registered_tasks
@@registered_tasks ||= {}
end
|