Class: Nova::Task

Inherits:
Object
  • Object
show all
Defined in:
lib/cocoanova/task.rb

Direct Known Subclasses

Compile

Defined Under Namespace

Classes: Compile

Constant Summary collapse

Tasks =
{}

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.[](key) ⇒ Object



11
12
13
# File 'lib/cocoanova/task.rb', line 11

def self.[](key)
    Tasks[key.to_sym] || []
end

.[]=(key, value) ⇒ Object



15
16
17
18
# File 'lib/cocoanova/task.rb', line 15

def self.[]=(key, value)
    Tasks[key.to_sym] ||= []
    Tasks[key.to_sym] << value
end

.invoke(name, params = {}) ⇒ Object



20
21
22
23
24
25
26
27
# File 'lib/cocoanova/task.rb', line 20

def self.invoke(name, params = {})
    total = self[name].count
    raise "Task #{name} not found" if total == 0
    self[name].each_with_index do |task, idx|
        puts "===> #{idx + 1}/#{total} #{task}"
        task.new.invoke(params)
    end
end

.require_allObject



7
8
9
# File 'lib/cocoanova/task.rb', line 7

def self.require_all
    Nova.require_folder :tasks
end

.task(*names) ⇒ Object

For Register



31
32
33
34
35
# File 'lib/cocoanova/task.rb', line 31

def self.task(*names)
    names.flatten.each do |name|
        Nova::Task[name] = self
    end
end

Instance Method Details

#invoke(params = {}) ⇒ Object

For subclassing



39
40
# File 'lib/cocoanova/task.rb', line 39

def invoke(params = {})
end