Rake as a library/API: possible?

D

David Palm

Hi all,
I'm trying to use rake as a library/API to retrieve the rake tasks in a given directory.

Basically I'm looking to mimic the output of
rake --tasks --silent

Looking through the source code and trying out some stuff in irb I'm getting the impression this usage was not considered at design stage. But is it possible?
...throws me out of IRB, as does "Rake::Application.new.run"

I've been trying for a good while to get around the above all to no avail.

Can this be done? Am I better off by just doing:
tasks = x%{rake --tasks --silent}

Thanks!
David
 
R

Ryan Davis

Looking through the source code and trying out some stuff in irb I'm
getting the impression this usage was not considered at design
stage. But is it possible?

...throws me out of IRB, as does "Rake::Application.new.run"

I think the biggie is that Rake::Application is a singleton.

% ruby -rubygems -e 'require "rake"; load "Rakefile"; p
Rake.application.tasks.map { |t| t.name }.sort'
["announce", "audit", "autotest", "check_extra_deps",
"check_manifest", "clean", "clobber", "clobber_docs",
"clobber_package", "clobber_rcov", "config_hoe", "debug_gem",
"default", "deps:email", "deps:fetch", "deps:list", "doc", "doc/
index.html", "docs", "email", "flay", "flog", "gem", "generate_key",
"install_gem", "multi", "package", "pkg", "pkg/ZenTest-4.0.0", "pkg/
ZenTest-4.0.0.gem", "pkg/ZenTest-4.0.0.tgz", "post_blog", "post_news",
"publish_docs", "publish_on_announce", "rcov", "rcov_info",
"rcov_overlay", "redocs", "release", "repackage", "ridocs", "sort",
"test", "test_deps", "update"]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,233
Members
46,820
Latest member
GilbertoA5

Latest Threads

Top