forked from bd808/graphite-graph-php
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rearranged src. Added PPW build scripts.
- Loading branch information
Showing
9 changed files
with
230 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
build/api | ||
build/code-browser | ||
build/coverage | ||
build/logs | ||
build/pdepend | ||
phpunit.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- Generated by PHP Project Wizard (PPW) 1.0.4 on Tue Oct 11 23:20:43 MDT 2011 --> | ||
|
||
<project name="graphite-graph" default="build" basedir="."> | ||
<property name="source" value="src"/> | ||
|
||
<target name="clean" description="Clean up and create artifact directories"> | ||
<delete dir="${basedir}/build/api"/> | ||
<delete dir="${basedir}/build/code-browser"/> | ||
<delete dir="${basedir}/build/coverage"/> | ||
<delete dir="${basedir}/build/logs"/> | ||
<delete dir="${basedir}/build/pdepend"/> | ||
|
||
<mkdir dir="${basedir}/build/api"/> | ||
<mkdir dir="${basedir}/build/code-browser"/> | ||
<mkdir dir="${basedir}/build/coverage"/> | ||
<mkdir dir="${basedir}/build/logs"/> | ||
<mkdir dir="${basedir}/build/pdepend"/> | ||
</target> | ||
|
||
<target name="phpunit" description="Run unit tests using PHPUnit and generates junit.xml and clover.xml"> | ||
<exec executable="phpunit" failonerror="true"/> | ||
</target> | ||
|
||
<target name="parallelTasks" description="Run the pdepend, phpmd, phpcpd, phpcs, phpdoc and phploc tasks in parallel using a maximum of 2 threads."> | ||
<parallel threadCount="2"> | ||
<sequential> | ||
<antcall target="pdepend"/> | ||
<antcall target="phpmd"/> | ||
</sequential> | ||
<antcall target="phpcpd"/> | ||
<antcall target="phpcs"/> | ||
<antcall target="phpdoc"/> | ||
<antcall target="phploc"/> | ||
</parallel> | ||
</target> | ||
|
||
<target name="pdepend" description="Generate jdepend.xml and software metrics charts using PHP_Depend"> | ||
<exec executable="pdepend"> | ||
<arg line="--jdepend-xml=${basedir}/build/logs/jdepend.xml | ||
--jdepend-chart=${basedir}/build/pdepend/dependencies.svg | ||
--overview-pyramid=${basedir}/build/pdepend/overview-pyramid.svg | ||
${source}" /> | ||
</exec> | ||
</target> | ||
|
||
<target name="phpmd" description="Generate pmd.xml using PHPMD"> | ||
<exec executable="phpmd"> | ||
<arg line="${source} | ||
xml | ||
codesize,design,naming,unusedcode | ||
--reportfile ${basedir}/build/logs/pmd.xml" /> | ||
</exec> | ||
</target> | ||
|
||
<target name="phpcpd" description="Generate pmd-cpd.xml using PHPCPD"> | ||
<exec executable="phpcpd"> | ||
<arg line="--log-pmd ${basedir}/build/logs/pmd-cpd.xml ${source}" /> | ||
</exec> | ||
</target> | ||
|
||
<target name="phploc" description="Generate phploc.csv"> | ||
<exec executable="phploc"> | ||
<arg line="--log-csv ${basedir}/build/logs/phploc.csv ${source}" /> | ||
</exec> | ||
</target> | ||
|
||
<target name="phpcs" description="Generate checkstyle.xml using PHP_CodeSniffer"> | ||
<exec executable="phpcs" output="/dev/null"> | ||
<arg line="--report=checkstyle | ||
--report-file=${basedir}/build/logs/checkstyle.xml | ||
--standard=PEAR | ||
${source}" /> | ||
</exec> | ||
</target> | ||
|
||
<target name="phpdoc" description="Generate API documentation using PHPDocumentor"> | ||
<exec executable="phpdoc"> | ||
<arg line="-d ${source} -t ${basedir}/build/api" /> | ||
</exec> | ||
</target> | ||
|
||
<target name="phpcb" description="Aggregate tool output with PHP_CodeBrowser"> | ||
<exec executable="phpcb"> | ||
<arg line="--log ${basedir}/build/logs | ||
--source ${source} | ||
--output ${basedir}/build/code-browser" /> | ||
</exec> | ||
</target> | ||
|
||
<target name="build" depends="clean,parallelTasks,phpunit,phpcb"/> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
<?php | ||
require_once 'GraphiteGraph.php'; | ||
require_once dirname(__FILE__) . '/../src/autoload.php'; | ||
|
||
$g = new GraphiteGraph('cpu_irq.ini', | ||
$g = new Graphite_GraphBuilder('cpu_irq.ini', | ||
array('width' => 800, 'height' => 400), | ||
array( 'hostname' => 'com.example.foo')); | ||
echo $g->url, "\n"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- Generated by PHP Project Wizard (PPW) 1.0.4 on Tue Oct 11 23:20:43 MDT 2011 --> | ||
|
||
<phpunit bootstrap="src/autoload.php" | ||
backupGlobals="false" | ||
backupStaticAttributes="false" | ||
strict="true" | ||
verbose="true"> | ||
<testsuites> | ||
<testsuite name="graphite-graph"> | ||
<directory suffix="Test.php">tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
|
||
<logging> | ||
<log type="coverage-html" target="build/coverage" title="graphite-graph" | ||
charset="UTF-8" yui="true" highlight="true" | ||
lowUpperBound="35" highLowerBound="70"/> | ||
<log type="coverage-clover" target="build/logs/clover.xml"/> | ||
<log type="junit" target="build/logs/junit.xml" logIncompleteSkipped="false"/> | ||
</logging> | ||
|
||
<filter> | ||
<whitelist addUncoveredFilesFromWhitelist="true"> | ||
<directory suffix=".php">src</directory> | ||
<exclude> | ||
<file>src/autoload.php</file> | ||
</exclude> | ||
</whitelist> | ||
</filter> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,18 +24,21 @@ | |
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
* POSSIBILITY OF SUCH DAMAGE. | ||
* | ||
* @package Graphite | ||
*/ | ||
|
||
|
||
/** | ||
* DSL for creating graph desciptions for <a | ||
* href="http://graphite.wikidot.com/">Graphite</a>. | ||
* | ||
* @package Graphite | ||
* @author Bryan Davis <[email protected]> | ||
* @version SVN: $Id: skeleton.php 81 2007-07-11 15:04:33Z bpd $ | ||
* @copyright 2011 Bryan Davis and contributors. All Rights Reserved. | ||
*/ | ||
class GraphiteGraph { | ||
class Graphite_GraphBuilder { | ||
|
||
/** | ||
* Properties for graph. | ||
|
@@ -88,7 +91,7 @@ public function __construct ($file=null, $overrides=array(), $info=array()) { | |
* Start a service block. | ||
* @param string $service Name of service | ||
* @param string $data Data collection of interest | ||
* @return GraphiteGraph Self, for message chaining | ||
* @return Graphite_GraphBuilder Self, for message chaining | ||
*/ | ||
public function service ($service, $data) { | ||
if (!isset($this->info['hostname'])) { | ||
|
@@ -101,7 +104,7 @@ public function service ($service, $data) { | |
|
||
/** | ||
* End service block. | ||
* @return GraphiteGraph Self, for message chaining | ||
* @return Graphite_GraphBuilder Self, for message chaining | ||
*/ | ||
public function endService () { | ||
$this->service = null; | ||
|
@@ -113,7 +116,7 @@ public function endService () { | |
* Add a data series to the graph. | ||
* @param string $name Name of data field to graph | ||
* @param array $opts Series options | ||
* @return GraphiteGraph Self, for message chaining | ||
* @return Graphite_GraphBuilder Self, for message chaining | ||
*/ | ||
public function field ($name, $opts) { | ||
if (isset($this->series[$name])) { | ||
|
@@ -248,16 +251,16 @@ protected function load ($file) { | |
$services = array(); | ||
foreach ($ini as $name => $data) { | ||
// look for services first | ||
if (isset($data['is_service'])) { | ||
if (isset($data[':is_service'])) { | ||
$services[$name] = $data; | ||
continue; | ||
} | ||
|
||
// it must be a field | ||
if (isset($data['use_service'])) { | ||
$svcData = $services[$data['use_service']]; | ||
if (isset($data[':use_service'])) { | ||
$svcData = $services[$data[':use_service']]; | ||
$svcName = (isset($svcData['service']))? | ||
$svcData['service']: $data['use_service']; | ||
$svcData['service']: $data[':use_service']; | ||
|
||
$this->service($svcName, $svcData['data']); | ||
} | ||
|
@@ -271,4 +274,4 @@ protected function load ($file) { | |
} //end load | ||
|
||
|
||
} //end GraphiteGraph | ||
} //end Graphite_GraphBuilder |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
/** | ||
* Copyright (c) 2011, Bryan Davis and contributors | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions are met: | ||
* | ||
* a. Redistributions of source code must retain the above copyright notice, | ||
* this list of conditions and the following disclaimer. | ||
* | ||
* b. Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in the | ||
* documentation and/or other materials provided with the distribution. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | ||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
* POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
|
||
/** | ||
* Simple autoloader that converts underscore and backslash to directories. | ||
* @param string $class Class to load | ||
* @return void | ||
*/ | ||
function graphite_graph_autoload ($class) { | ||
require dirname(__FILE__) . '/' . strtr($class, '_\\', '//') . '.php'; | ||
} | ||
|
||
spl_autoload_register('graphite_graph_autoload'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
/** | ||
* Copyright (c) 2011, Bryan Davis and contributors | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions are met: | ||
* | ||
* a. Redistributions of source code must retain the above copyright notice, | ||
* this list of conditions and the following disclaimer. | ||
* | ||
* b. Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in the | ||
* documentation and/or other materials provided with the distribution. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | ||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
* POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
|
||
/** | ||
* @author Bryan Davis <[email protected]> | ||
* @version SVN: $Id: skeleton.php 81 2007-07-11 15:04:33Z bpd $ | ||
* @copyright 2011 Bryan Davis and contributors. All Rights Reserved. | ||
*/ | ||
class Graphite_GraphBuilderTest extends PHPUnit_Framework_TestCase { | ||
|
||
public function testNothing () { | ||
$this->assertTrue(true); | ||
} | ||
|
||
} //end Graphite_GraphBuilderTest |