buildr-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrew Moore <>
Subject Task name which called a method
Date Fri, 29 Jan 2010 15:58:58 GMT


I'm a ruby newbie, and I've been using BuildR off and on for a bit
(currently 1.3.3), but I was wondering if there is a way to access the name
of a task that calls a method without passing an argument to that method.
For instance:

def print_task_name()
  # print the name of the task that called this function
  puts '['+taskName+']'

desc 'my-project'
define 'my-project'

  desc 'taskA'
  task 'taskA' do

  desc 'taskB'
  task 'taskB'

end #my-project

My goal is that if I run:

buildr my-project:taskA 

that the print_task_name method will print:


I've been searching through the various Rake, Buildr, and Ruby API's and the
closest I've come is the core ruby 'caller' method. I've spent enough time
trying to figure it out that it's time to ask the experts!

Is what I'm wanting to do possible without adding an argument to the
print_task_name method?

Thanks in advance for your help!



View this message in context:
Sent from the Apache Buildr - User mailing list archive at

View raw message