Replace template rewriting with the template helper.
authorGunnar Wrobel <p@rdus.de>
Tue, 11 Jan 2011 05:28:17 +0000 (06:28 +0100)
committerGunnar Wrobel <p@rdus.de>
Tue, 11 Jan 2011 05:28:17 +0000 (06:28 +0100)
components/lib/Components/Runner/CiPrebuild.php
components/lib/Components/Runner/CiSetup.php

index 88025d1..4854fe7 100644 (file)
@@ -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]), '_', '/')
             )
         );
     }
index 732f493..46a3e1a 100644 (file)
@@ -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()