From 6b8500ce48f45f18696f6215b8a01f5cf0e328b5 Mon Sep 17 00:00:00 2001 From: Jeff Dean Date: Sun, 16 Nov 2008 22:27:08 -0500 Subject: Rails guide: Added PluginGem section, reorganized the odds and ends. --- .../doc/guides/source/creating_plugins/tasks.txt | 29 ++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 railties/doc/guides/source/creating_plugins/tasks.txt (limited to 'railties/doc/guides/source/creating_plugins/tasks.txt') diff --git a/railties/doc/guides/source/creating_plugins/tasks.txt b/railties/doc/guides/source/creating_plugins/tasks.txt new file mode 100644 index 0000000000..c71ba42bb0 --- /dev/null +++ b/railties/doc/guides/source/creating_plugins/tasks.txt @@ -0,0 +1,29 @@ +== Rake tasks == + +When you created the plugin with the built-in rails generator, it generated a rake file for you in 'vendor/plugins/yaffle/tasks/yaffle.rake'. Any rake task you add here will be available to the app. + +Many plugin authors put all of their rake tasks into a common namespace that is the same as the plugin, like so: + +*vendor/plugins/yaffle/tasks/yaffle.rake* + +[source, ruby] +--------------------------------------------------------- +namespace :yaffle do + desc "Prints out the word 'Yaffle'" + task :squawk => :environment do + puts "squawk!" + end +end +--------------------------------------------------------- + +When you run `rake -T` from your plugin you will see: + +--------------------------------------------------------- +... +yaffle:squawk # Prints out the word 'Yaffle' +... +--------------------------------------------------------- + +You can add as many files as you want in the tasks directory, and if they end in .rake Rails will pick them up. + +Note that tasks from 'vendor/plugins/yaffle/Rakefile' are not available to the main app. \ No newline at end of file -- cgit v1.2.3