From: Gunnar Wrobel Date: Fri, 14 Jan 2011 14:20:37 +0000 (+0100) Subject: Change the distribution module to using a template directory. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=2da931c860bb558606de97d336028ef252286a14;p=horde.git Change the distribution module to using a template directory. --- diff --git a/components/data/distribute/openpkg/package.spec b/components/data/distribute/openpkg/package.spec new file mode 100644 index 000000000..38e9b831c --- /dev/null +++ b/components/data/distribute/openpkg/package.spec @@ -0,0 +1,2 @@ + - * @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 - * @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 diff --git a/components/lib/Components/Runner/Distribute.php b/components/lib/Components/Runner/Distribute.php index 92af47388..96154fdde 100644 --- a/components/lib/Components/Runner/Distribute.php +++ b/components/lib/Components/Runner/Distribute.php @@ -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) diff --git a/components/package.xml b/components/package.xml index ac789fd14..37fa240b1 100644 --- a/components/package.xml +++ b/components/package.xml @@ -24,8 +24,8 @@ jan@horde.org yes - 2011-01-12 - + 2011-01-14 + 0.0.1 0.0.1 @@ -46,7 +46,15 @@ - + + + + + + + + + @@ -70,7 +78,6 @@ - @@ -117,6 +124,7 @@ + @@ -211,6 +219,18 @@ + + + + + + + + + + + + @@ -237,6 +257,7 @@ + @@ -306,10 +327,12 @@ - + + + @@ -331,7 +354,6 @@ - @@ -359,6 +381,7 @@ + @@ -398,6 +421,10 @@ + + + + @@ -406,6 +433,7 @@ + @@ -422,7 +450,7 @@ alpha alpha - 2011-01-12 + 2011-01-14 LGPL * Initial release diff --git a/components/test/Components/StoryTestCase.php b/components/test/Components/StoryTestCase.php index d93cad3db..670c89185 100644 --- a/components/test/Components/StoryTestCase.php +++ b/components/test/Components/StoryTestCase.php @@ -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 index 000000000..35daf89db --- /dev/null +++ b/components/test/Components/fixture/templates/distribute/openpkg/package.spec @@ -0,0 +1,4 @@ +getName() . '.spec';