Project

General

Profile

« Previous | Next » 

Revision 429ebb9c

Added by Marc Dequènes over 13 years ago

  • ID 429ebb9c1a44108e2da28316170ad4345617a58d

[evol] BotnetTask DSL: now that we have one Task per task, close conversation thread as soon as the task is finished

View differences:

lib/cyborghood/cyborg/dsl.rb
reveal :logger
end
class Task < BaseDSL
class TaskBase < BaseDSL
attr_reader :bot, :name, :errors, :results
@@task_wip = 0
......
@notification_name = "task/#{@name}"
_setup
_start_dsl &block
end
def run_dsl
end
# may return a Hash of results
def schedule(&job)
_add_subtask("job/#{job.hash}") do |subtask|
......
if cb
_start_dsl(&cb)
else
@@task_wip -= 1
logger.debug "Task '#{@name}': finished (#{@@task_wip} remaining)"
_finished
end
end
......
true
end
def _setup
logger.debug "Task '#{@name}': created"
end
def _start_dsl(&block)
@dsl_runing = false
@subtasks = []
......
true
end
def _finished
@@task_wip -= 1
logger.debug "Task '#{@name}': finished (#{@@task_wip} remaining)"
end
end
# this empty class is used as a trick to be able to inject features
# as module.prepend does not exist yet
class Task < TaskBase
end
end
end

Also available in: Unified diff