-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added header zone in formatter file * Updated testing * Updated README
- Loading branch information
mmoreram
committed
Aug 31, 2014
1 parent
40e4341
commit 2684dee
Showing
23 changed files
with
393 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,15 @@ use-sort: | |
- _main | ||
group-type: each | ||
sort-type: alph | ||
sort-direction: asc | ||
sort-direction: asc | ||
header: | | ||
/** | ||
* This file is part of the Extractor package. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* Feel free to edit as you please, and have fun. | ||
* | ||
* @author Marc Morera <[email protected]> | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of the Extractor package. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* Feel free to edit as you please, and have fun. | ||
* | ||
* @author Marc Morera <[email protected]> | ||
*/ | ||
|
||
namespace Mmoreram\Extractor\Adapter; | ||
|
||
use Mmoreram\Extractor\Adapter\Abstracts\AbstractExtractorAdapter; | ||
use Mmoreram\Extractor\Adapter\Interfaces\ExtractorAdapterInterface; | ||
use Phar; | ||
use PharData; | ||
use Symfony\Component\Finder\Finder; | ||
|
||
/** | ||
* Class TarBz2ExtractorAdapter | ||
*/ | ||
class TarBz2ExtractorAdapter extends AbstractExtractorAdapter implements ExtractorAdapterInterface | ||
{ | ||
/** | ||
* Checks if current adapter can be used | ||
* | ||
* @return boolean Adapter usable | ||
*/ | ||
public function isAvailable() | ||
{ | ||
return 'Bz2'; | ||
} | ||
|
||
/** | ||
* Return the adapter identifier | ||
* | ||
* @return string Adapter identifier | ||
*/ | ||
public function getIdentifier() | ||
{ | ||
return class_exists('\PharData'); | ||
} | ||
|
||
/** | ||
* Extract files from a filepath | ||
* | ||
* @param string $filePath File path | ||
* | ||
* @return Finder | ||
*/ | ||
public function extract($filePath) | ||
{ | ||
$tmpDirectory = $this->getRandomTemporaryDir(); | ||
$pharArchive = new PharData($filePath, null, null, Phar::BZ2); | ||
$pharArchive->extractTo($tmpDirectory); | ||
|
||
return $this->createFinderFromDirectory($tmpDirectory); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of the Extractor package. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* Feel free to edit as you please, and have fun. | ||
* | ||
* @author Marc Morera <[email protected]> | ||
*/ | ||
|
||
namespace Mmoreram\Extractor\Adapter; | ||
|
||
use Mmoreram\Extractor\Adapter\Abstracts\AbstractExtractorAdapter; | ||
use Mmoreram\Extractor\Adapter\Interfaces\ExtractorAdapterInterface; | ||
use Phar; | ||
use PharData; | ||
use Symfony\Component\Finder\Finder; | ||
|
||
/** | ||
* Class TarExtractorAdapter | ||
*/ | ||
class TarExtractorAdapter extends AbstractExtractorAdapter implements ExtractorAdapterInterface | ||
{ | ||
/** | ||
* Checks if current adapter can be used | ||
* | ||
* @return boolean Adapter usable | ||
*/ | ||
public function isAvailable() | ||
{ | ||
return 'Tar'; | ||
} | ||
|
||
/** | ||
* Return the adapter identifier | ||
* | ||
* @return string Adapter identifier | ||
*/ | ||
public function getIdentifier() | ||
{ | ||
return class_exists('\PharData'); | ||
} | ||
|
||
/** | ||
* Extract files from a filepath | ||
* | ||
* @param string $filePath File path | ||
* | ||
* @return Finder | ||
*/ | ||
public function extract($filePath) | ||
{ | ||
$tmpDirectory = $this->getRandomTemporaryDir(); | ||
$pharArchive = new PharData($filePath, null, null, Phar::TAR); | ||
$pharArchive->extractTo($tmpDirectory); | ||
|
||
return $this->createFinderFromDirectory($tmpDirectory); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of the Extractor package. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* Feel free to edit as you please, and have fun. | ||
* | ||
* @author Marc Morera <[email protected]> | ||
*/ | ||
|
||
namespace Mmoreram\Extractor\Adapter; | ||
|
||
use Mmoreram\Extractor\Adapter\Abstracts\AbstractExtractorAdapter; | ||
use Mmoreram\Extractor\Adapter\Interfaces\ExtractorAdapterInterface; | ||
use Phar; | ||
use PharData; | ||
use Symfony\Component\Finder\Finder; | ||
|
||
/** | ||
* Class TarGzExtractorAdapter | ||
*/ | ||
class TarGzExtractorAdapter extends AbstractExtractorAdapter implements ExtractorAdapterInterface | ||
{ | ||
/** | ||
* Checks if current adapter can be used | ||
* | ||
* @return boolean Adapter usable | ||
*/ | ||
public function isAvailable() | ||
{ | ||
return 'Gz'; | ||
} | ||
|
||
/** | ||
* Return the adapter identifier | ||
* | ||
* @return string Adapter identifier | ||
*/ | ||
public function getIdentifier() | ||
{ | ||
return class_exists('\PharData'); | ||
} | ||
|
||
/** | ||
* Extract files from a filepath | ||
* | ||
* @param string $filePath File path | ||
* | ||
* @return Finder | ||
*/ | ||
public function extract($filePath) | ||
{ | ||
$tmpDirectory = $this->getRandomTemporaryDir(); | ||
$pharArchive = new PharData($filePath, null, null, Phar::GZ); | ||
$pharArchive->extractTo($tmpDirectory); | ||
|
||
return $this->createFinderFromDirectory($tmpDirectory); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,14 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of the Elcodi package. | ||
* | ||
* Copyright (c) 2014 Elcodi.com | ||
* This file is part of the Extractor package. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* Feel free to edit as you please, and have fun. | ||
* | ||
* @author Marc Morera <[email protected]> | ||
* @author Aldo Chiecchia <[email protected]> | ||
*/ | ||
|
||
namespace Mmoreram\Extractor\Resolver; | ||
|
@@ -51,6 +48,18 @@ public function getAdapterNamespaceGivenExtension($fileExtension) | |
$adapterNamespace .= 'PharExtractorAdapter'; | ||
break; | ||
|
||
case 'tar': | ||
$adapterNamespace .= 'TarExtractorAdapter'; | ||
break; | ||
|
||
case 'gz': | ||
$adapterNamespace .= 'TarGzExtractorAdapter'; | ||
break; | ||
|
||
case 'bz2': | ||
$adapterNamespace .= 'TarBz2ExtractorAdapter'; | ||
break; | ||
|
||
default: | ||
throw new ExtensionNotSupportedException($fileExtension); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,14 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of the Elcodi package. | ||
* | ||
* Copyright (c) 2014 Elcodi.com | ||
* This file is part of the Extractor package. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* Feel free to edit as you please, and have fun. | ||
* | ||
* @author Marc Morera <[email protected]> | ||
* @author Aldo Chiecchia <[email protected]> | ||
*/ | ||
|
||
namespace Mmoreram\Extractor\Resolver\Interfaces; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of the Extractor package. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* Feel free to edit as you please, and have fun. | ||
* | ||
* @author Marc Morera <[email protected]> | ||
*/ | ||
|
||
namespace Extractor\tests\Adapter; | ||
|
||
use Mmoreram\Extractor\Adapter\TarBz2ExtractorAdapter; | ||
use PHPUnit_Framework_TestCase; | ||
|
||
/** | ||
* Class TarBz2ExtractorAdapterTest | ||
*/ | ||
class TarBz2ExtractorAdapterTest extends PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* Setup | ||
*/ | ||
public function setUp() | ||
{ | ||
$pharExtractorAdapter = new TarBz2ExtractorAdapter(); | ||
if (!$pharExtractorAdapter->isAvailable()) { | ||
|
||
$this->markTestSkipped('Phar extension not installed'); | ||
} | ||
} | ||
|
||
/** | ||
* Test extract | ||
*/ | ||
public function testExtract() | ||
{ | ||
$tarExtractorAdapter = new TarBz2ExtractorAdapter(); | ||
$finder = $tarExtractorAdapter->extract(dirname(__FILE__). '/Fixtures/file.tar.bz2'); | ||
|
||
$this->assertEquals($finder->count(), 3); | ||
} | ||
} |
Oops, something went wrong.