summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Changes7
-rw-r--r--lib/CatalystX/Dispatcher/AsGraph.pm63
2 files changed, 42 insertions, 28 deletions
diff --git a/Changes b/Changes
index 32171e1..056cd89 100644
--- a/Changes
+++ b/Changes
@@ -1,6 +1,11 @@
Revision history for Perl extension CatalystX::Dispatcher::AsGraph
-0.02 Wed Jun 3
+0.03 Thu June 10 2010
+ - add 'package'
+ - nogetopt trait for graph attribute
+ - remove universal to use Class::MOP
+
+0.02 Wed Jun 3
- fix makefile
0.01 Sat May 30 10:36:31 2009
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 E<lt>franck@lumberjaph.netE<gt>
-
=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<http://www.catalystframework.org/calendar/2009/14>