Exemplo n.º 1
0
 public function testIgnorePatterns()
 {
     $fixture_data = '*/test/*';
     $fixture_data2 = '*/test?/*';
     $result_data = '.*\\/test\\/.*';
     $result_data2 = '.*\\/test.\\/.*';
     // default is empty
     $this->assertEquals(array(), $this->fixture->getIgnorePatterns());
     // test adding a normal glob with asterisks on both sides
     $this->fixture->addIgnorePattern($fixture_data);
     $this->assertEquals(array($result_data), $this->fixture->getIgnorePatterns());
     // what happens if we add another one with a question mark?
     $this->fixture->addIgnorePattern($fixture_data2);
     $this->assertEquals(array($result_data, $result_data2), $this->fixture->getIgnorePatterns());
     // what happens if we set all to an empty array
     $this->fixture->setIgnorePatterns(array());
     $this->assertEquals(array(), $this->fixture->getIgnorePatterns());
     // what happens if we set both patterns using the setIgnorePatterns method
     $this->fixture->setIgnorePatterns(array($fixture_data, $fixture_data2));
     $this->assertEquals(array($result_data, $result_data2), $this->fixture->getIgnorePatterns());
 }
Exemplo n.º 2
0
 /**
  * Execute the parsing process.
  *
  * @throws Zend_Console_Getopt_Exception
  *
  * @return void
  */
 public function execute()
 {
     $files = $this->parseFiles();
     if (count($files) < 1) {
         throw new Zend_Console_Getopt_Exception('No parsable files were found, did you specify any using the -f or -d parameter?');
     }
     $parser = new DocBlox_Parser();
     $parser->setTitle(htmlentities($this->getTitle()));
     if ($this->getVerbose()) {
         $parser->setLogLevel(DocBlox_Core_Log::DEBUG);
     }
     if ($this->getQuiet()) {
         $parser->setLogLevel(DocBlox_Core_Log::QUIET);
     }
     $parser->setExistingXml($this->getTarget() . '/structure.xml');
     $parser->setIgnorePatterns($this->getIgnore());
     $parser->setForced($this->getForce());
     $parser->setMarkers($this->getMarkers());
     $parser->setValidate($this->getValidate());
     $parser->setPath($parser->getCommonPath($files));
     // save the generate file to the path given as the 'target' option
     file_put_contents($this->getTarget() . '/structure.xml', $parser->parseFiles($files));
 }
Exemplo n.º 3
0
  if (count($opts->getFiles()) < 1)
  {
    throw new Zend_Console_Getopt_Exception('No parsable files were found, did you specify any using the -f or -d parameter?');
  }

} catch (Zend_Console_Getopt_Exception $e)
{
  // if the message actually contains anything, show it.
  if ($e->getMessage())
  {
    echo $e->getMessage() . PHP_EOL . PHP_EOL;
  }

  // show help message and exit the application
  echo $opts->getUsageMessage();
  exit;
}

// initialize the parser and pass the options as provided by the user or defaults
$docblox = new DocBlox_Parser();
$docblox->setLogLevel($opts->getOption('verbose') ? Zend_Log::DEBUG : $docblox->getLogLevel());
$docblox->setExistingXml(is_readable($path.'/structure.xml') ? file_get_contents($path.'/structure.xml') : null);
$docblox->setIgnorePatterns($opts->getIgnorePatterns());
$docblox->setForced($opts->getOption('force'));
$docblox->setMarkers($opts->getMarkers());
$docblox->setValidate($opts->getOption('validate'));

// save the generate file to the path given as the 'target' option
file_put_contents($path.'/structure.xml', $docblox->parseFiles($opts->getFiles()));