Permalink
Browse files

[Finder] tweaked previous merge

  • Loading branch information...
fabpot committed Oct 4, 2012
1 parent bcddd0e commit 5d3a65186db8ccdb7df28fa89c98bc7d9989dea1
Showing with 23 additions and 14 deletions.
  1. +1 −2 Adapter/GnuFindAdapter.php
  2. +5 −0 CHANGELOG.md
  3. +3 −3 Finder.php
  4. +5 −0 Shell/Shell.php
  5. +9 −9 Tests/FinderTest.php
@@ -124,8 +124,7 @@ public function searchInDirectory($dir)
*/
public function isSupported()
{
- return $this->shell->getType() !== Shell::TYPE_WINDOWS
- && $this->shell->testCommand('find');
+ return $this->shell->getType() === Shell::TYPE_UNIX && $this->shell->testCommand('find');
}
/**
View
@@ -1,6 +1,11 @@
CHANGELOG
=========
+2.2.0
+-----
+
+ * added finder adapters to improve performance on specific platforms
+
2.1.0
-----
View
@@ -62,8 +62,8 @@ public function __construct()
{
$this->ignore = static::IGNORE_VCS_FILES | static::IGNORE_DOT_FILES;
- $this->register(new GnuFindAdapter());
- $this->register(new PhpAdapter(), -50);
+ $this->addAdapter(new GnuFindAdapter());
+ $this->addAdapter(new PhpAdapter(), -50);
}
/**
@@ -86,7 +86,7 @@ public static function create()
*
* @return Finder The current Finder instance
*/
- public function register(Adapter\AdapterInterface $adapter, $priority = 0)
+ public function addAdapter(Adapter\AdapterInterface $adapter, $priority = 0)
{
$this->adapters[$adapter->getName()] = array(
'adapter' => $adapter,
View
@@ -20,6 +20,7 @@ class Shell
const TYPE_DARWIN = 2;
const TYPE_CYGWIN = 3;
const TYPE_WINDOWS = 4;
+ const TYPE_BSD = 5;
/**
* @var string|null
@@ -77,6 +78,10 @@ private function guessType()
return self::TYPE_DARWIN;
}
+ if (false !== strpos($os, 'bsd')) {
+ return self::TYPE_BSD;
+ }
+
if (0 === strpos($os, 'win')) {
return self::TYPE_WINDOWS;
}
View
@@ -552,11 +552,11 @@ public function testAdaptersOrdering()
{
$finder = Finder::create()
->removeAdapters()
- ->register(new FakeAdapter\NamedAdapter('a'), 0)
- ->register(new FakeAdapter\NamedAdapter('b'), -50)
- ->register(new FakeAdapter\NamedAdapter('c'), 50)
- ->register(new FakeAdapter\NamedAdapter('d'), -25)
- ->register(new FakeAdapter\NamedAdapter('e'), 25);
+ ->addAdapter(new FakeAdapter\NamedAdapter('a'), 0)
+ ->addAdapter(new FakeAdapter\NamedAdapter('b'), -50)
+ ->addAdapter(new FakeAdapter\NamedAdapter('c'), 50)
+ ->addAdapter(new FakeAdapter\NamedAdapter('d'), -25)
+ ->addAdapter(new FakeAdapter\NamedAdapter('e'), 25);
$this->assertEquals(
array('c', 'e', 'a', 'd', 'b'),
@@ -576,9 +576,9 @@ public function testAdaptersChaining()
$finder = Finder::create()
->removeAdapters()
- ->register(new FakeAdapter\UnsupportedAdapter(), 3)
- ->register(new FakeAdapter\FailingAdapter(), 2)
- ->register(new FakeAdapter\DummyAdapter($iterator), 1);
+ ->addAdapter(new FakeAdapter\UnsupportedAdapter(), 3)
+ ->addAdapter(new FakeAdapter\FailingAdapter(), 2)
+ ->addAdapter(new FakeAdapter\DummyAdapter($iterator), 1);
$this->assertIterator($filenames, $finder->in(sys_get_temp_dir())->getIterator());
}
@@ -624,7 +624,7 @@ private function buildFinder(Adapter\AdapterInterface $adapter)
{
return Finder::create()
->removeAdapters()
- ->register($adapter);
+ ->addAdapter($adapter);
}
private function getValidAdapters()

0 comments on commit 5d3a651

Please sign in to comment.