Hi Sawyer, On Sat, 28 Jul 2012 18:13:44 +0300 sawyer x <xsawy...@gmail.com> wrote:
> Hi, > > I wanted to consult on whether something is actually useful enough to > upload to CPAN. Perhaps I'm simply missing something obvious. > > Data::Tabular::Document (for the lack of a better name at the moment) > allows you to create a document with rows, with each row having items. They > are all objects, so you can create them separately and then add them. At > the end you can render it using any one of a few given renderers. Sounds good. I've had a similar idea for a module that renders tables into a multitude of formats and protocols (e.g: https://metacpan.org/release/Text-Table (which I maintain), HTML tables, Excel tables, CSV, tab-separated values, Google Docs, etc.), but did not do anything to implement it. Maybe we can collaborate on this module. > > The purpose is dual: > 1. Separate the view from the logics (as MVC does). So you add a document > and rows and items without caring what the output is. Then you can output > it however you want (CSV/Excel/etc.). This cleans up the code from having > output-specific handling. You just push it in the document, and then pick > the rendering format. Yes, please. > 2. Allow composing a row without adding it. I had a situation where I only > knew whether I needed a row or not at the end of a process. By that time, > I've already had to add the items. I could put the row data separately and > at the end of the processing put it in, but if you're using Excel, you need > to add each item separately so it becomes tricky. With this module, I can > create a new Data::Tabular::Document::Row object and add items to it. At > the end, I can decide to $doc->add_row($row_object) if I want to. > Sounds good. Hopefully there will also be a way to delete or manipulate previous rows. > Some extra info: > - Each item has "content" and "format". The format is not mandatory but > will be used if you're using Excel rendering and want cell formatting. > - Each row has "items" and "format". The format provides a general > row-level format. The row object maintains the item column so you can just > add and it will column it automatically. You could pick a specific column > for an item when you insert it into a row. > - Each document has "rows". It does the same as the row object to maintain > the index of the row so it stacks them when you add them without needing to > indicate which row number it is. > - You don't have to insert Row objects into a document or Item objects into > a row. If you simply give the data, one will be created for you. > - Each of these objects has an ID, so even if you add an anonymous one > (instead of an actual object) you get the ID back so you can play with it > (like removing it). When you dump the rows, you can get them either with > their IDs or just the rows themselves. > - When you render, you can give parameters that go to the renderer's > constructor. Sounds good. > > So the question is: is this totally worthless? Is it useful? It is useful > enough to upload to CPAN? Is there a better, more comfortable/correct way > of doing it? It sounds useful and worthy of being on CPAN. I'm not aware of a previous CPAN effort, but there might be. Regards, Shlomi Fish -- ----------------------------------------------------------------- Shlomi Fish http://www.shlomifish.org/ Rethinking CPAN - http://shlom.in/rethinking-cpan Chuck Norris writes understandable Perl code. Please reply to list if it's a mailing list post - http://shlom.in/reply .