From 16ec6a1fcba2a43ddf54e14755676e7752e3db1e Mon Sep 17 00:00:00 2001 From: franck cuny Date: Thu, 10 Jun 2010 14:30:44 +0200 Subject: add nogetpopt; fix package; remove universal --- lib/CatalystX/Dispatcher/AsGraph.pm | 63 +++++++++++++++++++++---------------- 1 file changed, 36 insertions(+), 27 deletions(-) (limited to 'lib/CatalystX/Dispatcher/AsGraph.pm') diff --git a/lib/CatalystX/Dispatcher/AsGraph.pm b/lib/CatalystX/Dispatcher/AsGraph.pm index 9f6bfd5..1a1baf2 100644 --- a/lib/CatalystX/Dispatcher/AsGraph.pm +++ b/lib/CatalystX/Dispatcher/AsGraph.pm @@ -1,21 +1,39 @@ +package CatalystX::Dispatcher::AsGraph; + +# ABSTRACT: Create a graph from Catalyst dispatcher + use MooseX::Declare; -use Graph::Easy; -use UNIVERSAL::require; -our $VERSION = '0.02'; +our $VERSION = '0.03'; class CatalystX::Dispatcher::AsGraph { + use Graph::Easy; with 'MooseX::Getopt'; - has [qw/appname output/] => ( is => 'ro', isa => 'Str', required => 1 ); - has 'graph' => ( is => 'ro', default => sub { Graph::Easy->new } ); + has [qw/appname output/] => (is => 'ro', isa => 'Str', required => 1); + + has graph => ( + traits => ['NoGetopt'], + is => 'ro', + default => sub { Graph::Easy->new } + ); + has app => ( + traits => ['NoGetopt'], + is => 'rw', + isa => 'Object', + lazy => 1, + handles => [qw/dispatcher/], + default => sub { + my $self = shift; + Class::MOP::load_class($self->appname); + my $app = $self->appname->new; + $app; + } + ); method run{ - my $class = $self->appname; - $class->require or die $@; - my $app = $class->new; - my $routes = $app->dispatcher->_tree; + my $routes = $self->dispatcher->_tree; $self->_new_node($routes, ''); } @@ -36,33 +54,24 @@ class CatalystX::Dispatcher::AsGraph { } } - -__END__ - -=head1 NAME - -CatalystX::Dispatcher::AsGraph - Create a graph from Catalyst dispatcher +1; =head1 SYNOPSIS use CatalystX::Dispatcher::AsGraph; - my $graph = CatalystX::Dispatcher::AsGraph->new_with_options(); - $graph->graph; + + my $graph = CatalystX::Dispatcher::AsGraph->new( + appname => 'MyApp', + output => 'myactions.png', + ); + $graph->run; =head1 DESCRIPTION -CatalystX::Dispatcher::AsGraph create a graph for a Catalyst application -using his dispatcher. +CatalystX::Dispatcher::AsGraph create a graph for a Catalyst application using his dispatcher. At the time, only private actions are graphed. -=head1 AUTHOR - -Franck Cuny Efranck@lumberjaph.netE - =head1 SEE ALSO -=head1 LICENSE - -This library is free software; you can redistribute it and/or modify -it under the same terms as Perl itself. +L -- cgit 1.4.1