Revision: 1222
Author: christian.wuerker
Date: Sat May 23 07:10:46 2015 UTC
Log: Updated doc tools.
https://code.google.com/p/cmclasses/source/detail?r=1222
Added:
/trunk/docs/packages/PackageGraphView.php
/trunk/docs/packages/index.php
/trunk/docs/test/index.php
Deleted:
/trunk/docs/packages/PackageGraphView.php5
/trunk/docs/packages/index.php5
/trunk/docs/test/index.php5
=======================================
--- /dev/null
+++ /trunk/docs/packages/PackageGraphView.php Sat May 23 07:10:46 2015 UTC
@@ -0,0 +1,162 @@
+<?php
+class PackageGraphView
+{
+ public $baseCss = '//
css.ceusmedia.com/';
+ public $baseJs = '//
js.ceusmedia.com/';
+ public $regExpFilename = '/^[A-Z].+\.php$/';
+ public $rexExpSignature = '/class [a-z]|interface [a-z] /i';
+ public $fileSerial = 'cache/files.serial';
+
+ public function __construct( $path )
+ {
+ $this->path = $path;
+ }
+
+ public function buildView( $refresh )
+ {
+ $clock = new Alg_Time_Clock();
+ $this->readData( $refresh );
+ $this->prepareData();
+
+ $view = new UI_Image_PieGraph( 600, 400 );
+ $page = new UI_HTML_PageFrame();
+ $page->addStyleSheet( $this->baseCss.'blueprint/reset.css' );
+ $page->addStyleSheet( $this->baseCss.'blueprint/typography.css' );
+ $page->addStyleSheet( $this->baseJs.'jquery/tabs/2.7.4/jquery.tabs.css'
);
+ $page->addJavaScript( $this->baseJs.'jquery/1.2.6.pack.js' );
+ $page->addJavaScript( $this->baseJs.'jquery/history/1.0.3.pack.js' );
+ $page->addJavaScript( $this->baseJs.'jquery/tabs/2.7.4.pack.js' );
+ $page->addJavaScript( 'script.js' );
+ $page->addStyleSheet( 'css/style.css' );
+ $page->addStyleSheet( 'css/tabs.office2.css' );
+ $page->addBody( '<h2>cmClasses Packages</h2>' );
+
+ $samples = $this->getPackages();
+
+ $data = array(
+ 'values' => array(),
+ 'uris' => array(),
+ 'legends' => array(),
+ 'labels' => array(),
+ 'total' => 0
+ );
+ foreach( $samples as $sampleName => $sampleData )
+ {
+ $data['values'][] = $sampleData['count'];
+ $data['legends'][] = $sampleData['label']." (".$sampleData['count'].")";
+ $data['uris'][] = "#".$sampleData['label'];
+ $data['labels'][] = $sampleData['label'];
+ $data['total'] += $sampleData['count'];
+ }
+ $view->setHeading( 'Packages by file count' );
+ @unlink( 'cache/PackageFileCount.png' );
+ $page->addBody( $view->build( "test1",
$data, 'cache/PackageFileCount.png' ) );
+
+
+
+ $data = array(
+ 'values' => array(),
+ 'uris' => array(),
+ 'legends' => array(),
+ 'labels' => array(),
+ 'total' => 0
+ );
+ foreach( $samples as $sampleName => $sampleData )
+ {
+ $data['values'][] = $sampleData['size'];
+ $data['legends'][] = $sampleData['label']."
(".Alg_UnitFormater::formatBytes( $sampleData['size'], 0, "", 1 ).")";
+ $data['uris'][] = "#".$sampleData['label'];
+ $data['labels'][] = $sampleData['label'];
+ $data['total'] += $sampleData['count'];
+ }
+ $view->setHeading( 'Packages by file size' );
+ @unlink( 'cache/PackageFileSize.png' );
+ $page->addBody( $view->build( "test2",
$data, 'cache/PackageFileSize.png' ) );
+ $page->addBody( '<div style="clear: both"></div>' );
+
+ $tabs = new UI_HTML_Tabs;
+ $tabs->setOption( 'fxAutoHeight', TRUE );
+ $tabs->setOption( 'initial', 0 );
+ $tabs->setOption( 'navClass', 'tabs-office2' );
+ foreach( $this->getPackages() as $package => $data )
+ {
+ $list = array();
+ foreach( $data['files'] as $fileName ){
+ $ext = pathinfo( $fileName, PATHINFO_EXTENSION );
+ $fileName = str_replace( '.', '_', $fileName );
+ $className = substr( $fileName, strlen( $package ) + 1 );
+ $className = substr( $className, 0, - strlen( $ext ) - 1 );
+ $fileName = $package.'/'.str_replace( '_', '/', $className ).'.'.$ext;
+# $list[] = '<a href="../../src/'.$fileName.'">'.$className.'</a>';
+ $list[] = $className;
+ }
+ $data = array(
+ 'label' => $package,
+ 'count' => $data['count'],
+ 'size' => Alg_UnitFormater::formatBytes( $data['size'] ),
+ 'list' => '<ul><li>'.join( '</li><li>', $list ).'</li></ul>',
+ );
+ $content = UI_Template::render( 'templates/package.html', $data );
+ $tabs->addTab( $package, $content, 'package_'.$package );
+ }
+ $html = $tabs->buildTabs( "tabs-packages" );
+ $script = $tabs->buildScript( "#tabs-packages" );
+ $page->addBody( $html );
+ $page->addHead( UI_HTML_Tag::create( 'script', $script ) );
+ $page->addBody( "<br/>".$clock->stop( 3, 0 )." ms" );
+ return $page->build();
+ }
+
+ protected function readData( $refresh = FALSE )
+ {
+ if( file_exists( $this->fileSerial ) && !$refresh )
+ return;
+ $files = array();
+ $index = new File_RecursiveRegexFilter( $this->path,
$this->regExpFilename, $this->rexExpSignature );
+ foreach( $index as $entry )
+ {
+ $pathName = substr( $entry->getPathname(), strlen( $this->path ) );
+ $files[$pathName] = filesize( $entry->getPathname() );
+ }
+ File_Editor::save( $this->fileSerial, serialize( $files ) );
+ }
+
+ protected function prepareData()
+ {
+ $this->map = new ADT_List_LevelMap();
+ $files = unserialize( File_Editor::load( $this->fileSerial ) );
+ foreach( $files as $pathName => $size )
+ {
+ if( !substr_count( $pathName, DIRECTORY_SEPARATOR ) )
+ continue;
+ $key = str_replace( DIRECTORY_SEPARATOR, ".", $pathName );
+ $this->map->set( $key, $size );
+ }
+ }
+
+ protected function getPackages( $key = NULL )
+ {
+ $packages = array();
+ $list = $key ? $this->map->get( $key ) : $this->map->getAll();
+ foreach( $list as $pathName => $size )
+ {
+ if( !preg_match( '/^[a-z]+/i', $pathName ) )
+ continue;
+ $package = array_shift( explode( ".", $pathName ) );
+ if( !isset( $packages[$package] ) )
+ $packages[$package] = array(
+ 'label' => $package,
+ 'count' => 0,
+ 'size' => 0
+ );
+ else
+ {
+ $packages[$package]['count'] ++;
+ $packages[$package]['size'] += $size;
+ $packages[$package]['files'][] = $pathName;
+ }
+ }
+ return $packages;
+ }
+}
+?>
=======================================
--- /dev/null
+++ /trunk/docs/packages/index.php Sat May 23 07:10:46 2015 UTC
@@ -0,0 +1,18 @@
+<?php
+require_once( "../../autoload.php" );
+
+$pathJpgraph = 'jpgraph/3.0.7/src/';
+$pathClasses = '../../src/';
+$refresh = isset( $_GET['refresh'] );
+
+define( 'JPGRAPH_PATH', $pathJpgraph );
+require_once( JPGRAPH_PATH.'jpgraph.php' );
+require_once( JPGRAPH_PATH.'jpgraph_pie.php');
+require_once( JPGRAPH_PATH.'jpgraph_pie3d.php' );
+
+require_once 'PackageGraphView.php';
+$graph = new PackageGraphView( $pathClasses );
+#$graph->baseCss = '//localhost/ceusmedia/css/';
+#$graph->baseJs = '//localhost/ceusmedia/js/';
+print( $graph->buildView( $refresh ) );
+?>
=======================================
--- /dev/null
+++ /trunk/docs/test/index.php Sat May 23 07:10:46 2015 UTC
@@ -0,0 +1,72 @@
+<?php
+class UnitTestViewer
+{
+ public function __construct( $fileName )
+ {
+ if( !file_exists( $fileName ) )
+ die( "no test results available - run unit tests first" );
+ $reader = new XML_UnitTestResultReader( $fileName );
+ $date = date( "d.m.Y H:i:s", $reader->getDate() );
+ $time = Alg_UnitFormater::formatSeconds( $reader->getTime(), 1 );
+ $countSuites = $reader->getTestSuiteCount();
+ $countCases = $reader->getTestCaseCount();
+ $countTests = $reader->getTestCount();
+ $countFailures = $reader->getFailureCount();
+ $countErrors = $reader->getErrorCount();
+ $countPassed = $countTests - $countFailures - $countErrors;
+ $ratioFailures = round( $countFailures / $countTests * 100, 1 );
+ $ratioErrors = round( $countErrors / $countTests * 100, 1 );
+ $ratioPassed = round( $countPassed / $countTests * 100, 1 );
+ $failures = $countFailures ? $this->buildList(
$reader->getFailures(), 'failure' ) : "none";
+ $errors = $countErrors ? $this->buildList(
$reader->getErrors(), 'failure' ) : "none";
+ echo require_once( "template.phpt" );
+ }
+
+ protected function buildList( $tests, $type )
+ {
+ $list = array();
+ foreach( $tests as $test )
+ {
+ $lines = array();
+ foreach( explode( "\n", $test['error'] ) as $line )
+ {
+ $class = NULL;
+ $first = substr( $line, 0, 1 );
+ if( $first == "+" )
+ $class = 'positive';
+ else if( $first == "-" )
+ $class = 'negative';
+ $lines[] = UI_HTML_Elements::ListItem( $line, 0, array( 'class' =>
$class ) );
+ }
+ $message = UI_HTML_Elements::unorderedList( $lines, 0, array( 'class'
=> 'message' ) );
+
+ $testSuite = $test['suite'];
+ $testCase = $test['case'];
+ $hash = md5( $testSuite.":".$testCase );
+ $id = $type.$hash;
+ $heading = '<b>'.$testSuite.'</b> :: <em>'.$testCase.'</em>';
+ $heading = UI_HTML_Tag::create(
+ 'div',
+ $heading,
+ array(
+ 'class' => 'heading',
+ 'id' => $hash,
+ 'onclick' => "$('#".$type.$hash."').toggle();"
+ )
+ );
+ $content = UI_HTML_Tag::create(
+ 'div',
+ $message,
+ array(
+ 'class' => 'message',
+ 'id' => $type.$hash
+ )
+ );
+ $list[] = $heading."\n".$content;
+ }
+ return implode( "\n", $list );
+ }
+}
+require_once '../../autoload.php';
+new UnitTestViewer( '../../Test/results.xml' );
+?>
=======================================
--- /trunk/docs/packages/PackageGraphView.php5 Wed May 30 02:35:42 2012 UTC
+++ /dev/null
@@ -1,163 +0,0 @@
-<?php
-class PackageGraphView
-{
- public $baseCss = '//
css.ceusmedia.com/';
- public $baseJs = '//
js.ceusmedia.com/';
- public $regExpFilename = '/^[A-Z].+\.php5$/';
- public $rexExpSignature = '/class [a-z]|interface [a-z] /i';
- public $fileSerial = 'cache/files.serial';
-
- public function __construct( $path )
- {
- $this->path = $path;
- }
-
- public function buildView( $refresh )
- {
- $clock = new Alg_Time_Clock();
- $this->readData( $refresh );
- $this->prepareData();
-
- $view = new UI_Image_PieGraph( 600, 400 );
- $page = new UI_HTML_PageFrame();
- $page->addStyleSheet( $this->baseCss.'blueprint/reset.css' );
- $page->addStyleSheet( $this->baseCss.'blueprint/typography.css' );
- $page->addStyleSheet( $this->baseJs.'jquery/tabs/2.7.4/jquery.tabs.css'
);
- $page->addJavaScript( $this->baseJs.'jquery/1.2.6.pack.js' );
- $page->addJavaScript( $this->baseJs.'jquery/history/1.0.3.pack.js' );
- $page->addJavaScript( $this->baseJs.'jquery/tabs/2.7.4.pack.js' );
- $page->addJavaScript( 'script.js' );
- $page->addStyleSheet( 'css/style.css' );
- $page->addStyleSheet( 'css/tabs.office2.css' );
- $page->addBody( '<h2>cmClasses Packages</h2>' );
-
- $samples = $this->getPackages();
-
- $data = array(
- 'values' => array(),
- 'uris' => array(),
- 'legends' => array(),
- 'labels' => array(),
- 'total' => 0
- );
- foreach( $samples as $sampleName => $sampleData )
- {
- $data['values'][] = $sampleData['count'];
- $data['legends'][] = $sampleData['label']." (".$sampleData['count'].")";
- $data['uris'][] = "#".$sampleData['label'];
- $data['labels'][] = $sampleData['label'];
- $data['total'] += $sampleData['count'];
- }
- $view->setHeading( 'Packages by file count' );
- @unlink( 'cache/PackageFileCount.png' );
- $page->addBody( $view->build( "test1",
$data, 'cache/PackageFileCount.png' ) );
-
-
-
- $data = array(
- 'values' => array(),
- 'uris' => array(),
- 'legends' => array(),
- 'labels' => array(),
- 'total' => 0
- );
- foreach( $samples as $sampleName => $sampleData )
- {
- $data['values'][] = $sampleData['size'];
- $data['legends'][] = $sampleData['label']."
(".Alg_UnitFormater::formatBytes( $sampleData['size'], 0, "", 1 ).")";
- $data['uris'][] = "#".$sampleData['label'];
- $data['labels'][] = $sampleData['label'];
- $data['total'] += $sampleData['count'];
- }
- $view->setHeading( 'Packages by file size' );
- @unlink( 'cache/PackageFileSize.png' );
- $page->addBody( $view->build( "test2",
$data, 'cache/PackageFileSize.png' ) );
- $page->addBody( '<div style="clear: both"></div>' );
-
- $tabs = new UI_HTML_Tabs;
- $tabs->setOption( 'fxAutoHeight', TRUE );
- $tabs->setOption( 'initial', 0 );
- $tabs->setOption( 'navClass', 'tabs-office2' );
- foreach( $this->getPackages() as $package => $data )
- {
- $list = array();
- foreach( $data['files'] as $fileName ){
- $ext = pathinfo( $fileName, PATHINFO_EXTENSION );
- $fileName = str_replace( '.', '_', $fileName );
- $className = substr( $fileName, strlen( $package ) + 1 );
- $className = substr( $className, 0, - strlen( $ext ) - 1 );
- $fileName = $package.'/'.str_replace( '_', '/', $className ).'.'.$ext;
-# $list[] = '<a href="../../src/'.$fileName.'">'.$className.'</a>';
- $list[] = $className;
- }
- $data = array(
- 'label' => $package,
- 'count' => $data['count'],
- 'size' => Alg_UnitFormater::formatBytes( $data['size'] ),
- 'list' => '<ul><li>'.join( '</li><li>', $list ).'</li></ul>',
- );
- $content = UI_Template::render( 'templates/package.html', $data );
- $tabs->addTab( $package, $content, 'package_'.$package );
- }
- $html = $tabs->buildTabs( "tabs-packages" );
- $script = $tabs->buildScript( "#tabs-packages" );
- $page->addBody( $html );
- $page->addHead( UI_HTML_Tag::create( 'script', $script ) );
- $page->addBody( "<br/>".$clock->stop( 3, 0 )." ms" );
- return $page->build();
- }
-
- protected function readData( $refresh = FALSE )
- {
- if( file_exists( $this->fileSerial ) && !$refresh )
- return;
- $files = array();
- $index = new File_RecursiveRegexFilter( $this->path,
$this->regExpFilename, $this->rexExpSignature );
- foreach( $index as $entry )
- {
-
- $pathName = substr( $entry->getPathname(), strlen( $this->path ) );
- $files[$pathName] = filesize( $entry->getPathname() );
- }
- File_Editor::save( $this->fileSerial, serialize( $files ) );
- }
-
- protected function prepareData()
- {
- $this->map = new ADT_List_LevelMap();
- $files = unserialize( File_Editor::load( $this->fileSerial ) );
- foreach( $files as $pathName => $size )
- {
- if( !substr_count( $pathName, DIRECTORY_SEPARATOR ) )
- continue;
- $key = str_replace( DIRECTORY_SEPARATOR, ".", $pathName );
- $this->map->set( $key, $size );
- }
- }
-
- protected function getPackages( $key = NULL )
- {
- $packages = array();
- $list = $key ? $this->map->get( $key ) : $this->map->getAll();
- foreach( $list as $pathName => $size )
- {
- if( !preg_match( '/^[a-z]+/i', $pathName ) )
- continue;
- $package = array_shift( explode( ".", $pathName ) );
- if( !isset( $packages[$package] ) )
- $packages[$package] = array(
- 'label' => $package,
- 'count' => 0,
- 'size' => 0
- );
- else
- {
- $packages[$package]['count'] ++;
- $packages[$package]['size'] += $size;
- $packages[$package]['files'][] = $pathName;
- }
- }
- return $packages;
- }
-}
-?>
=======================================
--- /trunk/docs/packages/index.php5 Wed May 30 02:35:42 2012 UTC
+++ /dev/null
@@ -1,18 +0,0 @@
-<?php
-require_once( "../../autoload.php5" );
-
-$pathJpgraph = 'jpgraph/3.0.7/src/';
-$pathClasses = '../../src/';
-$refresh = isset( $_GET['refresh'] );
-
-define( 'JPGRAPH_PATH', $pathJpgraph );
-require_once( JPGRAPH_PATH.'jpgraph.php' );
-require_once( JPGRAPH_PATH.'jpgraph_pie.php');
-require_once( JPGRAPH_PATH.'jpgraph_pie3d.php' );
-
-require_once 'PackageGraphView.php5';
-$graph = new PackageGraphView( $pathClasses );
-#$graph->baseCss = '//localhost/ceusmedia/css/';
-#$graph->baseJs = '//localhost/ceusmedia/js/';
-print( $graph->buildView( $refresh ) );
-?>
=======================================
--- /trunk/docs/test/index.php5 Sat Oct 30 00:11:58 2010 UTC
+++ /dev/null
@@ -1,72 +0,0 @@
-<?php
-class UnitTestViewer
-{
- public function __construct( $fileName )
- {
- if( !file_exists( $fileName ) )
- die( "no test results available - run unit tests first" );
- $reader = new XML_UnitTestResultReader( $fileName );
- $date = date( "d.m.Y H:i:s", $reader->getDate() );
- $time = Alg_UnitFormater::formatSeconds( $reader->getTime(), 1 );
- $countSuites = $reader->getTestSuiteCount();
- $countCases = $reader->getTestCaseCount();
- $countTests = $reader->getTestCount();
- $countFailures = $reader->getFailureCount();
- $countErrors = $reader->getErrorCount();
- $countPassed = $countTests - $countFailures - $countErrors;
- $ratioFailures = round( $countFailures / $countTests * 100, 1 );
- $ratioErrors = round( $countErrors / $countTests * 100, 1 );
- $ratioPassed = round( $countPassed / $countTests * 100, 1 );
- $failures = $countFailures ? $this->buildList(
$reader->getFailures(), 'failure' ) : "none";
- $errors = $countErrors ? $this->buildList(
$reader->getErrors(), 'failure' ) : "none";
- echo require_once( "template.phpt" );
- }
-
- protected function buildList( $tests, $type )
- {
- $list = array();
- foreach( $tests as $test )
- {
- $lines = array();
- foreach( explode( "\n", $test['error'] ) as $line )
- {
- $class = NULL;
- $first = substr( $line, 0, 1 );
- if( $first == "+" )
- $class = 'positive';
- else if( $first == "-" )
- $class = 'negative';
- $lines[] = UI_HTML_Elements::ListItem( $line, 0, array( 'class' =>
$class ) );
- }
- $message = UI_HTML_Elements::unorderedList( $lines, 0, array( 'class'
=> 'message' ) );
-
- $testSuite = $test['suite'];
- $testCase = $test['case'];
- $hash = md5( $testSuite.":".$testCase );
- $id = $type.$hash;
- $heading = '<b>'.$testSuite.'</b> :: <em>'.$testCase.'</em>';
- $heading = UI_HTML_Tag::create(
- 'div',
- $heading,
- array(
- 'class' => 'heading',
- 'id' => $hash,
- 'onclick' => "$('#".$type.$hash."').toggle();"
- )
- );
- $content = UI_HTML_Tag::create(
- 'div',
- $message,
- array(
- 'class' => 'message',
- 'id' => $type.$hash
- )
- );
- $list[] = $heading."\n".$content;
- }
- return implode( "\n", $list );
- }
-}
-require_once '../../autoload.php5';
-new UnitTestViewer( '../../Test/results.xml' );
-?>