Hello Jesper
Am 23.02.2011 um 12:59 schrieb Jesper Tholstrup Pedersen (JUP):
> The second part is making the loaded rakefile run from the correct sub
> directory.
> At the moment I have encapsulated this in a task.
>
> If you have any suggestions as to how the this could be packaged as a
> new task flavor, I'm all ears.
>
>From what I've found: __FILE__ seems to be the currently executed Ruby script,
>so passing __FILE__ to the following function should yield in changing to the
>current ruby/rake script.
def set_current_directory source_file
Dir.chdir File.dirname(source_file)
end
def task_from_current_directory source_file, *args, &block
define_task(args) { set_current_directory source_file }
define_task(args, block)
// maybe it's worth thinking about setting the current directory back
again here
end
Usage:
task_from_current_directory __FILE__, :build do
puts "task :build run."
puts "Current directory: #{Dir.pwd}"
end
This is not tested, but I hope one can get the idea. I don't know how and when
default arguments are added to a function call in ruby. Maybe it is possible to
pass the __FILE__ as a default parameter.
best regards
Torsten
_______________________________________________
Rake-devel mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rake-devel