Example #1
0
 protected function prepare()
 {
     $engine = Engine::factory();
     if (Type::determinePecl($this->path, $matches) < 1) {
         throw new \Exception('Not valid PECL URI');
     }
     if ('php' != $engine->getName()) {
         throw new \Exception('PECL is only supported with PHP');
     }
     $this->name = $matches['package'];
     $this->url = 'https://pecl.php.net/get/' . $matches['package'];
     if (isset($matches['stability']) && '' !== $matches['stability']) {
         $this->stability = $matches['stability'];
         $this->url .= '-' . $matches['stability'];
     } else {
         $this->stability = 'stable';
     }
     if (isset($matches['version']) && '' !== $matches['version']) {
         $this->url .= '/' . $matches['version'];
         $this->prettyVersion = $matches['version'];
         $this->version = $matches['version'];
     } else {
         $this->version = 'latest';
         $this->prettyVersion = 'latest-' . $this->stability;
     }
 }
Example #2
0
 protected function prepare()
 {
     if (Type::determinePickle($this->path, $matches) < 1) {
         throw new \Exception('Not a pickle git URI');
     }
     $this->name = $matches['package'];
     $extension = $this->fetchPackageJson();
     $versionParser = new VersionParser();
     if ($matches['version'] == '') {
         $versions = array_keys($extension['packages'][$this->name]);
         if (count($versions) > 1) {
             $versionToUse = $versions[1];
         } else {
             $versionToUse = $versions[0];
         }
     } else {
         $versionConstraints = $versionParser->parseConstraints($matches['version']);
         /* versions are sorted decreasing */
         foreach ($extension['packages'][$this->name] as $version => $release) {
             $constraint = new VersionConstraint('=', $versionParser->normalize($version));
             if ($versionConstraints->matches($constraint)) {
                 $versionToUse = $version;
                 break;
             }
         }
     }
     $package = $extension['packages'][$this->name][$versionToUse];
     $this->version = $versionToUse;
     $this->normalizedVersion = $versionParser->normalize($versionToUse);
     $this->name = $matches['package'];
     $this->prettyVersion = $this->version;
     $this->url = $package['source']['url'];
     $this->reference = $package['source']['reference'];
     $this->type = $package['source']['type'];
 }
Example #3
0
 public function __construct($path, ConsoleIO $io)
 {
     if (!$path) {
         throw new \Exception('Path cannot be empty');
     }
     $type = Type::determine($path, false === realpath($path));
     $this->command = Factory::getCommand($type, $path, $io);
 }
Example #4
0
 protected function prepare()
 {
     if (Type::determineGit($this->path, $matches) < 1) {
         throw new \Exception('Not valid git URI');
     }
     $this->name = $matches['package'];
     $this->version = isset($matches['reference']) ? $matches['reference'] : 'master';
     $this->prettyVersion = $this->version;
     $this->url = preg_replace('/#.*$/', '', $this->path);
 }
Example #5
0
 public function test_determine_srcdir()
 {
     $this->string(Command\Type::determine(getcwd(), false))->isIdenticalTo(Command\Type::SRC_DIR)->string(Command\Type::determine(getcwd(), true))->isIdenticalTo(Command\Type::ANY);
 }