Tap classes without manifest are not shown

1 view
Skip to first unread message

grosser.michael

unread,
Dec 14, 2008, 12:48:51 PM12/14/08
to Tap Forum
in lib/goodnight.rb
class Goodnight < Tap::Task
config :message, 'goodnight' # a goodnight message

def process(name)
puts "#{message} #{name}"
end
end

tap run -T
dump # the default dump task
load # the default load task
rake # run rake tasks
tap run goodnight
unknown task: goodnight

Simon Chiang

unread,
Dec 14, 2008, 7:21:33 PM12/14/08
to ruby-...@googlegroups.com
This is the expected behavior.  Tap needs to discover tasks 'somehow'.  Loading all the files under a lib directory arbitrarily is obviously not acceptable so solutions that use live code don't work.  You could make a separate manifest file but that's new overhead.  I decided to use a comment-based marker to indicate when a .rb file has a task to-be-discovered.

That marker is '::manifest' (it's a Lazydoc constant attribute).

In your example here, Goodnight could be used by tap but tap doesn't know it exists because there isn't a '::manifest' comment.  Yeah, it is overhead but I think it's the least amount of overhead possible and it allows you to define tasks that are by design not picked up by 'tap' (like base classes, for instance).


[lib/goodnight.rb]

# ::manifest <this is the summary string on the command line>


class Goodnight < Tap::Task
 config :message, 'goodnight'           # a goodnight message

 def process(name)
   puts "#{message} #{name}"
 end
end

That should solve it!
Reply all
Reply to author
Forward
0 new messages