Just include Rake::DSL in your class/file, and then you’ll be able to do the same things as in a Rakefile.