Change the distribution module to using a template directory.
authorGunnar Wrobel <p@rdus.de>
Fri, 14 Jan 2011 14:20:37 +0000 (15:20 +0100)
committerGunnar Wrobel <p@rdus.de>
Fri, 14 Jan 2011 14:20:37 +0000 (15:20 +0100)
components/data/distribute/openpkg/package.spec [new file with mode: 0644]
components/data/distribute_package.spec [deleted file]
components/lib/Components/Helper/Templates/Prefix.php [deleted file]
components/lib/Components/Runner/Distribute.php
components/package.xml
components/test/Components/StoryTestCase.php
components/test/Components/fixture/templates/distribute/openpkg/package.spec [new file with mode: 0644]

diff --git a/components/data/distribute/openpkg/package.spec b/components/data/distribute/openpkg/package.spec
new file mode 100644 (file)
index 0000000..38e9b83
--- /dev/null
@@ -0,0 +1,2 @@
+<?php
+echo 'DONE';
diff --git a/components/data/distribute_package.spec b/components/data/distribute_package.spec
deleted file mode 100644 (file)
index 38e9b83..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-<?php
-echo 'DONE';
diff --git a/components/lib/Components/Helper/Templates/Prefix.php b/components/lib/Components/Helper/Templates/Prefix.php
deleted file mode 100644 (file)
index b1913d5..0000000
+++ /dev/null
@@ -1,94 +0,0 @@
-<?php
-/**
- * Components_Helper_Templates_Single:: converts a single template file into a
- * target file.
- *
- * PHP version 5
- *
- * @category Horde
- * @package  Components
- * @author   Gunnar Wrobel <wrobel@pardus.de>
- * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link     http://pear.horde.org/index.php?package=Components
- */
-
-/**
- * Components_Helper_Templates_Single:: converts a single template file into a
- * target file.
- *
- * Copyright 2011 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  Components
- * @author   Gunnar Wrobel <wrobel@pardus.de>
- * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link     http://pear.horde.org/index.php?package=Components
- */
-class Components_Helper_Templates_Prefix
-extends Components_Helper_Templates
-{
-    /**
-     * The source location.
-     *
-     * @var string
-     */
-    private $_source;
-
-    /**
-     * The target location.
-     *
-     * @var string
-     */
-    private $_target;
-
-    /**
-     * Constructor.
-     *
-     * @param string $sdir  The templates source directory.
-     * @param string $tdir  The templates target directory.
-     * @param string $sfile The exact template source file.
-     * @param string $tfile The exact template target file.
-     */
-    public function __construct($sdir, $tdir, $prefix, $tfile)
-    {
-        $template = null;
-        foreach (
-            new RecursiveIteratorIterator(
-                new RecursiveDirectoryIterator($sdir),
-                RecursiveIteratorIterator::CHILD_FIRST
-            )
-            as $file
-        ) {
-            if (strpos($file->getBasename(), $prefix) === 0) {
-                $template = $file;
-                break;
-            }
-        }
-        if (empty($template)) {
-            throw new Components_Exception(
-                sprintf(
-                    'No packaging template starting with "%s" was found in the template directory %s!',
-                    $prefix,
-                    $sdir
-                )
-            );
-        }
-        $this->_source = $template->getPathname();
-        $this->_target = $tdir . DIRECTORY_SEPARATOR . $tfile;
-    }
-
-    /**
-     * Rewrite the template(s) from the source(s) to the target location(s).
-     *
-     * @param array  $parameters The template(s) parameters.
-     *
-     * @return NULL
-     */
-    public function write(array $parameters = array())
-    {
-        $this->writeSourceToTarget($this->_source, $this->_target, $parameters);
-    }
-}
\ No newline at end of file
index 92af473..96154fd 100644 (file)
@@ -88,11 +88,9 @@ class Components_Runner_Distribute
         $version = $package->getVersion() . 'dev' . strftime('%Y%m%d%H%M');
         $package->generateSnapshot($version, dirname($options['distribute']));
 
