SOS Taskable

I’m stuck. I can’t figure out how to implement Taskable. If you haven;t
seen my rantings abut this before, Taskable is an emulation of Rake’s
task syntax:

desc “this and that”

task ‘foo’ => [ ‘bar’ ] do


but limted to the scope of a module/class. Also, tasks themselves are
just be regular methods.

It’s easy enough to define:

class Module
def task( name_preqs, &action )
if Hash === name_preqs
name = name_preqs.key
preqs = name_preqs.value
name = name_preqs
preqs = []
define_method( name ) do |*args|
preqs.each { |n| send(n,*args) }*args)

The challenge comes from keeping track of the prequistes so they won’t
get run more than once. With some help on this list I came to
understand that I needed to use TSort, that much seemed to work. But
problems arise in just looking up the tasks. Consider when a module
extends itself, then a task is called at the module level, how will it
look up a prerequiste that was defined at the instance level?

Anyway, the whole idea was to create a system that parallels Method,
UnboundMethod, instance_method, instance_methods, etc., but substitute
‘task’ for ‘method’. Maybe this is just too low level to be pulled off
in pure Ruby? I’m on the verge of giving up --I’m weary of working on
it. Butmaybe someone else can see a clear soltuion?


Trans wrote:

I’m stuck. I can’t figure out how to implement Taskable.

Never mind. I just reworote the whole thing from scratch WITHOUT using
TSort and got it to work.