From 7ed5ebf4146c5c267b8c0548f08f6c7bee3a8c57 Mon Sep 17 00:00:00 2001 From: Gunnar Wrobel Date: Tue, 11 Jan 2011 06:28:17 +0100 Subject: [PATCH] Replace template rewriting with the template helper. --- components/lib/Components/Runner/CiPrebuild.php | 34 ++++++++++--------------- components/lib/Components/Runner/CiSetup.php | 23 ++++++++--------- 2 files changed, 25 insertions(+), 32 deletions(-) diff --git a/components/lib/Components/Runner/CiPrebuild.php b/components/lib/Components/Runner/CiPrebuild.php index 88025d1d3..4854fe7d4 100644 --- a/components/lib/Components/Runner/CiPrebuild.php +++ b/components/lib/Components/Runner/CiPrebuild.php @@ -81,28 +81,22 @@ class Components_Runner_CiPrebuild ); } - file_put_contents( - $options['ciprebuild'] . DIRECTORY_SEPARATOR . 'build.xml', - sprintf( - file_get_contents( - $this->_config_application->getTemplateDirectory() - . DIRECTORY_SEPARATOR . 'hudson-component-build.xml.template', - 'r' - ), - $options['toolsdir'] - ) + $build_template = new Components_Helper_Templates( + $this->_config_application->getTemplateDirectory() + . DIRECTORY_SEPARATOR . 'hudson-component-build.xml', + $options['ciprebuild'] . DIRECTORY_SEPARATOR . 'build.xml' ); + $build_template->write(array('toolsdir' => $options['toolsdir'])); - file_put_contents( - $options['ciprebuild'] . DIRECTORY_SEPARATOR . 'phpunit.xml', - sprintf( - file_get_contents( - $this->_config_application->getTemplateDirectory() - . DIRECTORY_SEPARATOR . 'hudson-component-phpunit.xml.template', - 'r' - ), - basename($arguments[0]), - strtr(basename($arguments[0]), '_', '/') + $phpunit_template = new Components_Helper_Templates( + $this->_config_application->getTemplateDirectory() + . DIRECTORY_SEPARATOR . 'hudson-component-phpunit.xml', + $options['ciprebuild'] . DIRECTORY_SEPARATOR . 'phpunit.xml' + ); + $phpunit_template->write( + array( + 'testclass' => basename($arguments[0]), + 'testpath' => strtr(basename($arguments[0]), '_', '/') ) ); } diff --git a/components/lib/Components/Runner/CiSetup.php b/components/lib/Components/Runner/CiSetup.php index 732f493e1..46a3e1ad0 100644 --- a/components/lib/Components/Runner/CiSetup.php +++ b/components/lib/Components/Runner/CiSetup.php @@ -92,18 +92,17 @@ class Components_Runner_CiSetup $origin = basename($arguments[0]); } - file_put_contents( - $options['cisetup'] . DIRECTORY_SEPARATOR . 'config.xml', - sprintf( - file_get_contents( - $this->_config_application->getTemplateDirectory() - . DIRECTORY_SEPARATOR . 'hudson-component-config.xml.template', - 'r' - ), - $origin, - 'horde', - $options['toolsdir'], - $this->_factory->createPackageForInstallLocation( + $config_template = new Components_Helper_Templates( + $this->_config_application->getTemplateDirectory() + . DIRECTORY_SEPARATOR . 'hudson-component-config.xml', + $options['cisetup'] . DIRECTORY_SEPARATOR . 'config.xml' + ); + $config_template->write( + array( + 'sourcepath' => $origin, + 'sourcejob' => 'horde', + 'toolsdir' => $options['toolsdir'], + 'description' => $this->_factory->createPackageForInstallLocation( $arguments[0] . DIRECTORY_SEPARATOR . 'package.xml', $options['pearrc'] )->getDescription() -- 2.11.0