}
return $package_file;
}
+
+ /**
+ * Return the contents of the gitignore file.
+ *
+ * @return string The information from the gitignore file.
+ */
+ public function fetchGitIgnore()
+ {
+ return '';
+ }
}
\ No newline at end of file
$package_xml_path,
array(
'packagedirectory' => dirname($package_xml_path),
- 'filelistgenerator' => 'file',
'clearcontents' => false,
'clearchangelog' => false,
'simpleoutput' => true,
- 'ignore' => array('*~', 'conf.php', 'CVS/*'),
- 'include' => '*',
'dir_roles' =>
array(
'bin' => 'script',
private $_filelist_factory;
/**
+ * Provides access to the contents handler.
+ *
+ * @var Components_Pear_Package_Contents_Factory
+ */
+ private $_contents_factory;
+
+ /**
* Constructor.
*
- * @param Components_Pear_Package_Tasks $tasks A tasks helper.
- * @param Components_Pear_Package_Filelist_Factory $factory Creates the filelist handler.
+ * @param Components_Pear_Package_Tasks $tasks A tasks helper.
+ * @param Components_Pear_Package_Filelist_Factory $filelist Creates the filelist handler.
+ * @param Components_Pear_Package_Contents_Factory $contents Creates the contents handler.
*/
public function __construct(
Components_Pear_Package_Tasks $tasks,
- Components_Pear_Package_Filelist_Factory $factory
+ Components_Pear_Package_Filelist_Factory $filelist,
+ Components_Pear_Package_Contents_Factory $contents
) {
$this->_tasks = $tasks;
- $this->_filelist_factory = $factory;
+ $this->_filelist_factory = $filelist;
+ $this->_contents_factory = $contents;
}
/**
}
/**
- * Generate an updated contents listing.
- *
- * @return NULL
- */
- private function _generateContents()
- {
- $this->getPackage()->generateContents();
- }
-
- /**
* Return an updated package description.
*
* @return PEAR_PackageFileManager2 The updated package.
public function update()
{
$taskfiles = $this->_tasks->denote($this->getPackage());
- $this->_generateContents();
+
+ $generator = $this->_contents_factory->create($this->getPackage());
+ $this->getPackage()->clearContents('/');
+ $this->getPackage()->_struc = $generator->getFileList();
+ $this->getPackage()->_getSimpleDirTag($this->getPackage()->_struc);
+
$this->_tasks->annotate($this->getPackage(), $taskfiles);
$this->_filelist_factory->create($this->getPackage())->update();
--- /dev/null
+<?php
+/**
+ * Components_Pear_Package_Contents_Factory:: handles the different contents
+ * list generators.
+ *
+ * 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_Pear_Package_Contents_Factory:: handles the different content list
+ * generators.
+ *
+ * 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 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_Pear_Package_Contents_Factory
+{
+ /**
+ * Create the contents handler.
+ *
+ * @param PEAR_PackageFile_v2_rw $package The package.
+ *
+ * @return Components_Pear_Package_Contents_List The content handler.
+ */
+ public function create(PEAR_PackageFile_v2_rw $package)
+ {
+ $root = new Components_Helper_Root(
+ $package->_options['packagedirectory']
+ );
+ return new Components_Pear_Package_Contents_List(
+ $package->_options['packagedirectory'],
+ new Components_Pear_Package_Contents_Ignore(
+ $root->fetchGitIgnore()
+ )
+ );
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+/**
+ * Components_Pear_Package_Contents_Ignore:: indicates which files in
+ * a content listing should be ignored.
+ *
+ * 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_Pear_Package_Contents_Ignore:: indicates which files in
+ * a content listing should be ignored.
+ *
+ * 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 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_Pear_Package_Contents_Ignore
+{
+ /**
+ * The gitignore information.
+ *
+ * @var string
+ */
+ private $_gitignore;
+
+ /**
+ * Constructor.
+ *
+ * @param string $gitignore The gitignore information
+ */
+ public function __construct($gitignore)
+ {
+ $this->_gitignore = $gitignore;
+ }
+
+ /**
+ * Tell whether to ignore a file or a directory
+ * allows * and ? wildcards
+ *
+ * @param string $file just the file name of the file or directory,
+ * in the case of directories this is the last dir
+ * @param string $path the full path
+ * @param bool $return value to return if regexp matches. Set this to
+ * false to include only matches, true to exclude
+ * all matches
+ *
+ * @return bool true if $path should be ignored, false if it should not
+ * @access private
+ */
+ public function checkIgnore($file, $path, $return = 1)
+ {
+ return !$return;
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+/**
+ * Components_Pear_Package_Contents_List:: is the default content handler for
+ * packages.
+ *
+ * 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_Pear_Package_Contents_List:: is the default content handler for
+ * packages.
+ *
+ * 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 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_Pear_Package_Contents_List
+extends PEAR_PackageFileManager_File
+{
+ /**
+ * Determines if a file should be ignored.
+ *
+ * @var Components_Pear_Package_Contents_Ignore
+ */
+ private $_ignore;
+
+ /**
+ * Constructor.
+ *
+ * @param string $package_directory The directory of the package.
+ * @param Components_Pear_Package_Contents_Ignore $ignore Ignores files.
+ */
+ public function __construct(
+ $package_directory, Components_Pear_Package_Contents_Ignore $ignore
+ ) {
+ $this->_ignore = $ignore;
+ $this->_options['packagedirectory'] = $package_directory;
+ $this->_options['include'] = '*';
+ $this->_options['ignore'] = array('*~', 'conf.php', 'CVS/*');
+ $this->_options['packagefile'] = 'package.xml';
+ $this->_options['addhiddenfiles'] = false;
+ }
+
+ /**
+ * Tell whether to ignore a file or a directory
+ * allows * and ? wildcards
+ *
+ * @param string $file just the file name of the file or directory,
+ * in the case of directories this is the last dir
+ * @param string $path the full path
+ * @param bool $return value to return if regexp matches. Set this to
+ * false to include only matches, true to exclude
+ * all matches
+ *
+ * @return bool true if $path should be ignored, false if it should not
+ * @access private
+ */
+ function _checkIgnore($file, $path, $return = 1)
+ {
+ $result = parent::_checkIgnore($file, $path, $return);
+ if ($result == $return) {
+ return $result;
+ } else {
+ return $this->_ignore->checkIgnore($file, $path, $return);
+ }
+ }
+}
\ No newline at end of file