Add a module for generating a development snapshot of a PEAR package.
authorGunnar Wrobel <p@rdus.de>
Tue, 24 Aug 2010 19:06:25 +0000 (21:06 +0200)
committerGunnar Wrobel <p@rdus.de>
Tue, 24 Aug 2010 19:06:25 +0000 (21:06 +0200)
The package will have the version number provided in package.xml but
appended with a timestamp (201008242106).

framework/Element/lib/Horde/Element/Module/DevPackage.php [new file with mode: 0644]
framework/Element/package.xml
framework/Element/test/Horde/Element/Integration/ElementTest.php
framework/Element/test/Horde/Element/StoryTestCase.php

diff --git a/framework/Element/lib/Horde/Element/Module/DevPackage.php b/framework/Element/lib/Horde/Element/Module/DevPackage.php
new file mode 100644 (file)
index 0000000..259d5ea
--- /dev/null
@@ -0,0 +1,82 @@
+<?php
+/**
+ * Horde_Element_Module_DevPackage:: generates a development snapshot for the
+ * specified package.
+ *
+ * PHP version 5
+ *
+ * @category Horde
+ * @package  Element
+ * @author   Gunnar Wrobel <wrobel@pardus.de>
+ * @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 <wrobel@pardus.de>
+ * @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());
+    }
+}
index e26c7a5..18e4826 100644 (file)
@@ -47,6 +47,7 @@
        <file name="Cli.php" role="php" />
       </dir> <!-- /lib/Horde/Element/Config -->
       <dir name="Module">
+       <file name="DevPackage.php" role="php" />
        <file name="Installer.php" role="php" />
        <file name="PearPackageXml.php" role="php" />
       </dir> <!-- /lib/Horde/Element/Module -->
    <install as="Horde/Element/Module.php" name="lib/Horde/Element/Module.php" />
    <install as="Horde/Element/Modules.php" name="lib/Horde/Element/Modules.php" />
    <install as="Horde/Element/Config/Cli.php" name="lib/Horde/Element/Config/Cli.php" />
+   <install as="Horde/Element/Module/DevPackage.php" name="lib/Horde/Element/Module/DevPackage.php" />
    <install as="Horde/Element/Module/Installer.php" name="lib/Horde/Element/Module/Installer.php" />
    <install as="Horde/Element/Module/PearPackageXml.php" name="lib/Horde/Element/Module/PearPackageXml.php" />
    <install as="horde-element" name="script/horde-element.php" />
index 8c667df..9d461db 100644 (file)
@@ -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')
index 9059466..4d05428 100644 (file)
@@ -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/',