From a8ec11e72701a0fb18b3861defaf1ef81715242c Mon Sep 17 00:00:00 2001
From: Gunnar Wrobel
Date: Wed, 24 Feb 2010 13:34:47 +0100
Subject: [PATCH] Renamed Horde_Packaging to Horde_Qc and started reorganzing
into classes/modules.
---
framework/Packaging/lib/Horde/Packaging/Cli.php | 1 -
framework/Packaging/script/horde-pear-release.php | 107 ---------------------
framework/{Packaging => Qc}/COPYING | 0
framework/Qc/lib/Horde/Qc/Config.php | 33 +++++++
framework/Qc/lib/Horde/Qc/Config/Cli.php | 82 ++++++++++++++++
framework/Qc/lib/Horde/Qc/Config/Interface.php | 33 +++++++
framework/Qc/lib/Horde/Qc/Module.php | 34 +++++++
.../Qc/lib/Horde/Qc/Module/PearPackageXml.php | 44 +++++++++
framework/{Packaging => Qc}/package.xml | 16 +--
framework/Qc/test/Horde/Qc/AllTests.php | 38 ++++++++
10 files changed, 274 insertions(+), 114 deletions(-)
delete mode 100644 framework/Packaging/lib/Horde/Packaging/Cli.php
delete mode 100755 framework/Packaging/script/horde-pear-release.php
rename framework/{Packaging => Qc}/COPYING (100%)
create mode 100644 framework/Qc/lib/Horde/Qc/Config.php
create mode 100644 framework/Qc/lib/Horde/Qc/Config/Cli.php
create mode 100644 framework/Qc/lib/Horde/Qc/Config/Interface.php
create mode 100644 framework/Qc/lib/Horde/Qc/Module.php
create mode 100644 framework/Qc/lib/Horde/Qc/Module/PearPackageXml.php
rename framework/{Packaging => Qc}/package.xml (81%)
create mode 100644 framework/Qc/test/Horde/Qc/AllTests.php
diff --git a/framework/Packaging/lib/Horde/Packaging/Cli.php b/framework/Packaging/lib/Horde/Packaging/Cli.php
deleted file mode 100644
index b3d9bbc7f..000000000
--- a/framework/Packaging/lib/Horde/Packaging/Cli.php
+++ /dev/null
@@ -1 +0,0 @@
- 'store_true')
- ),
-);
-$parser = new Horde_Argv_Parser(
- array(
- 'optionList' => $options,
- 'usage' => '%prog ' . _("[options] PACKAGE_PATH")
- )
-);
-list($opts, $args) = $parser->parseArgs();
-
-if (empty($args[0])) {
- echo "Please specify the path to the package you want to release!\n\n";
- $parser->printUsage(STDERR);
- exit(1);
-}
-
-$package_path = $args[0];
-if (!is_dir($package_path)) {
- printf("%s specifies no directory!\n", $package_path);
- exit(1);
-}
-
-$package_file = $package_path . '/package.xml';
-
-if (!file_exists($package_file)) {
- printf("There is no package.xml at %s!\n", $package_path);
- exit(1);
-}
-
-$package = PEAR_PackageFileManager2::importOptions(
- $package_file,
- array(
- 'packagedirectory' => $package_path,
- 'filelistgenerator' => 'file',
- 'clearcontents' => false,
- 'clearchangelog' => false,
- 'simpleoutput' => true,
- 'ignore' => array('*~', 'conf.php', 'CVS/*'),
- 'include' => '*',
- 'dir_roles' =>
- array(
- 'lib' => 'php',
- 'doc' => 'doc',
- 'example' => 'doc',
- 'script' => 'script',
- 'test' => 'test',
- 'migration' => 'data',
- ),
- )
-);
-
-$package->generateContents();
-
-/**
- * This is required to clear the
- * section.
- */
-$package->setPackageType('php');
-
-$contents = $package->getContents();
-$files = $contents['dir']['file'];
-
-foreach ($files as $file) {
- $components = explode('/', $file['attribs']['name'], 2);
- switch ($components[0]) {
- case 'doc':
- case 'example':
- case 'lib':
- case 'test':
- $package->addInstallAs(
- $file['attribs']['name'], $components[1]
- );
- break;
- case 'migration':
- $components = explode('/', $components[1]);
- array_splice($components, count($components) - 1, 0, 'migration');
- $package->addInstallAs(
- $file['attribs']['name'], implode('/', $components)
- );
- break;
- case 'script':
- $filename = basename($file['attribs']['name']);
- if (substr($filename, strlen($filename) - 4)) {
- $filename = substr($filename, 0, strlen($filename) - 4);
- }
- $package->addInstallAs(
- $file['attribs']['name'], $filename
- );
- break;
- }
-}
-
-if (!empty($opts['update_packagexml'])) {
- $package->writePackageFile();
-} else {
- $package->debugPackageFile();
-}
diff --git a/framework/Packaging/COPYING b/framework/Qc/COPYING
similarity index 100%
rename from framework/Packaging/COPYING
rename to framework/Qc/COPYING
diff --git a/framework/Qc/lib/Horde/Qc/Config.php b/framework/Qc/lib/Horde/Qc/Config.php
new file mode 100644
index 000000000..267d24789
--- /dev/null
+++ b/framework/Qc/lib/Horde/Qc/Config.php
@@ -0,0 +1,33 @@
+
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Qc
+ */
+
+/**
+ * Horde_Qc_Config:: class represents configuration for the Horde quality
+ * control tool.
+ *
+ * Copyright 2009-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 Qc
+ * @author Gunnar Wrobel
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Qc
+erver
+ */
+abstract class Horde_Qc_Config
+{
+}
\ No newline at end of file
diff --git a/framework/Qc/lib/Horde/Qc/Config/Cli.php b/framework/Qc/lib/Horde/Qc/Config/Cli.php
new file mode 100644
index 000000000..c14ec1bd3
--- /dev/null
+++ b/framework/Qc/lib/Horde/Qc/Config/Cli.php
@@ -0,0 +1,82 @@
+
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Qc
+ */
+
+/**
+ * Horde_Qc_Config_Cli:: class provides the command line interface for the Horde
+ * quality control tool.
+ *
+ * Copyright 2009-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 Qc
+ * @author Gunnar Wrobel
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Qc
+erver
+ */
+class Horde_Qc_Config_Cli
+implements Horde_Qc_Config_Interface
+{
+
+ private $_parser;
+
+ private $_opts;
+
+ private $_args;
+
+ /**
+ * Constructor.
+ *
+ * @param Horde_Qc_Modules $modules A list of modules.
+ */
+ public function __construct(Horde_Modules $modules)
+ {
+ $options = array();
+
+ foreach ($modules as $module) {
+ $options = array_merge($options, $module->getOptions());
+ }
+
+ $this->_parser = new Horde_Argv_Parser(
+ array(
+ 'optionList' => array_values($options),
+ 'usage' => '%prog ' . _("[options] PACKAGE_PATH")
+ )
+ );
+ list($this->_opts, $this->_args) = $parser->parseArgs();
+ $this->_validate();
+
+ foreach ($modules as $module) {
+ $module->validateOptions($this->_opts, $this->_args);
+ }
+ }
+
+ private function _validate()
+ {
+ if (empty($this->_args[0])) {
+ print "Please specify the path to the package you want to release!\n\n";
+ $this->_parser->printUsage(STDERR);
+ exit(1);
+ }
+
+ if (!is_dir($this->_args[0])) {
+ print sprintf("%s specifies no directory!\n", $this->_args[0]);
+ exit(1);
+ }
+ }
+
+}
diff --git a/framework/Qc/lib/Horde/Qc/Config/Interface.php b/framework/Qc/lib/Horde/Qc/Config/Interface.php
new file mode 100644
index 000000000..bf0bfeb67
--- /dev/null
+++ b/framework/Qc/lib/Horde/Qc/Config/Interface.php
@@ -0,0 +1,33 @@
+
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Qc
+ */
+
+/**
+ * Horde_Qc_Config_Interface:: represents configuration for the Horde quality
+ * control tool.
+ *
+ * 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 Qc
+ * @author Gunnar Wrobel
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Qc
+erver
+ */
+interface Horde_Qc_Config_Interface
+{
+}
\ No newline at end of file
diff --git a/framework/Qc/lib/Horde/Qc/Module.php b/framework/Qc/lib/Horde/Qc/Module.php
new file mode 100644
index 000000000..b2868f0b4
--- /dev/null
+++ b/framework/Qc/lib/Horde/Qc/Module.php
@@ -0,0 +1,34 @@
+
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Qc
+ */
+
+/**
+ * Horde_Qc_Module:: interface represents a single quality control module.
+ *
+ * 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 Qc
+ * @author Gunnar Wrobel
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Qc
+erver
+ */
+interface Horde_Qc_Module
+{
+ public function getOptions();
+
+ public function validateOptions(array $options, array $arguments);
+}
\ No newline at end of file
diff --git a/framework/Qc/lib/Horde/Qc/Module/PearPackageXml.php b/framework/Qc/lib/Horde/Qc/Module/PearPackageXml.php
new file mode 100644
index 000000000..dcbcde130
--- /dev/null
+++ b/framework/Qc/lib/Horde/Qc/Module/PearPackageXml.php
@@ -0,0 +1,44 @@
+
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Qc
+ */
+
+/**
+ * Horde_Qc_Module:: interface represents a single quality control module.
+ *
+ * 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 Qc
+ * @author Gunnar Wrobel
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Qc
+ */
+interface Horde_Qc_Module
+{
+ public function getOptions()
+ {
+ return array(
+ new Horde_Argv_Option(
+ '-u',
+ '--update-packagexml',
+ array('action' => 'store_true')
+ )
+ );
+ }
+
+ public function validateOptions(array $options, array $arguments)
+ {
+ }
+}
diff --git a/framework/Packaging/package.xml b/framework/Qc/package.xml
similarity index 81%
rename from framework/Packaging/package.xml
rename to framework/Qc/package.xml
index 65c367d4f..e4452dd35 100644
--- a/framework/Packaging/package.xml
+++ b/framework/Qc/package.xml
@@ -1,6 +1,6 @@
- Packaging
+ Qc
pear.horde.org
A package for preparing Horde PEAR releases.
The package provides utility methods usually required
@@ -42,9 +42,12 @@
-
-
-
+
+
+
+
+
+
@@ -73,8 +76,9 @@
-
-
+
+
+
diff --git a/framework/Qc/test/Horde/Qc/AllTests.php b/framework/Qc/test/Horde/Qc/AllTests.php
new file mode 100644
index 000000000..ad3f9c508
--- /dev/null
+++ b/framework/Qc/test/Horde/Qc/AllTests.php
@@ -0,0 +1,38 @@
+
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Qc
+ */
+
+/**
+ * Define the main method
+ */
+if (!defined('PHPUnit_MAIN_METHOD')) {
+ define('PHPUnit_MAIN_METHOD', 'Horde_Qc_AllTests::main');
+}
+
+/**
+ * Prepare the test setup.
+ */
+require_once 'Horde/Test/AllTests.php';
+
+/**
+ * @package Horde_Qc
+ * @subpackage UnitTests
+ */
+class Horde_Qc_AllTests extends Horde_Test_AllTests
+{
+}
+
+Horde_Qc_AllTests::init('Horde_Qc', __FILE__);
+
+if (PHPUnit_MAIN_METHOD == 'Horde_Qc_AllTests::main') {
+ Horde_Qc_AllTests::main();
+}
--
2.11.0