1
0
Fork 0

Merge pull request #1 from Seldaek/refactoring

Fixes
pull/19/head
Konstantin Kudryashov 2011-09-24 08:03:16 -07:00
commit cce4d3af11
8 changed files with 14 additions and 36 deletions

View File

@ -23,7 +23,7 @@ $composer->setRepository('Platform', new Repository\PlatformRepository());
$composer->setRepository('Packagist', new Repository\ComposerRepository('http://packagist.org'));
// initialize package
$loader = new Package\Loader\Json();
$loader = new Package\Loader\JsonLoader();
$package = $loader->load('composer.json');
// initialize lock

View File

@ -9,7 +9,7 @@
"required": true
},
"type": {
"description": "Package type, either 'Library', or the parent project it applies to if it's a plugin for a framework or application (e.g. 'Symfony2', 'Typo3', 'Drupal', ..).",
"description": "Package type, either 'Library', or the parent project it applies to if it's a plugin for a framework or application (e.g. 'Symfony2', 'Typo3', 'Drupal', ..), note that this has to be defined and communicated by any project implementing a custom composer installer, those are just unreliable examples.",
"type": "string",
"optional": true
},

View File

@ -13,6 +13,8 @@
namespace Composer\Command;
use Composer\DependencyResolver;
use Composer\DependencyResolver\Pool;
use Composer\DependencyResolver\Request;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
@ -43,7 +45,7 @@ EOT
protected function execute(InputInterface $input, OutputInterface $output)
{
if ($this->getLock()->isLocked()) {
$this->writeln('<info>Found lockfile. Reading</info>');
$output->writeln('<info>Found lockfile. Reading</info>');
foreach ($this->getLock()->getLockedPackages() as $package) {
$installer = $this->getComposer()->getInstaller($package->getType());

View File

@ -13,6 +13,7 @@
namespace Composer;
use Composer\Installer\InstallerInterface;
use Composer\Repository\RepositoryInterface;
/**
* @author Jordi Boggiano <j.boggiano@seld.be>

View File

@ -36,7 +36,7 @@ class ArrayLoader
$version = $versionParser->parse($config['version']);
$package = new Package\MemoryPackage($config['name'], $version['version'], $version['type']);
$package->setType($config['type']);
$package->setType(isset($config['type']) ? $config['type'] : 'library');
if (isset($config['extra'])) {
$package->setExtra($config['extra']);
@ -99,7 +99,7 @@ class ArrayLoader
$links[] = new Package\Link($srcPackageName, $packageName, $constraint, $description);
}
return $requirements;
return $links;
}
private function validateConfig(array $config)
@ -107,9 +107,6 @@ class ArrayLoader
if (!isset($config['name'])) {
throw new \UnexpectedValueException('name is required for package');
}
if (!isset($config['type'])) {
throw new \UnexpectedValueException('type is required for package');
}
if (!isset($config['version'])) {
throw new \UnexpectedValueException('version is required for package');
}

View File

@ -14,6 +14,7 @@ namespace Composer\Repository;
use Composer\Package\MemoryPackage;
use Composer\Package\BasePackage;
use Composer\Package\Version\VersionParser;
/**
* @author Jordi Boggiano <j.boggiano@seld.be>
@ -24,10 +25,12 @@ class PlatformRepository extends ArrayRepository
{
parent::initialize();
$versionParser = new VersionParser();
try {
$version = BasePackage::parseVersion(PHP_VERSION);
$version = $versionParser->parse(PHP_VERSION);
} catch (\UnexpectedValueException $e) {
$version = BasePackage::parseVersion(preg_replace('#^(.+?)(-.+)?$#', '$1', PHP_VERSION));
$version = $versionParser->parse(preg_replace('#^(.+?)(-.+)?$#', '$1', PHP_VERSION));
}
$php = new MemoryPackage('php', $version['version'], $version['type']);
@ -40,7 +43,7 @@ class PlatformRepository extends ArrayRepository
$reflExt = new \ReflectionExtension($ext);
try {
$version = BasePackage::parseVersion($reflExt->getVersion());
$version = $versionParser->parse($reflExt->getVersion());
} catch (\UnexpectedValueException $e) {
$version = array('version' => '0', 'type' => 'stable');
}

View File

@ -17,8 +17,5 @@ namespace Composer\Repository;
*/
interface RepositoryInterface extends \Countable
{
static function supports($type, $name = '', $url = '');
static function create($type, $name = '', $url = '');
function getPackages();
}

View File

@ -213,28 +213,6 @@ class SolverTest extends \PHPUnit_Framework_TestCase
));
}
/**
* @TODO: fix packagist.org bug
*/
public function BROKEN_testSolverWithComposerRepo()
{
$this->repoInstalled = new PlatformRepository;
// overwrite solver with custom installed repo
$this->solver = new Solver($this->policy, $this->pool, $this->repoInstalled);
$this->repo = new ComposerRepository('http://packagist.org');
list($monolog) = $this->repo->getPackages();
$this->reposComplete();
$this->request->install('Monolog');
$this->checkSolverResult(array(
array('job' => 'install', 'package' => $monolog),
));
}
protected function reposComplete()
{
$this->pool->addRepository($this->repoInstalled);