protected function findFiles() { $ds = new DirectoryScanner(); $ds->setBasedir($this->dir); $ds->setIncludes(array('**/composer.json')); $ds->scan(); return $ds->getIncludedFiles(); }
/** * Returns the excluded files * * @return array */ public function getExcludedFiles() { $includes = array(); foreach ($this->files as $file) { $includes[] = $file->getName(); } $this->directoryScanner->setIncludes($includes); $this->directoryScanner->scan(); $files = $this->directoryScanner->getIncludedFiles(); $dir = $this->directoryScanner->getBasedir(); $fileList = array(); foreach ($files as $file) { $fileList[] = $dir . DIRECTORY_SEPARATOR . $file; } return $fileList; }
protected function findSplits() { $this->log("checking heads for subsplits"); $repo = $this->getRepository(); $base = $this->getBase(); $splits = array(); $heads = $this->getHeads(); if (!empty($base)) { $base = '/' . ltrim($base, '/'); } else { $base = '/'; } chdir($repo . '/.subsplit'); foreach ($heads as $head) { $splits[$head] = array(); passthru("git checkout '{$head}'"); $ds = new DirectoryScanner(); $ds->setBasedir($repo . '/.subsplit' . $base); $ds->setIncludes(array('**/' . $this->subIndicatorFile)); $ds->scan(); $files = $ds->getIncludedFiles(); foreach ($files as $file) { $pkg = file_get_contents($repo . '/.subsplit' . $base . '/' . $file); $pkg_json = json_decode($pkg, true); $name = $pkg_json['name']; $component = str_replace('/composer.json', '', $file); $tmpreponame = explode('/', $name); $reponame = $tmpreponame[1]; $splits[$head][$component]['repo'] = $reponame; $nscomponent = str_replace('/', '\\', $component); $splits[$head][$component]['desc'] = "[READ ONLY] Subtree split of {$nscomponent}: " . $pkg_json['description']; } } passthru("git checkout master"); chdir($repo); $this->splits = $splits; }
/** feed dirscanner with infos defined by this fileset */ protected function setupDirectoryScanner(DirectoryScanner $ds, Project $p) { if ($ds === null) { throw new Exception("DirectoryScanner cannot be null"); } // FIXME - pass dir directly wehn dirscanner supports File $ds->setBasedir($this->dir->getPath()); foreach ($this->additionalPatterns as $addPattern) { $this->defaultPatterns->append($addPattern, $p); } $ds->setIncludes($this->defaultPatterns->getIncludePatterns($p)); $ds->setExcludes($this->defaultPatterns->getExcludePatterns($p)); $p->log("FileSet: Setup file scanner in dir " . $this->dir->__toString() . " with " . $this->defaultPatterns->toString(), Project::MSG_DEBUG); if ($ds instanceof SelectorScanner) { $ds->setSelectors($this->getSelectors($p)); } if ($this->useDefaultExcludes) { $ds->addDefaultExcludes(); } $ds->setCaseSensitive($this->isCaseSensitive); }
private function makeEntityNames($dirnames, PhingFile $rootDir) { if (empty($dirnames)) { return; } foreach ($dirnames as $dirname) { $this->output .= "<!-- dir: {$dirname} -->\n"; $ds = new DirectoryScanner(); $ds->setIncludes(array("**/*.xml")); $futil = new FileUtils(); $baseDir = $futil->resolveFile($rootDir, $dirname); $ds->setBasedir($baseDir->getPath()); $ds->scan(); $xmlFiles = $ds->getIncludedFiles(); $allEntities = ''; foreach ($xmlFiles as $xmlFilename) { $xmlFile = $futil->resolveFile($baseDir, $xmlFilename); $entityName = $this->fileToEntity($xmlFile, $rootDir); $this->output .= "<!-- {$dirname}/{$xmlFilename}-->\n"; $this->output .= "<!ENTITY {$entityName} SYSTEM \"{$dirname}/{$xmlFilename}\">\n"; $allEntities .= "&{$entityName};"; } $this->output .= "<!-- {$dirname} -->\n"; $this->output .= "<!ENTITY {$dirname}.all \"{$allEntities}\">\n"; } }
public function findComponents() { $ds = new DirectoryScanner(); $ds->setBasedir((string) $this->basedir . '/.subsplit/src'); $ds->setIncludes(array('**/composer.json')); $ds->scan(); $files = $ds->getIncludedFiles(); $this->subpackages = $files; }
/** * Inspired by http://www.phing.info/trac/ticket/137 */ public function testMultipleExcludes() { $this->executeTarget("multiple-setup"); $ds = new DirectoryScanner(); $ds->setBasedir($this->_basedir . "/echo"); $ds->setIncludes(array("**")); $ds->setExcludes(array("**/.gitignore", ".svn/", ".git/", "cache/", "build.xml", "a/a.xml")); $ds->scan(); $this->compareFiles($ds, array("b/b.xml"), array("", "a", "b")); }
/** * Helper to get instance of DirectoryScanner with cli options applied * * @param ezcConsoleInput $input CLI Options pased to app * * @return Theseer\Tools\IncludeExcludeFilterIterator */ protected function getScanner(\ezcConsoleInput $input) { $scanner = new DirectoryScanner(); $include = $input->getOption('include'); if (is_array($include->value)) { $scanner->setIncludes($include->value); } else { $scanner->addInclude($include->value); } $exclude = $input->getOption('exclude'); if ($exclude->value) { if (is_array($exclude->value)) { $scanner->setExcludes($exclude->value); } else { $scanner->addExclude($exclude->value); } } $args = $input->getArguments(); return $scanner($args[0]); }