Giulio Piancastelli
3/22/2005 4:57:00 PM
Jim Weirich wrote:
> If you can post the details of what you are doing, I'd be glad to
give a hand.
Well, I took another shot at a TaskLib implementation, and perhaps
found what was wrong with my code. Initially I wrote:
module Rake
class FitTestTask < TaskLib
attr_accessor :name, :libs, :pattern
def test_files=(list)
@test_files = list
end
def initialize(name=:fittest)
@name = name
@libs = ["lib"]
@pattern = nil
@test_files = nil
yield self if block_given?
define
end
def define
puts "Running FitTest tasklib with #@libs and tests #@test_files"
self
end
end
end
And rake aborted with the error message I reported. Then,
reimplementing, I noticed that you were actually *defining* a task in
TestTask#define, so I came up with:
def define
task @name do
puts "Running FitTest tasklib with #@libs and tests #@test_files"
end
self
end
This way, Rake runs fine, even if I don't understand the internal
mechanics. So, must every task in the lib be defined at once in a
method called by the constructor? The pattern usage of tasks seems to
suggest that (it's always Rake::SomeTask.new {...}) but I'd like to
hear more about this.
And... is it just *that* easy? Or are there other details I should be
aware of?
I'll try to define my tasks in a lib now; I'll get back to the
newsgroup if I happen to face some problems, perhaps harder to think
about than the latest. Sorry to bother.
Best Regards,
Giulio Piancastelli.