Permalink
Browse files

rule dumper scripts

  • Loading branch information...
1 parent 93e4fdc commit 89a36ea57668164583b07612ae089943d4c975aa @c9s committed Feb 24, 2012
Showing with 11 additions and 27 deletions.
  1. +10 −0 scripts/dump_rules.php
  2. +0 −26 src/Roller/Dumper/PhpDumper.php
  3. +1 −1 tests/Roller/RouterTest.php
@@ -0,0 +1,10 @@
+<?php
+require 'tests/bootstrap.php';
+
+$routes = new Roller\RouteSet;
+$routes->add( '/blog/:year/:month' , function($year,$month) { return 'Yes'; },array( 'year' => '\d+' ));
+$routes->add( '/blog/:id' , function($id) { return $id; },array( 'id' => '\d+' ));
+$routes->compile();
+
+$dumper = new Roller\Dumper\ConsoleDumper;
+$dumper->dump( $routes );
@@ -3,32 +3,6 @@
use ReflectionFunction;
use SplFileObject;
-class ClosureSerializer
-{
-
- /**
- * serialize closure
- *
- * @param Closure
- */
- static function serialize($closure)
- {
- $ref = new ReflectionFunction($closure);
- $file = new SplFileObject($ref->getFileName());
- $file->seek($ref->getStartLine()-1);
- $code = '';
- while ($file->key() < $ref->getEndLine())
- {
- $code .= $file->current();
- $file->next();
- }
- $start = strpos($code, 'function');
- $end = strrpos($code, '}') + 1;
- return substr($code, $start, $end - $start);
- }
-}
-
-
/**
* solution for var_export
*/
@@ -34,7 +34,7 @@ function test()
ok( $r !== false );
ok( $r );
$content = $r();
- is('Hello 2012', $content , 'default value' );
+ is('Hello 2012', $content , 'default value should work' );
$r = $router->dispatch('/path/to/another');
ok( $r === false , 'route not found.' );

0 comments on commit 89a36ea

Please sign in to comment.