[Catalyst] Version Numbers (not a patch)

Sebastian Riedel sri at oook.de
Thu Dec 15 02:38:45 CET 2005


14.12.2005 21:55 Ovid:
> My boss and I were struggling to figure out why my Catalyst app wasn't
> working on his box and with some help from #catalyst, we finally
> figured out that his version of Catalyst::View::TT (0.20) was broken.
>
> To make it easier to debug, I had the following code in
> Catalyst::setup() after the "Loaded components" section:
>
>   my @comp =
>       map  { $_ . ' ' . ($_->VERSION || '') }
>       grep { /^Catalyst/ && ! /^Catalyst::Plugin/ }
>       map  { s{/}{::}g; s/\.pm$//; $_ }
>         sort keys %INC;
>
>   if (@comp) {
>       my $t = Text::SimpleTable->new(76);
>       $t->row($_) for @comp;
>       $class->log->debug(
>         "Loaded core components:\n"
>         . $t->draw
>       );
>   }
>
> Personally, I find this code really ugly and digging through %INC  
> seems
> like the wrong way to go.  castaway pointed me to the comp() method,
> but I wasn't quite sure when it was available.  On the plus side, this
> code does dump out the core components and their (usually non- 
> existent)
> version numbers.
>
> So I have two questions:
>
> 1.  Is this code rubbish?

It's a bit too verbose for everyday use, but why not put it in a plugin.

> 2.  Where would I put tests for this code?  I'm having
>     trouble finding them.

We don't test those ascii tables, just the data they provide.
Have a look at the loaded components tests.

t/lib/Catalyst/Plugin/Test/Headers.pm
t/lib/TestApp/Controller/Action/Auto.pm
t/live_component_controller_action_auto.t


--
sebastian




More information about the Catalyst mailing list