Skip to content

Commit

Permalink
* various cs fixes (idention, tabs/spaces, doc blocks, etc.)
Browse files Browse the repository at this point in the history
 * fixed a typo'd exception name
  • Loading branch information
till committed Jun 25, 2012
1 parent 592f691 commit 1f41da8
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 42 deletions.
10 changes: 3 additions & 7 deletions src/Composer/Package/Dumper/BaseDumper.php
Expand Up @@ -32,7 +32,7 @@ abstract class BaseDumper implements DumperInterface
/** /**
* @var array * @var array
*/ */
static $keys = array( protected static $keys = array(
'binaries' => 'bin', 'binaries' => 'bin',
'scripts', 'scripts',
'type', 'type',
Expand Down Expand Up @@ -70,7 +70,6 @@ abstract class BaseDumper implements DumperInterface
* @param mixed $path * @param mixed $path
* @param \Composer\Util\ProcessExecutor|null $process * @param \Composer\Util\ProcessExecutor|null $process
* *
* @return \Composer\Package\Dumper\BaseDumper
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
*/ */
public function __construct($path = null, ProcessExecutor $process = null) public function __construct($path = null, ProcessExecutor $process = null)
Expand All @@ -79,7 +78,7 @@ public function __construct($path = null, ProcessExecutor $process = null)
if (!is_writable($path)) { if (!is_writable($path)) {
throw new \InvalidArgumentException("Not authorized to write to '{$path}'"); throw new \InvalidArgumentException("Not authorized to write to '{$path}'");
} }
$this->path = $path; $this->path = $path;
} }
$this->process = ($process !== null)?$process:new ProcessExecutor; $this->process = ($process !== null)?$process:new ProcessExecutor;
$this->temp = sys_get_temp_dir(); $this->temp = sys_get_temp_dir();
Expand All @@ -95,10 +94,7 @@ public function __construct($path = null, ProcessExecutor $process = null)
public function getFilename(PackageInterface $package, $extension) public function getFilename(PackageInterface $package, $extension)
{ {
$name = $package->getPrettyVersion(); $name = $package->getPrettyVersion();
$fileName = sprintf('%s.%s', $fileName = sprintf('%s.%s', $name, $extension);
$name,
$extension
);
return $fileName; return $fileName;
} }


Expand Down
10 changes: 9 additions & 1 deletion src/Composer/Package/Dumper/DumperInterface.php
Expand Up @@ -17,5 +17,13 @@
*/ */
interface DumperInterface interface DumperInterface
{ {
/**
* Return value depends on implementation - e.g. generating a tar or zip the
* method currently returns void, the ArrayDumper returns an array.
*
* @param PackageInterface $package
*
* @return mixed
*/
public function dump(PackageInterface $package); public function dump(PackageInterface $package);
} }
31 changes: 16 additions & 15 deletions src/Composer/Package/Dumper/TarDumper.php
Expand Up @@ -32,21 +32,22 @@ public function dump(PackageInterface $package)
$sourceRef = $package->getSourceReference(); $sourceRef = $package->getSourceReference();


switch ($sourceType) { switch ($sourceType) {
case 'git': case 'git':
$this->downloadGit($package, $workDir); $this->downloadGit($package, $workDir);
$this->packageGit($fileName, $sourceRef, $workDir); $this->packageGit($fileName, $sourceRef, $workDir);
break; break;
case 'hg': case 'hg':
$this->downloadHg($package, $workDir); $this->downloadHg($package, $workDir);
$this->packageHg($fileName, $sourceRef, $workDir); $this->packageHg($fileName, $sourceRef, $workDir);
break; break;
case 'svn': case 'svn':
$dir = $workDir . (substr($sourceRef, 0, 1) !== '/')?'/':'' . $sourceRef; $dir = $workDir . (substr($sourceRef, 0, 1) !== '/')?'/':'' . $sourceRef;
$this->downloadSvn($package, $workDir); $this->downloadSvn($package, $workDir);
$this->package($fileName, $dir, \Phar::TAR); $this->package($fileName, $dir, \Phar::TAR);
break; break;
default: default:
throw new \InvalidArgumentException("Unable to handle repositories of type '{$sourceType}'."); throw new \InvalidArgumentException(
"Unable to handle repositories of type '{$sourceType}'.");
} }
} }
} }
30 changes: 15 additions & 15 deletions src/Composer/Package/Dumper/ZipDumper.php
Expand Up @@ -32,21 +32,21 @@ public function dump(PackageInterface $package)
$sourceRef = $package->getSourceReference(); $sourceRef = $package->getSourceReference();


switch ($sourceType) { switch ($sourceType) {
case 'git': case 'git':
$this->downloadGit($package, $workDir); $this->downloadGit($package, $workDir);
$this->packageGit($fileName, $sourceRef, $workDir); $this->packageGit($fileName, $sourceRef, $workDir);
break; break;
case 'hg': case 'hg':
$this->downloadHg($package, $workDir); $this->downloadHg($package, $workDir);
$this->packageHg($fileName, $sourceRef, $workDir); $this->packageHg($fileName, $sourceRef, $workDir);
break; break;
case 'svn': case 'svn':
$dir = $workDir . (substr($sourceRef, 0, 1) !== '/')?'/':'' . $sourceRef; $dir = $workDir . (substr($sourceRef, 0, 1) !== '/')?'/':'' . $sourceRef;
$this->downloadSvn($package, $workDir); $this->downloadSvn($package, $workDir);
$this->package($fileName, $dir, \Phar::ZIP); $this->package($fileName, $dir, \Phar::ZIP);
break; break;
default: default:
throw new \InvalidArgumentException("Unable to handle repositories of type '{$sourceType}'."); throw new \InvalidArgumentException("Unable to handle repositories of type '{$sourceType}'.");
} }
} }
} }
8 changes: 4 additions & 4 deletions tests/Composer/Test/Package/Dumper/DumperTest.php
Expand Up @@ -35,7 +35,7 @@ abstract class DumperTest extends \PHPUnit_Framework_TestCase
public function setUp() public function setUp()
{ {
$this->fs = new Filesystem; $this->fs = new Filesystem;
$this->process = new ProcessExecutor; $this->process = new ProcessExecutor;
$this->testdir = sys_get_temp_dir() . '/composer_dumpertest_git_repository' . mt_rand(); $this->testdir = sys_get_temp_dir() . '/composer_dumpertest_git_repository' . mt_rand();
} }


Expand All @@ -58,20 +58,20 @@ protected function setupGitRepo()
chdir($td); chdir($td);


$result = $this->process->execute("git init -q"); $result = $this->process->execute("git init -q");
if ($result > 0) { if ($result > 0) {
throw new \RuntimeException( throw new \RuntimeException(
"Could not init: " . $this->process->getErrorOutput()); "Could not init: " . $this->process->getErrorOutput());
} }
$result = file_put_contents('b', 'a'); $result = file_put_contents('b', 'a');
if (false === $result) { if (false === $result) {
throw new \RuntimeExcepton("Could not save file."); throw new \RuntimeException("Could not save file.");
} }
$result = $this->process->execute("git add b && git commit -m 'commit b' -q"); $result = $this->process->execute("git add b && git commit -m 'commit b' -q");
if ($result > 0) { if ($result > 0) {
throw new \RuntimeException( throw new \RuntimeException(
"Could not init: " . $this->process->getErrorOutput()); "Could not init: " . $this->process->getErrorOutput());
} }
chdir($currentWorkDir); chdir($currentWorkDir);
} }


protected function removeGitRepo() protected function removeGitRepo()
Expand Down

0 comments on commit 1f41da8

Please sign in to comment.