Multi-Purpose format plugins

1 view
Skip to first unread message

Gregory Brown

unread,
Feb 8, 2007, 6:23:54 PM2/8/07
to Ruby Reports
In trunk, I've got multi-purpose plugins working.

What they do is provide the name of your format inside of the plugin,
so that you can handle it appropriately.

You can also have something like:


def build_header
csv { output << data.to_csv }
text { output <<< data.join(' | ') }
end

where something like
format_name { .. }

will only run the block if the plugin is being invoked for that format.

I also added syntactic sugar for plugin registration in the form of:
renders :csv, :for => MyRenderer

For a more comprehensive example, see the simplified code from the
grouping example I posted earlier this week.

http://pastie.caboo.se/38970

You can also see the changeset which adds these features:
http://stonecode.svnrepository.com/ruport/trac.cgi/changeset/519

I'm interested in what people think of these changes. Once we add in
the smart hooks to the Report DSL, i figure they could be a pretty
helpful abstraction.

Gregory Brown

unread,
Feb 8, 2007, 6:26:44 PM2/8/07
to Ruby Reports
On 2/8/07, Gregory Brown <gregory...@gmail.com> wrote:
> In trunk, I've got multi-purpose plugins working.
>
> What they do is provide the name of your format inside of the plugin,
> so that you can handle it appropriately.
>
> You can also have something like:
>
>
> def build_header
> csv { output << data.to_csv }
> text { output <<< data.join(' | ') }

whoops, << not <<<

Reply all
Reply to author
Forward
0 new messages