Required file for rake task -- put into a plugin?

Hello all. I’ve just written up a bit of ruby code that I’d like to use
in a rake task for my web application (it has to be run on a schedule,
and calling rake through cron seems to be a good way to do that).

My question is: Where should I place this code so that it’s both
accessible to the rake task and logically located in the rails
application directory structure?

I could place it into a plugin. However, I don’t feel entirely
comfortable with that approach since this functionality is pretty
important to the application. It’s not really something that should be
tacked on.

I could also place the code into the lib/tasks directory. However, that
seems rather messy.

Where would you put it? Thanks for any suggestions or insight.

Hello Jon,

2006/12/5, Jon F. [email protected]:

I could also place the code into the lib/tasks directory. However, that
seems rather messy.

Why do you think it’s messy ? That’s where Rake tasks are supposed to
go.

Simply name your file “lib/tasks/mytasks.rake” and go from there.

Bye !

François Beausoleil
http://blog.teksol.info/
http://piston.rubyforge.org/

Thanks, François!

I have no problem putting the rake file in the lib/tasks directory. I’m
just curious whether I should also put my library file (containing
objects I use in the rake task) in the same place. It just struck me as
a little messy to put it in the same directory as the rake task files.

Hello Jon,

2006/12/5, Jon F. [email protected]:

Okay, I went googling around the web and ran across at least one example
of libraries being placed in – you guessed it – the lib directory.
That seems to work correctly for rake and the application controllers.
It also doesn’t offend my rails-powered sense of ‘rightness’.

I realize now that I misread your original E-Mail. You wanted to have
some utility code available for the Rake task, but not necessarily for
the rest of the application. Now that I understand your requirement,
I guess I would simply have dropped the code in the task file.
Simple, effective.

Bye !

François Beausoleil
http://blog.teksol.info/
http://piston.rubyforge.org/

Okay, I went googling around the web and ran across at least one example
of libraries being placed in – you guessed it – the lib directory.
That seems to work correctly for rake and the application controllers.
It also doesn’t offend my rails-powered sense of ‘rightness’.

( Ah, so obvious… )

Thanks!