[Catalyst-commits] r8597 - in Catalyst-Action-Serialize-SimpleExcel/1.000/trunk: . lib/Catalyst/Action/Serialize t

caelum at dev.catalyst.perl.org caelum at dev.catalyst.perl.org
Wed Nov 12 21:18:45 GMT 2008


Author: caelum
Date: 2008-11-12 21:18:45 +0000 (Wed, 12 Nov 2008)
New Revision: 8597

Modified:
   Catalyst-Action-Serialize-SimpleExcel/1.000/trunk/Changes
   Catalyst-Action-Serialize-SimpleExcel/1.000/trunk/META.yml
   Catalyst-Action-Serialize-SimpleExcel/1.000/trunk/lib/Catalyst/Action/Serialize/SimpleExcel.pm
   Catalyst-Action-Serialize-SimpleExcel/1.000/trunk/t/excel.t
Log:
C::A::Serialize::SimpleExcel: CPAN release


Modified: Catalyst-Action-Serialize-SimpleExcel/1.000/trunk/Changes
===================================================================
--- Catalyst-Action-Serialize-SimpleExcel/1.000/trunk/Changes	2008-11-12 17:30:33 UTC (rev 8596)
+++ Catalyst-Action-Serialize-SimpleExcel/1.000/trunk/Changes	2008-11-12 21:18:45 UTC (rev 8597)
@@ -1,5 +1,9 @@
 Revision history for Catalyst-Action-Serialize-SimpleExcel
 
-0.01_01  2008-11-11 03:34:23
+0.011  2008-11-12 13:17:16 PDT
+    First CPAN release, fixed Content-Type and used HashRefInflator in example
+    as jshirley suggested.
+
+0.01_01  2008-11-11 03:34:23 PDT
     svn deleted all my files then rebuilt it from screen scrollback buffers,
     just as I was putting the finishing touches on the dist.

Modified: Catalyst-Action-Serialize-SimpleExcel/1.000/trunk/META.yml
===================================================================
--- Catalyst-Action-Serialize-SimpleExcel/1.000/trunk/META.yml	2008-11-12 17:30:33 UTC (rev 8596)
+++ Catalyst-Action-Serialize-SimpleExcel/1.000/trunk/META.yml	2008-11-12 21:18:45 UTC (rev 8597)
@@ -25,4 +25,4 @@
   parent: 0
 resources:
   license: http://dev.perl.org/licenses/
-version: 0.01_01
+version: 0.011

Modified: Catalyst-Action-Serialize-SimpleExcel/1.000/trunk/lib/Catalyst/Action/Serialize/SimpleExcel.pm
===================================================================
--- Catalyst-Action-Serialize-SimpleExcel/1.000/trunk/lib/Catalyst/Action/Serialize/SimpleExcel.pm	2008-11-12 17:30:33 UTC (rev 8596)
+++ Catalyst-Action-Serialize-SimpleExcel/1.000/trunk/lib/Catalyst/Action/Serialize/SimpleExcel.pm	2008-11-12 21:18:45 UTC (rev 8597)
@@ -4,7 +4,7 @@
 use warnings;
 no warnings 'uninitialized';
 use parent 'Catalyst::Action';
-use Spreadsheet::WriteExcel ();
+use Spreadsheet::WriteExcel;
 use Scalar::Util 'reftype';
 use namespace::clean;
 
@@ -14,11 +14,11 @@
 
 =head1 VERSION
 
-Version 0.01_01
+Version 0.011
 
 =cut
 
-our $VERSION = '0.01_01';
+our $VERSION = '0.011';
 
 =head1 SYNOPSIS
 
@@ -30,6 +30,7 @@
     package MyApp::Controller::REST;
 
     use parent 'Catalyst::Controller::REST';
+    use DBIx::Class::ResultClass::HashRefInflator ();
     use POSIX 'strftime';
 
     __PACKAGE__->config->{map}{'application/vnd.ms-excel'} = 'SimpleExcel';
@@ -43,9 +44,10 @@
             order_by => 'author,title'
         });
 
+        $rs->result_class('DBIx::Class::ResultClass::HashRefInflator');
+
         my @t = map {
-            my $row = $_;
-            [ map $row->$_, qw/author title/ ]
+            [ @{$_}{qw/author title/} ]
         } $rs->all;
 
         my $entity = {
@@ -72,13 +74,32 @@
     }
 
 Note, the content-type query param is required if you're just linking to the
-action. It tells C::C::REST what you're serializing the data as.
+action. It tells L<Catalyst::Controller::REST> what you're serializing the data
+as.
 
 =head1 DESCRIPTION
 
 Your entity should be either an array of arrays, or the more embellished format
-described in the L</SYNOPSIS>.
+described below and in the L</SYNOPSIS>.
 
+If entity is a hashref, keys should be:
+
+=head2 rows
+
+Required. The array of arrays of rows.
+
+=head2 header
+
+Optional, an array for the first line of the sheet, which will be in bold.
+
+=head2 column_widths
+
+Optional, the widths in characters of the columns.
+
+=head2 filename
+
+The name of the file before .xls. Defaults to "data".
+
 =cut
 
 sub execute {
@@ -136,7 +157,7 @@
     my $filename = $data->{filename} || 'data';
 
     $workbook->close;
-    $c->res->content_type('application/octet-stream');
+    $c->res->content_type('application/vnd.ms-excel');
     $c->res->header('Content-Disposition' =>
      "attachment; filename=${filename}.xls");
     $c->res->output($buf);
@@ -154,6 +175,12 @@
 the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Catalyst-Action-Serialize-SimpleExcel>.  I will be notified, and then you'll
 automatically be notified of progress on your bug as I make changes.
 
+=head1 SEE ALSO
+
+L<Catalyst>, L<Catalyst::Controller::REST>, L<Catalyst::Action::REST>,
+L<Catalyst::View::Excel::Template::Plus>, L<Spreadsheet::WriteExcel>,
+L<Spreadsheet::ParseExcel>
+
 =head1 TODO
 
 =over 4

Modified: Catalyst-Action-Serialize-SimpleExcel/1.000/trunk/t/excel.t
===================================================================
--- Catalyst-Action-Serialize-SimpleExcel/1.000/trunk/t/excel.t	2008-11-12 17:30:33 UTC (rev 8596)
+++ Catalyst-Action-Serialize-SimpleExcel/1.000/trunk/t/excel.t	2008-11-12 21:18:45 UTC (rev 8597)
@@ -25,7 +25,7 @@
 ok((my $resp = request '/rest/fancy?content-type=application%2Fvnd.ms-excel'),
     'received response');
 
-is($resp->header('Content-Type'), 'application/octet-stream', 'Content-Type');
+is($resp->header('Content-Type'), 'application/vnd.ms-excel', 'Content-Type');
 
 is($resp->header('Content-Disposition'), 'attachment; filename=mtfnpy.xls', 'Content-Disposition');
 




More information about the Catalyst-commits mailing list