Permalink
Browse files

Add GLOB_BRACE option for better pattern searches.

  • Loading branch information...
1 parent eaed604 commit 1636fa080b8cd0cbb2f4a61e68a08add5f88391c Blaine Schmeisser committed Jan 24, 2013
Showing with 19 additions and 2 deletions.
  1. +2 −2 core/Libraries.php
  2. +17 −0 tests/cases/core/LibrariesTest.php
View
@@ -979,8 +979,8 @@ protected static function _search($config, $options, $name = null) {
$suffix = $options['namespaces'] ? '' : $config['suffix'];
$suffix = ($options['suffix'] === null) ? $suffix : $options['suffix'];
- $dFlags = GLOB_ONLYDIR;
- $libs = (array) glob($path . $suffix, $options['namespaces'] ? $dFlags : 0);
+ $dFlags = GLOB_ONLYDIR & GLOB_BRACE;
+ $libs = (array) glob($path . $suffix, $options['namespaces'] ? $dFlags : GLOB_BRACE);
if ($options['recursive']) {
list($current, $match) = explode('/*', $path, 2);
@@ -65,6 +65,23 @@ public function testPathTemplate() {
$this->assertEqual($paths, Libraries::paths());
}
+ public function testPathTemplateWithGlobBrace() {
+ Libraries::paths(array(
+ 'analysis' => array(
+ '{:library}\analysis\*{Docblock,Debugger}',
+ ),
+ ));
+
+ $analysis = list($docblock, $debugger) = Libraries::locate('analysis', null, array(
+ 'recursive' => false,
+ 'format' => false,
+ ));
+
+ $this->assertCount(2, $analysis);
+ $this->assertPattern('/Docblock\.php/', $docblock);
+ $this->assertPattern('/Debugger\.php/', $debugger);
+ }
+
public function testPathTransform() {
$expected = 'Library/Class/Separated/By/Underscore';
$result = Libraries::path('Library_Class_Separated_By_Underscore', array(

0 comments on commit 1636fa0

Please sign in to comment.