From: Gunnar Wrobel Date: Tue, 24 Aug 2010 19:06:25 +0000 (+0200) Subject: Add a module for generating a development snapshot of a PEAR package. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=9feaaa4794423fe681c2c72c06360bb45d288ec8;p=horde.git Add a module for generating a development snapshot of a PEAR package. The package will have the version number provided in package.xml but appended with a timestamp (201008242106). --- diff --git a/framework/Element/lib/Horde/Element/Module/DevPackage.php b/framework/Element/lib/Horde/Element/Module/DevPackage.php new file mode 100644 index 000000000..259d5ea67 --- /dev/null +++ b/framework/Element/lib/Horde/Element/Module/DevPackage.php @@ -0,0 +1,82 @@ + + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Element + */ + +/** + * Horde_Element_Module_DevPackage:: generates a development snapshot for the + * specified package. + * + * Copyright 2010 The Horde Project (http://www.horde.org/) + * + * See the enclosed file COPYING for license information (LGPL). If you + * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. + * + * @category Horde + * @package Element + * @author Gunnar Wrobel + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Element + */ +class Horde_Element_Module_DevPackage +implements Horde_Element_Module +{ + public function getOptionGroupTitle() + { + return 'Development Packages'; + } + + public function getOptionGroupDescription() + { + return 'This module generates a development snapshot for the specified package'; + } + + public function getOptionGroupOptions() + { + return array( + new Horde_Argv_Option( + '-d', + '--devpackage', + array( + 'action' => 'store_true', + 'help' => 'generate a development snapshot' + ) + ), + ); + } + + public function handle(Horde_Element_Config $config) + { + $options = $config->getOptions(); + if (!empty($options['devpackage'])) { + $this->run($config); + } + } + + public function run(Horde_Element_Config $config) + { + $options = $config->getOptions(); + + $pear = new PEAR(); + $pear->setErrorHandling(PEAR_ERROR_DIE); + + $arguments = $config->getArguments(); + $pkgfile = $arguments[0] . DIRECTORY_SEPARATOR . 'package.xml'; + + $pkg = new PEAR_PackageFile(new PEAR_Config()); + $pf = $pkg->fromPackageFile($pkgfile, PEAR_VALIDATE_NORMAL); + $pf->_packageInfo['version']['release'] = $pf->getVersion() + . 'dev' . strftime('%Y%m%d%H%M'); + $gen = $pf->getDefaultGenerator(); + $tgzfile = $gen->toTgz(new PEAR_Common()); + } +} diff --git a/framework/Element/package.xml b/framework/Element/package.xml index e26c7a597..18e48260e 100644 --- a/framework/Element/package.xml +++ b/framework/Element/package.xml @@ -47,6 +47,7 @@ + @@ -126,6 +127,7 @@ + diff --git a/framework/Element/test/Horde/Element/Integration/ElementTest.php b/framework/Element/test/Horde/Element/Integration/ElementTest.php index 8c667df68..9d461db63 100644 --- a/framework/Element/test/Horde/Element/Integration/ElementTest.php +++ b/framework/Element/test/Horde/Element/Integration/ElementTest.php @@ -68,6 +68,16 @@ extends Horde_Element_StoryTestCase /** * @scenario */ + public function theDevpackageModuleAddsTheDOptionInTheHelpOutput() + { + $this->given('the default Element setup') + ->when('calling the package with the help option') + ->then('the help will contain the "d" option.'); + } + + /** + * @scenario + */ public function theThePOptionProvidesAnUpdatedPackageXml() { $this->given('the default Element setup') diff --git a/framework/Element/test/Horde/Element/StoryTestCase.php b/framework/Element/test/Horde/Element/StoryTestCase.php index 9059466a2..4d05428ab 100644 --- a/framework/Element/test/Horde/Element/StoryTestCase.php +++ b/framework/Element/test/Horde/Element/StoryTestCase.php @@ -146,6 +146,12 @@ extends PHPUnit_Extensions_Story_TestCase $world['output'] ); break; + case 'the help will contain the "d" option.': + $this->assertRegExp( + '/-d,\s*--devpackage/', + $world['output'] + ); + break; case 'the help will contain the "i" option.': $this->assertRegExp( '/-i\s*INSTALL,\s*--install=INSTALL/',