buildr-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Antoine Toulme <>
Subject Re: Task name which called a method
Date Fri, 29 Jan 2010 16:32:41 GMT
In that case I would define the task and its method before, and then the
task name is available by calling self.to_s

You could use a module to make it simple:

module Stuff

  def foo



task('bar') do |t|
  t.extend Stuff



On Fri, Jan 29, 2010 at 08:25, Andrew Moore <>wrote:

> Thanks for the quick response...
> I'm wanting to try and figure out the task name from within a method called
> from the task as opposed to within the task itself.
> I had hoped there would be some sort of callstack or scope kept by buildr
> or
> something I could tap into to get that information while within the
> print_task_name method. In my real-world example I'm doing some other
> system
> calls, testing the result and hoping to fail the build with a message that
> has the task name in it. It sounds like I would have to add the '|t|' to
> each task and pass it into each method call. I was hoping to avoid doing
> that for every task and call to my method (keeping it a bit DRYer).
> Any other thoughts?
> ~ Andrew
> --
> View this message in context:
> Sent from the Apache Buildr - User mailing list archive at

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message