[Jifty-commit] r3014 - in jifty/trunk: lib/Jifty
plugins/DumpDispatcher plugins/DumpDispatcher/doc
plugins/DumpDispatcher/lib plugins/DumpDispatcher/lib/Jifty
plugins/DumpDispatcher/lib/Jifty/Plugin
plugins/DumpDispatcher/lib/Jifty/Plugin/DumpDispatcher
plugins/DumpDispatcher/lib/Jifty/Plugin/DumpDispatcher/Model
plugins/DumpDispatcher/share plugins/DumpDispatcher/share/po
plugins/DumpDispatcher/share/web
plugins/DumpDispatcher/share/web/static
plugins/DumpDispatcher/share/web/templates plugins/DumpDispatcher/t
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Sat Mar 17 20:45:54 EDT 2007
Author: dpavlin
Date: Sat Mar 17 20:45:52 2007
New Revision: 3014
Added:
jifty/trunk/plugins/DumpDispatcher/
jifty/trunk/plugins/DumpDispatcher/Makefile.PL
jifty/trunk/plugins/DumpDispatcher/doc/
jifty/trunk/plugins/DumpDispatcher/lib/
jifty/trunk/plugins/DumpDispatcher/lib/Jifty/
jifty/trunk/plugins/DumpDispatcher/lib/Jifty/Plugin/
jifty/trunk/plugins/DumpDispatcher/lib/Jifty/Plugin/DumpDispatcher/
jifty/trunk/plugins/DumpDispatcher/lib/Jifty/Plugin/DumpDispatcher.pm
jifty/trunk/plugins/DumpDispatcher/lib/Jifty/Plugin/DumpDispatcher/Action/
jifty/trunk/plugins/DumpDispatcher/lib/Jifty/Plugin/DumpDispatcher/Dispatcher.pm
jifty/trunk/plugins/DumpDispatcher/lib/Jifty/Plugin/DumpDispatcher/Model/
jifty/trunk/plugins/DumpDispatcher/share/
jifty/trunk/plugins/DumpDispatcher/share/po/
jifty/trunk/plugins/DumpDispatcher/share/web/
jifty/trunk/plugins/DumpDispatcher/share/web/static/
jifty/trunk/plugins/DumpDispatcher/share/web/templates/
jifty/trunk/plugins/DumpDispatcher/t/
Modified:
jifty/trunk/lib/Jifty/Dispatcher.pm
jifty/trunk/lib/Jifty/Handler.pm
Log:
extracted dump_rules into DumpDispatcher plugin
Modified: jifty/trunk/lib/Jifty/Dispatcher.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Dispatcher.pm (original)
+++ jifty/trunk/lib/Jifty/Dispatcher.pm Sat Mar 17 20:45:52 2007
@@ -1261,56 +1261,4 @@
return @matches;
}
-=head2 dump_rules
-
-Dump all defined rules in debug log. It will be called by Jifty on startup.
-
-=cut
-
-sub dump_rules {
- my $self = shift;
-
- no strict 'refs';
- foreach my $stage ( qw/SETUP RUN CLEANUP/ ) {
-
- Jifty->log->debug( "Dispatcher rules in stage $stage:");
- foreach my $r ( @{ $self . '::RULES_' . $stage } ) {
- Jifty->log->debug( _unroll_dumpable_rules( 0,$r ) );
- }
-
- }
-};
-
-=head2 _unroll_dumpable_rules LEVEL,RULE
-
-Walk all rules defined in dispatcher starting at rule
-C<RULE> and indentation level C<LEVEL>
-
-=cut
-
-sub _unroll_dumpable_rules {
- my ($level, $rule) = @_;
- my $log =
- # indentation
- ( " " x $level ) .
- # op
- ( $rule->[0] || "undef op" ) . ' ' .
- # arguments
- (
- ! defined( $rule->[1] ) ? "" :
- ref $rule->[1] eq 'ARRAY' ? "'" . join("','", @{ $rule->[1] }) . "'" :
- ref $rule->[1] eq 'HASH' ? $rule->[1]->{method} . " '" . $rule->[1]->{""} ."'" :
- ref $rule->[1] eq 'CODE' ? '{...}' :
- "'" . $rule->[1] . "'"
- );
-
- if (ref $rule->[2] eq 'ARRAY') {
- $level++;
- foreach my $sr ( @{ $rule->[2] } ) {
- $log .= _unroll_dumpable_rules( $level, $sr );
- }
- }
- return $log;
-}
-
1;
Modified: jifty/trunk/lib/Jifty/Handler.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Handler.pm (original)
+++ jifty/trunk/lib/Jifty/Handler.pm Sat Mar 17 20:45:52 2007
@@ -66,8 +66,8 @@
$self->dispatcher( Jifty->app_class( "Dispatcher" ) );
Jifty::Util->require( $self->dispatcher );
$self->dispatcher->import_plugins;
- $self->dispatcher->dump_rules;
-
+ eval { Jifty::Plugin::DumpDispatcher->dump_rules };
+
$self->setup_view_handlers();
return $self;
}
Added: jifty/trunk/plugins/DumpDispatcher/Makefile.PL
==============================================================================
--- (empty file)
+++ jifty/trunk/plugins/DumpDispatcher/Makefile.PL Sat Mar 17 20:45:52 2007
@@ -0,0 +1,8 @@
+use inc::Module::Install;
+name('Jifty-Plugin-DumpDispatcher');
+version('0.01');
+requires('Jifty' => '0.70117');
+
+install_share;
+
+WriteAll;
Added: jifty/trunk/plugins/DumpDispatcher/lib/Jifty/Plugin/DumpDispatcher.pm
==============================================================================
--- (empty file)
+++ jifty/trunk/plugins/DumpDispatcher/lib/Jifty/Plugin/DumpDispatcher.pm Sat Mar 17 20:45:52 2007
@@ -0,0 +1,64 @@
+use strict;
+use warnings;
+
+package Jifty::Plugin::DumpDispatcher;
+use base qw/Jifty::Plugin/;
+
+# Your plugin goes here. If takes any configuration or arguments, you
+# probably want to override L<Jifty::Plugin/init>.
+
+=head2 dump_rules
+
+Dump all defined rules in debug log. It should be called by Jifty, after
+C<< Jifty->dispatcher->import_plugins >> on startup.
+
+=cut
+
+sub dump_rules {
+ my $self = shift;
+ #my %args = @_;
+
+ no strict 'refs';
+ foreach my $stage ( qw/SETUP RUN CLEANUP/ ) {
+
+ my $rules = Jifty->app_class( 'Dispatcher' ) . '::RULES_' . $stage;
+
+ Jifty->log->debug( "Dispatcher rules in stage $stage:");
+ Jifty->log->debug( _unroll_dumpable_rules( 0, $_ ) ) foreach @{ $rules }
+
+ }
+};
+
+=head2 _unroll_dumpable_rules LEVEL,RULE
+
+Walk all rules defined in dispatcher starting at rule
+C<RULE> and indentation level C<LEVEL>
+
+=cut
+
+sub _unroll_dumpable_rules {
+ my ($level, $rule) = @_;
+ my $log =
+ # indentation
+ ( " " x $level ) .
+ # op
+ ( $rule->[0] || "undef op" ) . ' ' .
+ # arguments
+ (
+ ! defined( $rule->[1] ) ? "" :
+ ref $rule->[1] eq 'ARRAY' ? "'" . join("','", @{ $rule->[1] }) . "'" :
+ ref $rule->[1] eq 'HASH' ? $rule->[1]->{method} . " '" . $rule->[1]->{""} ."'" :
+ ref $rule->[1] eq 'CODE' ? '{...}' :
+ "'" . $rule->[1] . "'"
+ );
+
+ if (ref $rule->[2] eq 'ARRAY') {
+ $level++;
+ foreach my $sr ( @{ $rule->[2] } ) {
+ $log .= _unroll_dumpable_rules( $level, $sr );
+ }
+ }
+ return $log;
+}
+
+1;
Added: jifty/trunk/plugins/DumpDispatcher/lib/Jifty/Plugin/DumpDispatcher/Dispatcher.pm
==============================================================================
--- (empty file)
+++ jifty/trunk/plugins/DumpDispatcher/lib/Jifty/Plugin/DumpDispatcher/Dispatcher.pm Sat Mar 17 20:45:52 2007
@@ -0,0 +1,9 @@
+use strict;
+use warnings;
+
+package Jifty::Plugin::DumpDispatcher::Dispatcher;
+use Jifty::Dispatcher -base;
+
+# Put any plugin-specific dispatcher rules here.
+
+1;
More information about the Jifty-commit
mailing list