factor dispatch parser out
[catagits/Web-Simple.git] / lib / Web / Simple / Application.pm
index d52dc78..4021170 100644 (file)
@@ -72,7 +72,10 @@ sub BUILDALL {
   my @targ;
   while ($targ->isa(__PACKAGE__) and $targ ne __PACKAGE__) {
     push(@targ, "${targ}::BUILD")
-      if do { no strict 'refs'; defined *{"${targ}::BUILD"}{CODE} };
+      if do {
+           no strict 'refs'; no warnings 'once';
+           defined *{"${targ}::BUILD"}{CODE}
+         };
     my @targ_isa = do { no strict 'refs'; @{"${targ}::ISA"} };
     die "${targ} uses Multiple Inheritance: ISA is: ".join ', ', @targ_isa
       if @targ_isa > 1;
@@ -127,8 +130,8 @@ sub _construct_redispatch {
 }
 
 sub _build_dispatch_parser {
-  require Web::Simple::DispatchParser;
-  return Web::Simple::DispatchParser->new;
+  require Web::Dispatch::Parser;
+  return Web::Dispatch::Parser->new;
 }
 
 sub _cannot_call_twice {
@@ -190,7 +193,7 @@ sub _build_dispatcher_from_spec {
   my $parser = $class->_build_dispatch_parser;
   my $matcher = (
     defined($proto) && length($proto)
-      ? $parser->parse_dispatch_specification($proto)
+      ? $parser->parse($proto)
       : sub { ({}, $_[1]) }
   );
   return $class->_build_dispatcher({
@@ -272,7 +275,7 @@ sub run {
     return $self->_run_cgi;
   }
   unless (@ARGV && $ARGV[0] =~ m{^/}) {
-    return $self->_run_cli;
+    return $self->_run_cli(@ARGV);
   }
 
   my $path = shift @ARGV;