Mar 27 2009
How to create a dradis export plugin?
Although we presented some of this concepts already in dradis reporting: quick & neat word export, here is the step by step guide to get an export plugin recognised by the dradis framework and ready to use!
Update (2009-04-09): Checkout the new import/export plugin generators at dradis community forums.
Generate the plugin skeleton
$ ./script/generate plugin my_export create vendor/plugins/my_export/lib create vendor/plugins/my_export/tasks create vendor/plugins/my_export/test create vendor/plugins/my_export/README create vendor/plugins/my_export/MIT-LICENSE create vendor/plugins/my_export/Rakefile create vendor/plugins/my_export/init.rb create vendor/plugins/my_export/install.rb create vendor/plugins/my_export/uninstall.rb create vendor/plugins/my_export/lib/my_export.rb create vendor/plugins/my_export/tasks/my_export_tasks.rake create vendor/plugins/my_export/test/my_export_test.rb
Edit vendor/plugins/my_export/init.rb to include the main plugin library:
# Include hook code here require 'my_export'
In the main library (vendor/plugins/my_export/lib/my_export.rb), define a module (choose a name, ideally it should match the plugin name):
# MyExport module MyExport end
This is all you really need to get it started. Now you have to put your code in the right place so the framework finds it (and creates an entry for you in the export menu).
Hooking into the framework
At the end of the day an export plugin provides a number of Rails actions. These are methods that will be invoked through the URL, for instance:-
/export/to_pdf /export/to_xml /export/to_excel ...
Each export plugin can define several actions. If more than one action is defined a nested submenu will be appended to the export menu with all the defined actions.
In order for the framework to find your actions, they have to be defined in a certain way, they have to be defined inside the Actions module (we are still editing the same file):-
# MyExport module MyExport module Actions # first action def to_myformat(params={}) # your action code goes here end # second action # [...] end end
And that’s it, nice and easy, you can define as many actions as you like in you Actions module.
Finally, in order to make everything work together you need to include your module in the main repository of export plugins (Plugins::Export):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | # MyExport module MyExport module Actions # first action def to_myformat(params={}) # your action code goes here end # [...] end end module Plugins module Export include MyExport end end |
Remember to restart you dradis server. Your export menu should have an entry for your newly created plugin. And now is the time to be creative about what you implement!
Popularity: 11% [?]

June 14th, 2009 at 10:46 am
[...] to Dradis, you can download plugins here: http://dradisframework.org/community/index.php?board=2.0 http://usefulfor.com/ruby/2009/03/27/how-to-create-a-dradis-export-plugin/SHARETHIS.addEntry({ title: “Update: Dradis v2.2!”, url: [...]