Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Initial commit

  • Loading branch information...
commit 56360c8c2eb8ef6a9b7cf7ef56895d6bdfcc7557 0 parents
@stuartherbert stuartherbert authored
6 .gitignore
@@ -0,0 +1,6 @@
+.build
+dist
+.tmp
+nbproject
+review
+vendor
8 .hgignore
@@ -0,0 +1,8 @@
+syntax: glob
+
+.build
+.dist
+nbproject
+review
+tmp
+vendor
29 LICENSE.txt
@@ -0,0 +1,29 @@
+New BSD License
+===============
+
+Copyright (c) 2010, Gradwell dot com Ltd
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+* Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+* 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.
+* Neither the name of Gradwell dot com Ltd nor the names of its
+ contributors may be used to endorse or promote products derived from this
+ software without specific prior written permission.
+
+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 HOLDER 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.
92 README.md
@@ -0,0 +1,92 @@
+ComponentManagerPhpLibrary
+==========================
+
+ComponentManagerPhpLibrary contains the code and data used by the phix commands for creating and maintaining php-library components.
+
+To learn more about PHP components, Google for 'Beyond Frameworks'.
+
+Installation
+------------
+
+ComponentManagerPhpLibrary is normally installed as a dependency; i.e. it gets installed because something else lists it in a package.xml file.
+
+If you want to install it yourself, you can do so using using the [PEAR Installer](http://pear.php.net). This installer is the community's de-facto standard for distributing PHP components.
+
+ sudo pear channel-discover pear.gradwell.com
+ sudo pear install --alldeps Gradwell/ComponentManagerPhpLibrary
+
+After installation, you will find the code inside your local PEAR repository, which on Linux systems is normally /usr/share/php.
+
+Documentation
+-------------
+
+This component adds the 'php-library:' set of commands to phix.
+
+To see all of the commands available, do:
+
+ # phix built-in help
+ phix
+
+To get help on the individual php-library commands, do:
+
+ # php-library built-in help
+ phix help php-library:init
+ phix help php-library:status
+ phix help php-library:upgrade
+
+Development Environment
+-----------------------
+
+If you want to patch or enhance this component, you will need to create a suitable development environment:
+
+ # phpunit
+ sudo pear channel-discover pear.phpunit.de
+ sudo pear channel-discover components.ez.no
+ sudo pear channel-discover pear.symfony-project.com
+ sudo pear install --alldeps phpunit/PHPUnit
+
+ # phing
+ sudo pear channel-discover pear.phing.info
+ sudo pear install --alldeps phing/phing
+
+ # pdepend
+ sudo pear channel-discover pear.pdepend.org
+ sudo pear install --alldeps pdepend/PHP_Depend-beta
+
+ # phpdoc
+ sudo pear install --alldeps pear/PhpDocumentor
+
+ # phpmd
+ sudo apt-get install php5-imagick
+ sudo pear channel-discover pear.phpmd.org
+ sudo pear install --alldeps phpmd/PHP_PMD-alpha
+
+ # phpcpd
+ sudo pear install --alldeps phpunit/phpcpd
+
+ # phpcs
+ sudo pear install --alldeps pear/PHP_CodeSniffer-beta
+
+ # phpcb
+ sudo pear install --alldeps phpunit/PHP_CodeBrowser
+
+You can then clone the git repository:
+
+ # ComponentManagerPhpLibrary
+ git clone git://github.com/Gradwell/ComponentManagerPhpLibrary.git
+
+You will then need to populate the vendor folder, to build a local copy of all of the dependencies for
+
+ # vendor folder
+ cd ComponentManagerPhpLibrary
+ phing build-vendor
+
+To test your changes, you would do the following:
+
+ # test changes
+ phing test
+
+ # install changes into vendor folder, for local use
+ phing pear-package
+ phing install-local
+ vendor/bin/phix <command>
9 build.properties
@@ -0,0 +1,9 @@
+project.name=ComponentManagerPhpLibrary
+project.majorVersion=1
+project.minorVersion=0
+project.patchLevel=0
+
+checkstyle.standard=Zend
+
+component.type=php-library
+component.version=2
249 build.xml
@@ -0,0 +1,249 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- build file for phing -->
+<project default="help" basedir=".">
+ <!-- Human-readable info about our component -->
+ <property file="build.properties" />
+
+ <property name="project.version" value="${project.majorVersion}.${project.minorVersion}.${project.patchLevel}" />
+ <property name="project.apiversion" value="${project.majorVersion}.${project.minorVersion}" />
+
+ <!-- Paths to the directories that we work with -->
+ <property name="project.srcdir" value="${project.basedir}/src" override="true" />
+ <property name="project.src.phpdir" value="${project.srcdir}/php" override="true" />
+ <property name="project.src.bindir" value="${project.srcdir}/bin" override="true" />
+ <property name="project.src.datadir" value="${project.srcdir}/data" override="true" />
+ <property name="project.src.testdir" value="${project.srcdir}/tests" override="true" />
+ <property name="project.src.wwwdir" value="${project.srcdir}/www" override="true" />
+ <property name="project.src.testunitdir" value="${project.src.testdir}/unit-tests" override="true" />
+ <property name="project.src.testintdir" value="${project.src.testdir}/integration-tests" override="true" />
+ <property name="project.src.testfuncdir" value="${project.src.testdir}/functional-tests" override="true" />
+
+ <property name="project.reviewdir" value="${project.basedir}/review" override="true" />
+ <property name="project.review.logsdir" value="${project.basedir}/review/logs" override="true" />
+ <property name="project.review.docsdir" value="${project.reviewdir}/docs" override="true" />
+ <property name="project.review.codebrowserdir" value="${project.reviewdir}/code-browser" override="true" />
+ <property name="project.review.codecoveragedir" value="${project.reviewdir}/code-coverage" override="true" />
+
+ <property name="project.builddir" value="${project.basedir}/.build" override="true" />
+ <property name="project.pkgdir" value="${project.builddir}/${project.name}-${project.version}" override="true" />
+ <property name="project.tmpdir" value="${project.basedir}/.tmp" override="true" />
+
+ <property name="project.vendordir" value="${project.basedir}/vendor" override="true" />
+ <property name="project.vendor.bindir" value="${project.vendordir}/bin" override="true" />
+ <property name="project.vendor.datadir" value="${project.vendordir}/data" override="true" />
+ <property name="project.vendor.phpdir" value="${project.vendordir}/php" override="true" />
+ <property name="project.vendor.testdir" value="${project.vendordir}/tests" override="true" />
+ <property name="project.vendor.docdir" value="${project.vendordir}/docs" override="true" />
+ <property name="project.vendor.wwwdir" value="${project.vendordir}/www" override="true" />
+
+ <property name="project.distdir" value="${project.basedir}/dist" />
+ <property name="project.tarfilename" value="${project.name}-${project.version}.tgz" />
+ <property name="project.tarfile" value="${project.distdir}/${project.tarfilename}" />
+
+ <!-- a user to use to publish on the pear server -->
+ <property name="remote.user" value="" override="true" />
+
+ <!-- lists of the files that make up our package -->
+ <fileset dir="${project.src.bindir}" id="binfiles">
+ <include name="**/**"/>
+ </fileset>
+ <fileset dir="${project.src.datadir}" id="datafiles">
+ <include name="**/**"/>
+ </fileset>
+ <fileset dir="${project.src.phpdir}" id="phpfiles">
+ <include name="**/**"/>
+ </fileset>
+ <fileset dir="${project.src.testunitdir}/php" id="testfiles">
+ <include name="**/**"/>
+ </fileset>
+ <fileset dir="${project.src.wwwdir}" id="wwwfiles">
+ <include name="**/**" />
+ </fileset>
+
+ <!-- Tell the user what this build file supports -->
+ <target name="help">
+ <echo message="${project.name} ${project.version}: build.xml targets:" />
+ <echo message="" />
+ <echo message="lint" />
+ <echo message=" Check the PHP files for syntax errors" />
+ <echo message="test" />
+ <echo message=" Run the component's PHPUnit tests" />
+ <echo message="code-review" />
+ <echo message=" Run all of the code quality targets:" />
+ <echo message="" />
+ <echo message=" code-browser" />
+ <echo message=" Run code quality tests for PHP_CodeBrowser" />
+ <echo message=" phpcpd" />
+ <echo message=" Check for cut and paste problems" />
+ <echo message=" phpdoc" />
+ <echo message=" Create the PHP docs from source code" />
+ <echo message="" />
+ <echo message="build-vendor" />
+ <echo message=" Populate vendor/ with this package's dependencies" />
+ <echo message="pear-package" />
+ <echo message=" Create a PEAR-compatible package" />
+ <echo message="install-vendor" />
+ <echo message=" Install this component from source into vendor/" />
+ <echo message="install-system" />
+ <echo message=" Install this component from source for all local users" />
+ <echo message=" You must be root to run this target on Linux!!" />
+ <echo message="clean" />
+ <echo message=" Remove all temporary folders created by this build file" />
+ </target>
+
+ <!-- Run PHP lint on all of the source code -->
+ <target name="lint">
+ <phplint>
+ <fileset dir="${project.src.phpdir}">
+ <include name="**/*.php" />
+ </fileset>
+ </phplint>
+ </target>
+
+ <!-- Run the unit tests for this module -->
+ <target name="run-unittests" depends="lint">
+ <delete dir="${project.review.codecoveragedir}" />
+ <mkdir dir="${project.review.codecoveragedir}" />
+ <mkdir dir="${project.review.logsdir}" />
+ <exec command="phpunit --bootstrap=${project.src.testunitdir}/bootstrap.php --coverage-html ${project.review.codecoveragedir} --coverage-clover ${project.review.logsdir}/phpunit.xml ${project.src.testunitdir}" checkreturn="true" logoutput="true"/>
+ <echo/>
+ <echo>The code coverage report is in ${project.review.codecoveragedir}</echo>
+ </target>
+
+ <!-- Run all the tests for this module -->
+ <target name="test" depends="run-unittests" />
+
+ <!-- Run the code review quality tests -->
+ <target name="code-review" depends="run-unittests, code-browser, phpcpd, pdepend" />
+
+ <!-- Run all of the targets for setting up the code browser -->
+ <target name="code-browser" depends="phpmd, phpcs, phpcb" />
+
+ <target name="pdepend">
+ <mkdir dir="${project.review.logsdir}" />
+ <exec command="pdepend --phpunit-xml=${project.review.logsdir}/pdepend.xml --jdepend-xml=${project.review.logsdir}/jdepend.xml --jdepend-chart=${project.review.logsdir}/dependencies.svg --overview-pyramid=${project.review.logsdir}/overview-pyramid.svg ${project.src.phpdir}" logoutput="true"/>
+ </target>
+
+ <!-- Generate package docs -->
+ <target name="phpdoc">
+ <mkdir dir="${project.review.logsdir}" />
+ <exec command="phpdoc -d ${project.src.phpdir} -t ${project.review.docsdir}" logoutput="true"/>
+ <echo message="You will find the PHPDoc for your project at: ${project.review.docsdir}/index.html"/>
+ </target>
+
+ <!-- Check code for code smells -->
+ <target name="phpmd">
+ <mkdir dir="${project.review.logsdir}" />
+ <exec command="phpmd ${project.src.phpdir} xml codesize,design,naming,unusedcode --reportfile ${project.review.logsdir}/phpmd.xml" logoutput="true" />
+ </target>
+
+ <target name="phpcpd">
+ <mkdir dir="${project.review.logsdir}"/>
+ <exec command="phpcpd --log-pmd ${project.review.logsdir}/pmd-cpd.xml ${project.src.phpdir}" logoutput="true" />
+ </target>
+
+ <!-- Check the code for style violations -->
+ <target name="phpcs">
+ <mkdir dir="${project.review.logsdir}" />
+ <exec command="phpcs --report=xml --report-file=${project.review.logsdir}/checkstyle.xml --standard=${checkstyle.standard} --extensions=php ${project.src.phpdir}" logoutput="true"/>
+ </target>
+
+ <!-- Build the code-browser files -->
+ <target name="phpcb" depends="phpmd">
+ <delete dir="${project.review.codebrowserdir}" />
+ <mkdir dir="${project.review.codebrowserdir}" />
+ <exec command="phpcb --log ${project.review.logsdir} --source ${project.src.phpdir} --output ${project.review.codebrowserdir}" logoutput="true" />
+ </target>
+
+ <!-- Populate vendor with the dependencies for this component -->
+ <target name="build-vendor" depends="pear-package,setup-vendor">
+ <echo>Populating vendor/ with dependencies</echo>
+ <exec command="phix pear:register-channels" checkreturn="true" logoutput="true" />
+ <exec command="pear -c ${project.tmpdir}/pear-config install --alldeps ${project.builddir}/package.xml" logoutput="true" checkreturn="true"/>
+ </target>
+
+ <!-- Setup the vendor folder -->
+ <target name="setup-vendor">
+ <echo>Creating vendor/ as a sandboxed PEAR install folder</echo>
+ <delete dir="${project.vendordir}" />
+ <mkdir dir="${project.vendordir}" />
+ <delete dir="${project.tmpdir}" />
+ <mkdir dir="${project.tmpdir}" />
+ <exec command="pear config-create ${project.tmpdir} ${project.tmpdir}/pear-config" checkreturn="true" logoutput="true" />
+ <exec command="pear -c ${project.tmpdir}/pear-config config-set preferred_state alpha" checkreturn="true" logoutput="true" />
+ <exec command="pear -c ${project.tmpdir}/pear-config config-set php_dir ${project.vendor.phpdir}" checkreturn="true" logoutput="true" />
+ <exec command="pear -c ${project.tmpdir}/pear-config config-set bin_dir ${project.vendor.bindir}" checkreturn="true" logoutput="true" />
+ <exec command="pear -c ${project.tmpdir}/pear-config config-set data_dir ${project.vendor.datadir}" checkreturn="true" logoutput="true" />
+ <exec command="pear -c ${project.tmpdir}/pear-config config-set doc_dir ${project.vendor.docdir}" checkreturn="true" logoutput="true" />
+ <exec command="pear -c ${project.tmpdir}/pear-config config-set test_dir ${project.vendor.testdir}" checkreturn="true" logoutput="true" />
+ <exec command="pear -c ${project.tmpdir}/pear-config config-set www_dir ${project.vendor.wwwdir}" checkreturn="true" logoutput="true" />
+ </target>
+
+ <!-- Create a dummy PEAR package to satisfy lib-vendor -->
+ <target name="pear-package-for-lib-vendor">
+ <echo>Building release directory</echo>
+ <delete dir="${project.builddir}" />
+ <mkdir dir="${project.pkgdir}" />
+ <copy todir="${project.pkgdir}">
+ <fileset refid="phpfiles"/>
+ </copy>
+ <copy todir="${project.builddir}">
+ <fileset dir=".">
+ <include name="package.xml" />
+ </fileset>
+ </copy>
+ <copy file="${project.basedir}/build.xml" tofile="${project.builddir}/build.xml" overwrite="true" />
+ <exec command="phix pear:expand-package-xml" checkreturn="yes" logoutput="yes"/>
+ </target>
+
+ <!-- Create the PEAR package, ready for release -->
+ <target name="pear-package">
+ <echo>Building release directory</echo>
+ <delete dir="${project.builddir}" />
+ <mkdir dir="${project.pkgdir}" />
+ <copy todir="${project.pkgdir}">
+ <fileset refid="binfiles"/>
+ <fileset refid="datafiles"/>
+ <fileset refid="phpfiles"/>
+ <fileset refid="testfiles"/>
+ <fileset refid="wwwfiles"/>
+ </copy>
+ <copy todir="${project.builddir}">
+ <fileset dir=".">
+ <include name="package.xml" />
+ </fileset>
+ </copy>
+
+ <exec command="phix pear:expand-package-xml" checkreturn="yes" logoutput="yes"/>
+
+ <echo>Creating ${project.tarfile} PEAR package</echo>
+
+ <mkdir dir="${project.distdir}" />
+ <delete file="${project.tarfile}" />
+ <tar destfile="${project.tarfile}" compression="gzip">
+ <fileset dir="${project.builddir}">
+ <include name="*" />
+ </fileset>
+ </tar>
+ <echo>Your PEAR package is in ${project.tarfile}</echo>
+ </target>
+
+ <!-- Install the code -->
+ <target name="install-vendor">
+ <exec command="pear -c ${project.tmpdir}/pear-config install --alldeps -f ${project.tarfile}" logoutput="true" checkreturn="true"/>
+ </target>
+ <target name="install-system">
+ <exec command="pear install -f -a ${project.tarfile}" checkreturn="true" logoutput="true" />
+ </target>
+
+ <!-- Clean up the mess -->
+ <target name="clean">
+ <delete dir="${project.builddir}" />
+ <delete dir="${project.distdir}" />
+ <delete dir="${project.reviewdir}" />
+ <delete dir="${project.pkgdir}" />
+ <delete dir="${project.distdir}" />
+ <delete dir="${project.tmpdir}" />
+ </target>
+</project>
+<!-- vim: set tabstop=2 shiftwidth=2 expandtab: -->
83 package.xml
@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<package packagerversion="1.9.1" version="2.0" xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0
+ http://pear.php.net/dtd/tasks-1.0.xsd
+ http://pear.php.net/dtd/package-2.0
+ http://pear.php.net/dtd/package-2.0.xsd">
+ <name>ComponentManagerPhpLibrary</name>
+ <channel>pear.gradwell.com</channel>
+ <summary>Supports creating and managing a php-library component</summary>
+ <description>
+ ComponentManagerPhpLibrary contains the code and skeleton files required to create and manage a php-library component.
+ </description>
+ <lead>
+ <name>Stuart Herbert</name>
+ <user>stuartherbert</user>
+ <email>stuart@stuartherbert.com</email>
+ <active>yes</active>
+ </lead>
+ <date>${build.date}</date>
+ <time>${build.time}</time>
+ <version>
+ <release>${project.majorVersion}.${project.minorVersion}.${project.patchLevel}</release>
+ <api>${project.majorVersion}.${project.minorVersion}</api>
+ </version>
+ <stability>
+ <release>stable</release>
+ <api>stable</api>
+ </stability>
+ <license>New BSD license</license>
+ <notes>
+ No notes.
+ </notes>
+ <contents>
+ <dir baseinstalldir="/" name="/">
+${contents}
+ </dir>
+ </contents>
+ <dependencies>
+ <required>
+ <php>
+ <min>5.3.0</min>
+ </php>
+ <pearinstaller>
+ <min>1.6.0</min>
+ </pearinstaller>
+ <package>
+ <name>Autoloader</name>
+ <channel>pear.gradwell.com</channel>
+ <min>2.0.0</min>
+ <max>2.999.9999</max>
+ </package>
+ <package>
+ <name>ComponentManagerShared</name>
+ <channel>pear.gradwell.com</channel>
+ <min>1.0.0</min>
+ <max>1.999.9999</max>
+ </package>
+ <package>
+ <name>phix</name>
+ <channel>pear.gradwell.com</channel>
+ <min>0.10.0</min>
+ <max>1.999.9999</max>
+ </package>
+ </required>
+ </dependencies>
+ <phprelease />
+ <changelog>
+ <release>
+ <version>
+ <release>1.0.0</release>
+ <api>1.0</api>
+ </version>
+ <stability>
+ <release>stable</release>
+ <api>stable</api>
+ </stability>
+ <date>2011-03-21</date>
+ <license>New BSD license</license>
+ <notes>
+ </notes>
+ </release>
+ </changelog>
+</package>
+<!-- vim: set tabstop=2 shiftwidth=2 expandtab: -->
6 src/data/php-library/.gitignore
@@ -0,0 +1,6 @@
+.build
+dist
+.tmp
+nbproject
+review
+vendor
8 src/data/php-library/.hgignore
@@ -0,0 +1,8 @@
+syntax: glob
+
+.build
+.dist
+nbproject
+review
+tmp
+vendor
0  src/data/php-library/LICENSE.txt
No changes.
0  src/data/php-library/README.md
No changes.
31 src/data/php-library/bootstrap.php
@@ -0,0 +1,31 @@
+<?php
+
+// =========================================================================
+//
+// tests/bootstrap.php
+// A helping hand for running our unit tests
+//
+// Author Stuart Herbert
+// (stuart.herbert@gradwell.com)
+//
+// Copyright (c) 2010 Gradwell dot com Ltd
+// All rights reserved
+//
+// =========================================================================
+
+// step 1: create the APP_TOPDIR constant that all MF components require
+define('APP_TOPDIR', realpath(__DIR__ . '/../../php'));
+define('APP_LIBDIR', realpath(__DIR__ . '/../../../vendor/php'));
+define('APP_TESTDIR', realpath(__DIR__ . '/php'));
+
+// step 2: add the lib-vendor code to the include path
+set_include_path(APP_LIBDIR . PATH_SEPARATOR . get_include_path());
+
+// step 3: add the tests folder to the include path
+set_include_path(APP_TESTDIR . PATH_SEPARATOR . get_include_path());
+
+// step 4: add our code to the include path
+set_include_path(APP_TOPDIR . PATH_SEPARATOR . get_include_path());
+
+// step 5: find the autoloader, and install it
+require_once(APP_LIBDIR . '/gwc.autoloader.php');
11 src/data/php-library/build.properties
@@ -0,0 +1,11 @@
+project.name=<your project name>
+project.majorVersion=X
+project.minorVersion=Y
+project.patchLevel=Z
+
+checkstyle.standard=Zend
+
+publish.user=<your user here>
+
+component.type=php-library
+component.version=2
249 src/data/php-library/build.xml
@@ -0,0 +1,249 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- build file for phing -->
+<project default="help" basedir=".">
+ <!-- Human-readable info about our component -->
+ <property file="build.properties" />
+
+ <property name="project.version" value="${project.majorVersion}.${project.minorVersion}.${project.patchLevel}" />
+ <property name="project.apiversion" value="${project.majorVersion}.${project.minorVersion}" />
+
+ <!-- Paths to the directories that we work with -->
+ <property name="project.srcdir" value="${project.basedir}/src" override="true" />
+ <property name="project.src.phpdir" value="${project.srcdir}/php" override="true" />
+ <property name="project.src.bindir" value="${project.srcdir}/bin" override="true" />
+ <property name="project.src.datadir" value="${project.srcdir}/data" override="true" />
+ <property name="project.src.testdir" value="${project.srcdir}/tests" override="true" />
+ <property name="project.src.wwwdir" value="${project.srcdir}/www" override="true" />
+ <property name="project.src.testunitdir" value="${project.src.testdir}/unit-tests" override="true" />
+ <property name="project.src.testintdir" value="${project.src.testdir}/integration-tests" override="true" />
+ <property name="project.src.testfuncdir" value="${project.src.testdir}/functional-tests" override="true" />
+
+ <property name="project.reviewdir" value="${project.basedir}/review" override="true" />
+ <property name="project.review.logsdir" value="${project.basedir}/review/logs" override="true" />
+ <property name="project.review.docsdir" value="${project.reviewdir}/docs" override="true" />
+ <property name="project.review.codebrowserdir" value="${project.reviewdir}/code-browser" override="true" />
+ <property name="project.review.codecoveragedir" value="${project.reviewdir}/code-coverage" override="true" />
+
+ <property name="project.builddir" value="${project.basedir}/.build" override="true" />
+ <property name="project.pkgdir" value="${project.builddir}/${project.name}-${project.version}" override="true" />
+ <property name="project.tmpdir" value="${project.basedir}/.tmp" override="true" />
+
+ <property name="project.vendordir" value="${project.basedir}/vendor" override="true" />
+ <property name="project.vendor.bindir" value="${project.vendordir}/bin" override="true" />
+ <property name="project.vendor.datadir" value="${project.vendordir}/data" override="true" />
+ <property name="project.vendor.phpdir" value="${project.vendordir}/php" override="true" />
+ <property name="project.vendor.testdir" value="${project.vendordir}/tests" override="true" />
+ <property name="project.vendor.docdir" value="${project.vendordir}/docs" override="true" />
+ <property name="project.vendor.wwwdir" value="${project.vendordir}/www" override="true" />
+
+ <property name="project.distdir" value="${project.basedir}/dist" />
+ <property name="project.tarfilename" value="${project.name}-${project.version}.tgz" />
+ <property name="project.tarfile" value="${project.distdir}/${project.tarfilename}" />
+
+ <!-- a user to use to publish on the pear server -->
+ <property name="remote.user" value="" override="true" />
+
+ <!-- lists of the files that make up our package -->
+ <fileset dir="${project.src.bindir}" id="binfiles">
+ <include name="**/**"/>
+ </fileset>
+ <fileset dir="${project.src.datadir}" id="datafiles">
+ <include name="**/**"/>
+ </fileset>
+ <fileset dir="${project.src.phpdir}" id="phpfiles">
+ <include name="**/**"/>
+ </fileset>
+ <fileset dir="${project.src.testunitdir}/php" id="testfiles">
+ <include name="**/**"/>
+ </fileset>
+ <fileset dir="${project.src.wwwdir}" id="wwwfiles">
+ <include name="**/**" />
+ </fileset>
+
+ <!-- Tell the user what this build file supports -->
+ <target name="help">
+ <echo message="${project.name} ${project.version}: build.xml targets:" />
+ <echo message="" />
+ <echo message="lint" />
+ <echo message=" Check the PHP files for syntax errors" />
+ <echo message="test" />
+ <echo message=" Run the component's PHPUnit tests" />
+ <echo message="code-review" />
+ <echo message=" Run all of the code quality targets:" />
+ <echo message="" />
+ <echo message=" code-browser" />
+ <echo message=" Run code quality tests for PHP_CodeBrowser" />
+ <echo message=" phpcpd" />
+ <echo message=" Check for cut and paste problems" />
+ <echo message=" phpdoc" />
+ <echo message=" Create the PHP docs from source code" />
+ <echo message="" />
+ <echo message="build-vendor" />
+ <echo message=" Populate vendor/ with this package's dependencies" />
+ <echo message="pear-package" />
+ <echo message=" Create a PEAR-compatible package" />
+ <echo message="install-vendor" />
+ <echo message=" Install this component from source into vendor/" />
+ <echo message="install-system" />
+ <echo message=" Install this component from source for all local users" />
+ <echo message=" You must be root to run this target on Linux!!" />
+ <echo message="clean" />
+ <echo message=" Remove all temporary folders created by this build file" />
+ </target>
+
+ <!-- Run PHP lint on all of the source code -->
+ <target name="lint">
+ <phplint>
+ <fileset dir="${project.src.phpdir}">
+ <include name="**/*.php" />
+ </fileset>
+ </phplint>
+ </target>
+
+ <!-- Run the unit tests for this module -->
+ <target name="run-unittests" depends="lint">
+ <delete dir="${project.review.codecoveragedir}" />
+ <mkdir dir="${project.review.codecoveragedir}" />
+ <mkdir dir="${project.review.logsdir}" />
+ <exec command="phpunit --bootstrap=${project.src.testunitdir}/bootstrap.php --coverage-html ${project.review.codecoveragedir} --coverage-clover ${project.review.logsdir}/phpunit.xml ${project.src.testunitdir}" checkreturn="true" logoutput="true"/>
+ <echo/>
+ <echo>The code coverage report is in ${project.review.codecoveragedir}</echo>
+ </target>
+
+ <!-- Run all the tests for this module -->
+ <target name="test" depends="run-unittests" />
+
+ <!-- Run the code review quality tests -->
+ <target name="code-review" depends="run-unittests, code-browser, phpcpd, pdepend" />
+
+ <!-- Run all of the targets for setting up the code browser -->
+ <target name="code-browser" depends="phpmd, phpcs, phpcb" />
+
+ <target name="pdepend">
+ <mkdir dir="${project.review.logsdir}" />
+ <exec command="pdepend --phpunit-xml=${project.review.logsdir}/pdepend.xml --jdepend-xml=${project.review.logsdir}/jdepend.xml --jdepend-chart=${project.review.logsdir}/dependencies.svg --overview-pyramid=${project.review.logsdir}/overview-pyramid.svg ${project.src.phpdir}" logoutput="true"/>
+ </target>
+
+ <!-- Generate package docs -->
+ <target name="phpdoc">
+ <mkdir dir="${project.review.logsdir}" />
+ <exec command="phpdoc -d ${project.src.phpdir} -t ${project.review.docsdir}" logoutput="true"/>
+ <echo message="You will find the PHPDoc for your project at: ${project.review.docsdir}/index.html"/>
+ </target>
+
+ <!-- Check code for code smells -->
+ <target name="phpmd">
+ <mkdir dir="${project.review.logsdir}" />
+ <exec command="phpmd ${project.src.phpdir} xml codesize,design,naming,unusedcode --reportfile ${project.review.logsdir}/phpmd.xml" logoutput="true" />
+ </target>
+
+ <target name="phpcpd">
+ <mkdir dir="${project.review.logsdir}"/>
+ <exec command="phpcpd --log-pmd ${project.review.logsdir}/pmd-cpd.xml ${project.src.phpdir}" logoutput="true" />
+ </target>
+
+ <!-- Check the code for style violations -->
+ <target name="phpcs">
+ <mkdir dir="${project.review.logsdir}" />
+ <exec command="phpcs --report=xml --report-file=${project.review.logsdir}/checkstyle.xml --standard=${checkstyle.standard} --extensions=php ${project.src.phpdir}" logoutput="true"/>
+ </target>
+
+ <!-- Build the code-browser files -->
+ <target name="phpcb" depends="phpmd">
+ <delete dir="${project.review.codebrowserdir}" />
+ <mkdir dir="${project.review.codebrowserdir}" />
+ <exec command="phpcb --log ${project.review.logsdir} --source ${project.src.phpdir} --output ${project.review.codebrowserdir}" logoutput="true" />
+ </target>
+
+ <!-- Populate vendor with the dependencies for this component -->
+ <target name="build-vendor" depends="pear-package,setup-vendor">
+ <echo>Populating vendor/ with dependencies</echo>
+ <exec command="phix pear:register-channels" checkreturn="true" logoutput="true" />
+ <exec command="pear -c ${project.tmpdir}/pear-config install --alldeps ${project.builddir}/package.xml" logoutput="true" checkreturn="true"/>
+ </target>
+
+ <!-- Setup the vendor folder -->
+ <target name="setup-vendor">
+ <echo>Creating vendor/ as a sandboxed PEAR install folder</echo>
+ <delete dir="${project.vendordir}" />
+ <mkdir dir="${project.vendordir}" />
+ <delete dir="${project.tmpdir}" />
+ <mkdir dir="${project.tmpdir}" />
+ <exec command="pear config-create ${project.tmpdir} ${project.tmpdir}/pear-config" checkreturn="true" logoutput="true" />
+ <exec command="pear -c ${project.tmpdir}/pear-config config-set preferred_state alpha" checkreturn="true" logoutput="true" />
+ <exec command="pear -c ${project.tmpdir}/pear-config config-set php_dir ${project.vendor.phpdir}" checkreturn="true" logoutput="true" />
+ <exec command="pear -c ${project.tmpdir}/pear-config config-set bin_dir ${project.vendor.bindir}" checkreturn="true" logoutput="true" />
+ <exec command="pear -c ${project.tmpdir}/pear-config config-set data_dir ${project.vendor.datadir}" checkreturn="true" logoutput="true" />
+ <exec command="pear -c ${project.tmpdir}/pear-config config-set doc_dir ${project.vendor.docdir}" checkreturn="true" logoutput="true" />
+ <exec command="pear -c ${project.tmpdir}/pear-config config-set test_dir ${project.vendor.testdir}" checkreturn="true" logoutput="true" />
+ <exec command="pear -c ${project.tmpdir}/pear-config config-set www_dir ${project.vendor.wwwdir}" checkreturn="true" logoutput="true" />
+ </target>
+
+ <!-- Create a dummy PEAR package to satisfy lib-vendor -->
+ <target name="pear-package-for-lib-vendor">
+ <echo>Building release directory</echo>
+ <delete dir="${project.builddir}" />
+ <mkdir dir="${project.pkgdir}" />
+ <copy todir="${project.pkgdir}">
+ <fileset refid="phpfiles"/>
+ </copy>
+ <copy todir="${project.builddir}">
+ <fileset dir=".">
+ <include name="package.xml" />
+ </fileset>
+ </copy>
+ <copy file="${project.basedir}/build.xml" tofile="${project.builddir}/build.xml" overwrite="true" />
+ <exec command="phix pear:expand-package-xml" checkreturn="yes" logoutput="yes"/>
+ </target>
+
+ <!-- Create the PEAR package, ready for release -->
+ <target name="pear-package">
+ <echo>Building release directory</echo>
+ <delete dir="${project.builddir}" />
+ <mkdir dir="${project.pkgdir}" />
+ <copy todir="${project.pkgdir}">
+ <fileset refid="binfiles"/>
+ <fileset refid="datafiles"/>
+ <fileset refid="phpfiles"/>
+ <fileset refid="testfiles"/>
+ <fileset refid="wwwfiles"/>
+ </copy>
+ <copy todir="${project.builddir}">
+ <fileset dir=".">
+ <include name="package.xml" />
+ </fileset>
+ </copy>
+
+ <exec command="phix pear:expand-package-xml" checkreturn="yes" logoutput="yes"/>
+
+ <echo>Creating ${project.tarfile} PEAR package</echo>
+
+ <mkdir dir="${project.distdir}" />
+ <delete file="${project.tarfile}" />
+ <tar destfile="${project.tarfile}" compression="gzip">
+ <fileset dir="${project.builddir}">
+ <include name="*" />
+ </fileset>
+ </tar>
+ <echo>Your PEAR package is in ${project.tarfile}</echo>
+ </target>
+
+ <!-- Install the code -->
+ <target name="install-vendor">
+ <exec command="pear -c ${project.tmpdir}/pear-config install --alldeps -f ${project.tarfile}" logoutput="true" checkreturn="true"/>
+ </target>
+ <target name="install-system">
+ <exec command="pear install -f -a ${project.tarfile}" checkreturn="true" logoutput="true" />
+ </target>
+
+ <!-- Clean up the mess -->
+ <target name="clean">
+ <delete dir="${project.builddir}" />
+ <delete dir="${project.distdir}" />
+ <delete dir="${project.reviewdir}" />
+ <delete dir="${project.pkgdir}" />
+ <delete dir="${project.distdir}" />
+ <delete dir="${project.tmpdir}" />
+ </target>
+</project>
+<!-- vim: set tabstop=2 shiftwidth=2 expandtab: -->
71 src/data/php-library/package.xml
@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<package packagerversion="1.9.1" version="2.0" xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0
+ http://pear.php.net/dtd/tasks-1.0.xsd
+ http://pear.php.net/dtd/package-2.0
+ http://pear.php.net/dtd/package-2.0.xsd">
+ <name>Your Package Name</name>
+ <channel>Your PEAR server</channel>
+ <summary>Summary goes here</summary>
+ <description>
+ Description goes here
+ </description>
+ <lead>
+ <name>Your name</name>
+ <user>Anything goes here</user>
+ <email>Your email address</email>
+ <active>yes</active>
+ </lead>
+ <date>${build.date}</date>
+ <time>${build.time}</time>
+ <version>
+ <release>${project.majorVersion}.${project.minorVersion}.${project.patchLevel}</release>
+ <api>${project.majorVersion}.${project.minorVersion}</api>
+ </version>
+ <stability>
+ <release>stable</release>
+ <api>stable</api>
+ </stability>
+ <license>All rights reserved.</license>
+ <notes>
+ No notes.
+ </notes>
+ <contents>
+ <dir baseinstalldir="/" name="/">
+${contents}
+ </dir>
+ </contents>
+ <dependencies>
+ <required>
+ <php>
+ <min>5.2.0</min>
+ </php>
+ <pearinstaller>
+ <min>1.6.0</min>
+ </pearinstaller>
+ <package>
+ <name>Autoloader</name>
+ <channel>pear.gradwell.com</channel>
+ <min>1.0.0</min>
+ <max>1.999.9999</max>
+ </package>
+ </required>
+ </dependencies>
+ <phprelease />
+ <changelog>
+ <release>
+ <version>
+ <release>X.Y.Z</release>
+ <api>X.Y</api>
+ </version>
+ <stability>
+ <release>stable</release>
+ <api>stable</api>
+ </stability>
+ <date>Your release date</date>
+ <license>All rights reserved</license>
+ <notes>
+ </notes>
+ </release>
+ </changelog>
+</package>
+<!-- vim: set tabstop=2 shiftwidth=2 expandtab: -->
197 src/php/Gradwell/ComponentManager/Entities/LibraryComponentFolder.php
@@ -0,0 +1,197 @@
+<?php
+
+/**
+ * Copyright (c) 2010 Gradwell dot com Ltd.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * 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.
+ *
+ * * Neither the name of Gradwell dot com Ltd nor the names of his
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 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.
+ *
+ * @package Gradwell
+ * @subpackage ComponentManager
+ * @author Stuart Herbert <stuart.herbert@gradwell.com>
+ * @copyright 2010 Gradwell dot com Ltd. www.gradwell.com
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @link http://gradwell.github.com
+ * @version @@PACKAGE_VERSION@@
+ */
+
+namespace Gradwell\ComponentManager\Entities;
+
+class LibraryComponentFolder extends ComponentFolder
+{
+ const LATEST_VERSION = 3;
+ const DATA_FOLDER = '@@DATA_DIR@@/phix/php-library';
+
+ public function createComponent()
+ {
+ // step 1: create the folders required
+ $this->createFolders();
+
+ // step 2: create the build file
+ $this->createBuildFile();
+ $this->createBuildProperties();
+
+ // step 3: create the package.xml file
+ $this->createPackageXmlFile();
+
+ // step 4: add in the doc files
+ $this->createDocFiles();
+
+ // step 5: add in config files for popular source
+ // control systems
+ $this->createScmIgnoreFiles();
+
+ // step 6: don't forget the bootstrap file for
+ // the unit tests
+ $this->createBootstrapFile();
+
+ // if we get here, job done
+ }
+
+ public function upgradeComponent()
+ {
+ // just make sure we're not being asked to do something
+ // that is impossible
+ if ($this->componentVersion >= self::LATEST_VERSION)
+ {
+ throw new \Exception('Folder ' . $this->folder . ' is on version ' . $this->componentVersion . ' which is newer than known latest version ' . self::LATEST_VERSION);
+ }
+
+ // ok, let's do the upgrades
+ $thisVersion = $this->componentVersion;
+ while ($thisVersion < self::LATEST_VERSION)
+ {
+ $method = 'upgradeFrom' . $thisVersion . 'To' . ($thisVersion + 1);
+ \call_user_method($method, $this);
+ $thisVersion++;
+ $this->editBuildPropertiesVersionNumber($thisVersion);
+ }
+
+ // all done
+ }
+
+ protected function createFolders()
+ {
+ $foldersToMake = array
+ (
+ 'src',
+ 'src/php',
+ 'src/bin',
+ 'src/data',
+ 'src/web',
+ 'src/tests',
+ 'src/tests/unit-tests',
+ 'src/tests/unit-tests/bin',
+ 'src/tests/unit-tests/php',
+ 'src/tests/unit-tests/web',
+ 'src/tests/integration-tests',
+ 'src/tests/functional-tests',
+ );
+
+ foreach ($foldersToMake as $folderToMake)
+ {
+ $folder = $this->folder . '/' . $folderToMake;
+
+ // does the folder already exist?
+ if (is_dir($folder))
+ {
+ // yes it does ... nothing needed
+ continue;
+ }
+
+ // no it does not ... create it
+ if (!mkdir ($folder))
+ {
+ // it all went wrong
+ throw new \Exception('unable to create folder ' . $this->folder . '/' . $folderToMake);
+ }
+ }
+ }
+
+ protected function createBuildFile()
+ {
+ $this->copyFilesFromDataFolder(array('build.xml'));
+ }
+
+ protected function createBuildProperties()
+ {
+ $this->copyFilesFromDataFolder(array('build.properties'));
+ }
+
+ protected function createPackageXmlFile()
+ {
+ $this->copyFilesFromDataFolder(array('package.xml'));
+ }
+
+ protected function createDocFiles()
+ {
+ $this->copyFilesFromDataFolder(array('README.md', 'LICENSE.txt'));
+ }
+
+ protected function createScmIgnoreFiles()
+ {
+ $this->copyFilesFromDataFolder(array('.gitignore', '.hgignore'));
+ }
+
+ protected function createBootstrapFile()
+ {
+ $this->copyFilesFromDataFolder(array('bootstrap.php'), '/src/tests/unit-tests/');
+ }
+
+ /**
+ * Upgrade a php-library to v2
+ *
+ * The changes between v1 and v2 are:
+ *
+ * * improved build file
+ * * improved SCM ignore files
+ * * improved bootstrap file
+ *
+ * Nothing has moved location.
+ */
+ protected function upgradeFrom1To2()
+ {
+ $this->createBuildFile();
+ $this->createScmIgnoreFiles();
+ $this->createBootstrapFile();
+ }
+
+ /**
+ * Upgrade a php-library to v3
+ *
+ * The changes between v2 and v3 are:
+ *
+ * * improved build file
+ */
+ protected function upgradeFrom2To3()
+ {
+ $this->createBuildFile();
+ }
+}
125 src/php/Gradwell/ComponentManager/PhixCommands/PhpLibraryInit.php
@@ -0,0 +1,125 @@
+<?php
+
+/**
+ * Copyright (c) 2010 Gradwell dot com Ltd.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * 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.
+ *
+ * * Neither the name of Gradwell dot com Ltd nor the names of his
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 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.
+ *
+ * @package Gradwell
+ * @subpackage ComponentManager
+ * @author Stuart Herbert <stuart.herbert@gradwell.com>
+ * @copyright 2010 Gradwell dot com Ltd. www.gradwell.com
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @link http://gradwell.github.com
+ * @version @@PACKAGE_VERSION@@
+ */
+
+namespace Gradwell\ComponentManager\PhixCommands;
+
+use Phix_Project\Phix\CommandsList;
+use Phix_Project\Phix\Context;
+use Phix_Project\PhixExtensions\CommandInterface;
+use Gradwell\CommandLineLib\DefinedSwitches;
+use Gradwell\CommandLineLib\DefinedSwitch;
+
+use Gradwell\ComponentManager\Entities\LibraryComponentFolder;
+
+if (!class_exists('Gradwell\ComponentManager\PhixCommands\PhpLibraryInit'))
+{
+class PhpLibraryInit extends ComponentCommandBase implements CommandInterface
+{
+ public function getCommandName()
+ {
+ return 'php-library:init';
+ }
+
+ public function getCommandDesc()
+ {
+ return 'initialise the directory structure of a php-library component';
+ }
+
+ public function getCommandArgs()
+ {
+ return array
+ (
+ '<folder>' => '<folder> is a path to an existing folder, which you must have permission to write to.',
+ );
+ }
+
+ public function validateAndExecute($args, $argsIndex, Context $context)
+ {
+ $so = $context->stdout;
+ $se = $context->stderr;
+
+ // do we have a folder to init?
+ $errorCode = $this->validateFolder($args, $argsIndex, $context);
+ if ($errorCode !== null)
+ {
+ return $errorCode;
+ }
+ $folder = $args[$argsIndex];
+
+ // has the folder already been initialised?
+ $lib = new LibraryComponentFolder($folder);
+ if ($lib->state != LibraryComponentFolder::STATE_EMPTY)
+ {
+ $se->output($context->errorStyle, $context->errorPrefix);
+
+ // what do we need to tell the user to do?
+ switch ($lib->state)
+ {
+ case LibraryComponentFolder::STATE_UPTODATE:
+ $se->outputLine(null, "folder has already been initialised");
+ break;
+
+ case LibraryComponentFolder::STATE_NEEDSUPGRADE:
+ $se->outputLine(null, "folder has been initialised; needs upgrade");
+ $se->output(null, 'use ');
+ $se->output($context->commandStyle, $context->argvZero . ' php-library:upgrade');
+ $se->outputLine(null, ' to upgrade this folder');
+ break;
+
+ default:
+ $se->outputLine(null, 'I do not know what to do with this folder');
+ break;
+ }
+
+ return 1;
+ }
+
+ // if we get here, we have a green light
+ $lib->createComponent();
+
+ // if we get here, it worked (ie, no exception!!)
+ $so->outputLine(null, 'Initialised empty php-library component in ' . $folder);
+ }
+}
+}
120 src/php/Gradwell/ComponentManager/PhixCommands/PhpLibraryStatus.php
@@ -0,0 +1,120 @@
+<?php
+
+/**
+ * Copyright (c) 2010 Gradwell dot com Ltd.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * 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.
+ *
+ * * Neither the name of Gradwell dot com Ltd nor the names of his
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 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.
+ *
+ * @package Gradwell
+ * @subpackage ComponentManager
+ * @author Stuart Herbert <stuart.herbert@gradwell.com>
+ * @copyright 2010 Gradwell dot com Ltd. www.gradwell.com
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @link http://gradwell.github.com
+ * @version @@PACKAGE_VERSION@@
+ */
+
+namespace Gradwell\ComponentManager\PhixCommands;
+
+use Phix_Project\Phix\CommandsList;
+use Phix_Project\Phix\Context;
+use Phix_Project\PhixExtensions\CommandInterface;
+use Gradwell\CommandLineLib\DefinedSwitches;
+use Gradwell\CommandLineLib\DefinedSwitch;
+
+use Gradwell\ComponentManager\Entities\LibraryComponentFolder;
+
+if (!class_exists('Gradwell\ComponentManager\PhixCommands\PhpLibraryStatus'))
+{
+class PhpLibraryStatus extends ComponentCommandBase implements CommandInterface
+{
+ public function getCommandName()
+ {
+ return 'php-library:status';
+ }
+
+ public function getCommandDesc()
+ {
+ return 'check the status of a php-library component';
+ }
+
+ public function getCommandArgs()
+ {
+ return array
+ (
+ '<folder>' => '<folder> is a path to an existing folder, which you must have permission to write to.',
+ );
+ }
+
+ public function validateAndExecute($args, $argsIndex, Context $context)
+ {
+ $so = $context->stdout;
+ $se = $context->stderr;
+
+ // do we have a folder to init?
+ $errorCode = $this->validateFolder($args, $argsIndex, $context);
+ if ($errorCode !== null)
+ {
+ return $errorCode;
+ }
+ $folder = $args[$argsIndex];
+
+ // has the folder already been initialised?
+ $lib = new LibraryComponentFolder($folder);
+
+ // what do we need to tell the user to do?
+ switch ($lib->state)
+ {
+ case LibraryComponentFolder::STATE_UPTODATE:
+ $so->outputLine(null, "folder has already been initialised, and is up to date");
+ break;
+
+ case LibraryComponentFolder::STATE_NEEDSUPGRADE:
+ $so->outputLine(null, "folder has been initialised; needs upgrade");
+ $so->output(null, 'use ');
+ $so->output($context->commandStyle, $context->argvZero . ' php-library:upgrade');
+ $so->outputLine(null, ' to upgrade this folder');
+ break;
+
+ case LibraryComponentFolder::STATE_EMPTY:
+ $so->outputLine(null, 'folder is empty');
+ break;
+
+ default:
+ $se->output($context->errorStyle, $context->errorPrefix);
+ $se->outputLine(null, 'I do not know what to do with this folder');
+ break;
+ }
+
+ return 1;
+ }
+}
+}
125 src/php/Gradwell/ComponentManager/PhixCommands/PhpLibraryUpgrade.php
@@ -0,0 +1,125 @@
+<?php
+
+/**
+ * Copyright (c) 2010 Gradwell dot com Ltd.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * 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.
+ *
+ * * Neither the name of Gradwell dot com Ltd nor the names of his
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 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.
+ *
+ * @package Gradwell
+ * @subpackage ComponentManager
+ * @author Stuart Herbert <stuart.herbert@gradwell.com>
+ * @copyright 2010 Gradwell dot com Ltd. www.gradwell.com
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @link http://gradwell.github.com
+ * @version @@PACKAGE_VERSION@@
+ */
+
+namespace Gradwell\ComponentManager\PhixCommands;
+
+use Phix_Project\Phix\CommandsList;
+use Phix_Project\Phix\Context;
+use Phix_Project\PhixExtensions\CommandInterface;
+use Gradwell\CommandLineLib\DefinedSwitches;
+use Gradwell\CommandLineLib\DefinedSwitch;
+
+use Gradwell\ComponentManager\Entities\LibraryComponentFolder;
+
+if (!class_exists('Gradwell\ComponentManager\PhixCommands\PhpLibraryUpgrade'))
+{
+class PhpLibraryUpgrade extends ComponentCommandBase implements CommandInterface
+{
+ public function getCommandName()
+ {
+ return 'php-library:upgrade';
+ }
+
+ public function getCommandDesc()
+ {
+ return 'upgrade the structure of a php-library component to the latest version';
+ }
+
+ public function getCommandArgs()
+ {
+ return array
+ (
+ '<folder>' => '<folder> is a path to an existing folder, which you must have permission to write to.',
+ );
+ }
+
+ public function validateAndExecute($args, $argsIndex, Context $context)
+ {
+ $so = $context->stdout;
+ $se = $context->stderr;
+
+ // do we have a folder to init?
+ $errorCode = $this->validateFolder($args, $argsIndex, $context);
+ if ($errorCode !== null)
+ {
+ return $errorCode;
+ }
+ $folder = $args[$argsIndex];
+
+ // has the folder already been initialised?
+ $lib = new LibraryComponentFolder($folder);
+ if ($lib->state != LibraryComponentFolder::STATE_NEEDSUPGRADE)
+ {
+ $se->output($context->errorStyle, $context->errorPrefix);
+
+ // what do we need to tell the user to do?
+ switch ($lib->state)
+ {
+ case LibraryComponentFolder::STATE_UPTODATE:
+ $se->outputLine(null, "folder is already at latest version");
+ break;
+
+ case LibraryComponentFolder::STATE_EMPTY:
+ $se->outputLine(null, "folder is not a php-library");
+ $se->output(null, 'use ');
+ $se->output($context->commandStyle, $context->argvZero . ' php-library:init');
+ $se->outputLine(null, ' to initialise this folder');
+ break;
+
+ default:
+ $se->outputLine(null, 'I do not know what to do with this folder');
+ break;
+ }
+
+ return 1;
+ }
+
+ // if we get here, we have a green light
+ $lib->upgradeComponent();
+
+ // if we get here, it worked (ie, no exception!!)
+ $so->outputLine(null, 'Upgraded php-library component in ' . $folder . ' to the latest version');
+ }
+}
+}
77 src/php/Gradwell/ComponentManager/PhixCommands/PhpLibraryVersion.php
@@ -0,0 +1,77 @@
+<?php
+
+/**
+ * Copyright (c) 2010 Gradwell dot com Ltd.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * 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.
+ *
+ * * Neither the name of Gradwell dot com Ltd nor the names of his
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 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.
+ *
+ * @package Gradwell
+ * @subpackage ComponentManager
+ * @author Stuart Herbert <stuart.herbert@gradwell.com>
+ * @copyright 2010 Gradwell dot com Ltd. www.gradwell.com
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @link http://gradwell.github.com
+ * @version @@PACKAGE_VERSION@@
+ */
+
+namespace Gradwell\ComponentManager\PhixCommands;
+
+use Phix_Project\Phix\Context;
+use Phix_Project\PhixExtensions\CommandInterface;
+
+if (!class_exists('Gradwell\ComponentManager\PhixCommands\PhpLibraryVersion'))
+{
+class PhpLibraryVersion extends ComponentCommandBase implements CommandInterface
+{
+ public function getCommandName()
+ {
+ return 'php-library:version';
+ }
+
+ public function getCommandDesc()
+ {
+ return 'show which version of ComponentManager is installed';
+ }
+
+ public function getCommandArgs()
+ {
+ return array();
+ }
+
+ public function validateAndExecute($args, $argsIndex, Context $context)
+ {
+ $so = $context->stdout;
+ $se = $context->stderr;
+
+ $so->outputLine(null, "@@PACKAGE_VERSION@@");
+ }
+}
+}
31 src/tests/unit-tests/bootstrap.php
@@ -0,0 +1,31 @@
+<?php
+
+// =========================================================================
+//
+// tests/bootstrap.php
+// A helping hand for running our unit tests
+//
+// Author Stuart Herbert
+// (stuart.herbert@gradwell.com)
+//
+// Copyright (c) 2010 Gradwell dot com Ltd
+// All rights reserved
+//
+// =========================================================================
+
+// step 1: create the APP_TOPDIR constant that all MF components require
+define('APP_TOPDIR', realpath(__DIR__ . '/../../php'));
+define('APP_LIBDIR', realpath(__DIR__ . '/../../../vendor/php'));
+define('APP_TESTDIR', realpath(__DIR__ . '/php'));
+
+// step 2: add the lib-vendor code to the include path
+set_include_path(APP_LIBDIR . PATH_SEPARATOR . get_include_path());
+
+// step 3: add the tests folder to the include path
+set_include_path(APP_TESTDIR . PATH_SEPARATOR . get_include_path());
+
+// step 4: add our code to the include path
+set_include_path(APP_TOPDIR . PATH_SEPARATOR . get_include_path());
+
+// step 5: find the autoloader, and install it
+require_once(APP_LIBDIR . '/gwc.autoloader.php');
Please sign in to comment.
Something went wrong with that request. Please try again.