-        $build_template = new Components_Helper_Templates_Prefix(
+        $build_template = new Components_Helper_Templates_Directory(
             $this->_config_application->getTemplateDirectory(),
-            dirname($options['distribute']),
-            'distribute_',
-            basename($options['distribute'])
+            $options['distribute']
         );
         $build_template->write(
             array('package' => $package, 'version' => $version)
index ac789fd..37fa240 100644 (file)
@@ -24,8 +24,8 @@
   <email>jan@horde.org</email>
   <active>yes</active>
  </lead>
- <date>2011-01-12</date>
- <time>10:29:42</time>
+ <date>2011-01-14</date>
+ <time>15:17:04</time>
  <version>
   <release>0.0.1</release>
   <api>0.0.1</api>
     </file>
    </dir> <!-- /bin -->
    <dir name="data">
-    <file name="distribute_package.spec" role="data" />
+    <dir name="distribute">
+     <dir name="openpkg">
+      <file name="package.spec" role="data" />
+     </dir> <!-- /data/distribute/openpkg -->
+    </dir> <!-- /data/distribute -->
+    <dir name="html">
+     <file name="index.html" role="doc" />
+     <file name="install.html" role="doc" />
+    </dir> <!-- /data/html -->
     <file name="hudson-component-build.xml.template" role="data" />
     <file name="hudson-component-config.xml.template" role="data" />
     <file name="hudson-component-phpunit.xml.template" role="data" />
@@ -70,7 +78,6 @@
       </dir> <!-- /lib/Components/Helper/Template -->
       <dir name="Templates">
        <file name="Directory.php" role="php" />
-       <file name="Prefix.php" role="php" />
        <file name="Single.php" role="php" />
       </dir> <!-- /lib/Components/Helper/Templates -->
       <file name="InstallationRun.php" role="php" />
       <file name="Dependencies.php" role="php" />
       <file name="DevPackage.php" role="php" />
       <file name="Distribute.php" role="php" />
+      <file name="Document.php" role="php" />
       <file name="Installer.php" role="php" />
       <file name="PearPackageXml.php" role="php" />
      </dir> <!-- /lib/Components/Runner -->
         <file name="one" role="test" />
         <file name="two" role="test" />
        </dir> <!-- /test/Components/fixture/templates/dir -->
+       <dir name="distribute">
+        <dir name="openpkg">
+         <file name="package.spec" role="test" />
+        </dir> <!-- /test/Components/fixture/templates/distribute/openpkg -->
+       </dir> <!-- /test/Components/fixture/templates/distribute -->
+       <dir name="html">
+        <file name="index.html" role="test" />
+        <file name="install.html" role="test" />
+       </dir> <!-- /test/Components/fixture/templates/html -->
+       <dir name="rewrite">
+        <file name="one" role="test" />
+       </dir> <!-- /test/Components/fixture/templates/rewrite -->
        <file name="hudson-component-build.xml.template" role="test" />
        <file name="hudson-component-config.xml.template" role="test" />
        <file name="hudson-component-phpunit.xml.template" role="test" />
      <dir name="Unit">
       <dir name="Components">
        <dir name="Helper">
+        <file name="rewritten" role="test" />
         <file name="TemplatesTest.php" role="test" />
        </dir> <!-- /test/Components/Unit/Components/Helper -->
        <dir name="Pear">
  <phprelease>
   <filelist>
    <install as="horde-components" name="bin/horde-components" />
-   <install as="distribute_package.spec" name="data/distribute_package.spec" />
    <install as="hudson-component-build.xml.template" name="data/hudson-component-build.xml.template" />
    <install as="hudson-component-config.xml.template" name="data/hudson-component-config.xml.template" />
    <install as="hudson-component-phpunit.xml.template" name="data/hudson-component-phpunit.xml.template" />
+   <install as="distribute/openpkg/package.spec" name="data/distribute/openpkg/package.spec" />
+   <install as="html/index.html" name="data/html/index.html" />
+   <install as="html/install.html" name="data/html/install.html" />
    <install as="Components.php" name="lib/Components.php" />
    <install as="Components/Config.php" name="lib/Components/Config.php" />
    <install as="Components/Configs.php" name="lib/Components/Configs.php" />
    <install as="Components/Helper/Template/Php.php" name="lib/Components/Helper/Template/Php.php" />
    <install as="Components/Helper/Template/Printf.php" name="lib/Components/Helper/Template/Printf.php" />
    <install as="Components/Helper/Templates/Directory.php" name="lib/Components/Helper/Templates/Directory.php" />
-   <install as="Components/Helper/Templates/Prefix.php" name="lib/Components/Helper/Templates/Prefix.php" />
    <install as="Components/Helper/Templates/Single.php" name="lib/Components/Helper/Templates/Single.php" />
    <install as="Components/Module/Base.php" name="lib/Components/Module/Base.php" />
    <install as="Components/Module/CiSetup.php" name="lib/Components/Module/CiSetup.php" />
    <install as="Components/Runner/Dependencies.php" name="lib/Components/Runner/Dependencies.php" />
    <install as="Components/Runner/DevPackage.php" name="lib/Components/Runner/DevPackage.php" />
    <install as="Components/Runner/Distribute.php" name="lib/Components/Runner/Distribute.php" />
+   <install as="Components/Runner/Document.php" name="lib/Components/Runner/Document.php" />
    <install as="Components/Runner/Installer.php" name="lib/Components/Runner/Installer.php" />
    <install as="Components/Runner/PearPackageXml.php" name="lib/Components/Runner/PearPackageXml.php" />
    <install as="Components/AllTests.php" name="test/Components/AllTests.php" />
    <install as="Components/fixture/templates/variables.template" name="test/Components/fixture/templates/variables.template" />
    <install as="Components/fixture/templates/dir/one" name="test/Components/fixture/templates/dir/one" />
    <install as="Components/fixture/templates/dir/two" name="test/Components/fixture/templates/dir/two" />
+   <install as="Components/fixture/templates/distribute/openpkg/package.spec" name="test/Components/fixture/templates/distribute/openpkg/package.spec" />
+   <install as="Components/fixture/templates/html/index.html" name="test/Components/fixture/templates/html/index.html" />
+   <install as="Components/fixture/templates/html/install.html" name="test/Components/fixture/templates/html/install.html" />
+   <install as="Components/fixture/templates/rewrite/one" name="test/Components/fixture/templates/rewrite/one" />
    <install as="Components/Integration/ComponentsTest.php" name="test/Components/Integration/ComponentsTest.php" />
    <install as="Components/Integration/Components/Module/CiSetupTest.php" name="test/Components/Integration/Components/Module/CiSetupTest.php" />
    <install as="Components/Integration/Components/Module/DependenciesTest.php" name="test/Components/Integration/Components/Module/DependenciesTest.php" />
    <install as="Components/Integration/Components/Module/DocumentTest.php" name="test/Components/Integration/Components/Module/DocumentTest.php" />
    <install as="Components/Integration/Components/Module/InstallerTest.php" name="test/Components/Integration/Components/Module/InstallerTest.php" />
    <install as="Components/Integration/Components/Module/PearPackageXmlTest.php" name="test/Components/Integration/Components/Module/PearPackageXmlTest.php" />
+   <install as="Components/Unit/Components/Helper/rewritten" name="test/Components/Unit/Components/Helper/rewritten" />
    <install as="Components/Unit/Components/Helper/TemplatesTest.php" name="test/Components/Unit/Components/Helper/TemplatesTest.php" />
    <install as="Components/Unit/Components/Pear/Package/Filelist/DefaultTest.php" name="test/Components/Unit/Components/Pear/Package/Filelist/DefaultTest.php" />
    <install as="COPYING" name="COPYING" />
     <release>alpha</release>
     <api>alpha</api>
    </stability>
-   <date>2011-01-12</date>
+   <date>2011-01-14</date>
    <license uri="http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html">LGPL</license>
    <notes>
 * Initial release
index d93cad3..670c891 100644 (file)
@@ -295,7 +295,8 @@ extends PHPUnit_Extensions_Story_TestCase
         case 'calling the package with the distribute option and a path to a Horde framework component':
             $_SERVER['argv'] = array(
                 'horde-components',
-                '--distribute=' . $this->_getTemporaryDirectory() . '/package.spec',
+                '--templatedir=' . dirname(__FILE__) . '/fixture/templates/distribute/openpkg',
+                '--distribute=' . $this->_getTemporaryDirectory(),
                 dirname(__FILE__) . '/fixture/framework/Install'
             );
             $world['output'] = $this->_callUnstrictComponents();
@@ -620,7 +621,7 @@ extends PHPUnit_Extensions_Story_TestCase
             $this->assertTrue(
                 file_exists(
                     $this->_temp_dir . DIRECTORY_SEPARATOR
-                    . 'package.spec'
+                    . 'Install.spec'
                 )
             );
             break;
diff --git a/components/test/Components/fixture/templates/distribute/openpkg/package.spec b/components/test/Components/fixture/templates/distribute/openpkg/package.spec
new file mode 100644 (file)
index 0000000..35daf89
--- /dev/null
@@ -0,0 +1,4 @@
+<?php
+echo 'DONE';
+
+$target = $package->getName() . '.spec';