Browse Source

CS and wording fixes, refs #1728

Jordi Boggiano 12 years ago
parent
commit
1b030a76d4
2 changed files with 11 additions and 16 deletions
  1. 5 5
      doc/05-repositories.md
  2. 6 11
      src/Composer/Repository/ArtifactRepository.php

+ 5 - 5
doc/05-repositories.md

@@ -490,7 +490,7 @@ information.
 There are some cases, when there is no ability to have one of the previously
 mentioned repository types online, even the VCS one. Typical example could be
 cross-organisation library exchange through built artifacts. Of course, most
-of the times they are private. To simplify maintenance, one can simply specify
+of the times they are private. To simplify maintenance, one can simply use a
 repository of type `artifact` with a folder containing ZIP archives of those
 private packages:
 
@@ -514,10 +514,10 @@ Each zip artifact is just a ZIP archive with `composer.json` in root folder:
     composer.json
     ...
 
-If there is two archives with different versions of a package, they would be
-imported both. If archive with newer version would be put to artifact folder and
-`update` command would be triggered, that version would replace previous, at it
- logically seems.
+If there are two archives with different versions of a package, they are both
+imported. When an archive with a newer version is added in the artifact folder
+and you run `update`, that version will be imported as well and Composer will
+update to the latest version.
 
 ## Disabling Packagist
 

+ 6 - 11
src/Composer/Repository/ArtifactRepository.php

@@ -28,6 +28,10 @@ class ArtifactRepository extends ArrayRepository
 
     public function __construct(array $repoConfig, IOInterface $io)
     {
+        if (!extension_loaded('zip')) {
+            throw new \RuntimeException('The artifact repository requires PHP\'s zip extension');
+        }
+
         $this->loader = new ArrayLoader();
         $this->lookup = $repoConfig['url'];
         $this->io = $io;
@@ -37,13 +41,6 @@ class ArtifactRepository extends ArrayRepository
     {
         parent::initialize();
 
-        if (!extension_loaded('zip')) {
-            $msg = 'In order to use <comment>artifact</comment> repository, ' .
-                'you need to have <comment>zip</comment> extension enabled';
-            $this->io->write($msg);
-            return;
-        }
-
         $this->scanDirectory($this->lookup);
     }
 
@@ -59,16 +56,14 @@ class ArtifactRepository extends ArrayRepository
             $package = $this->getComposerInformation($file);
             if (!$package) {
                 if ($io->isVerbose()) {
-                    $msg = "File <comment>{$file->getBasename()}</comment> doesn't seem to hold a package";
-                    $io->write($msg);
+                    $io->write("File <comment>{$file->getBasename()}</comment> doesn't seem to hold a package");
                 }
                 continue;
             }
 
             if ($io->isVerbose()) {
                 $template = 'Found package <info>%s</info> (<comment>%s</comment>) in file <info>%s</info>';
-                $msg = sprintf($template, $package->getName(), $package->getPrettyVersion(), $file->getBasename());
-                $io->write($msg);
+                $io->write(sprintf($template, $package->getName(), $package->getPrettyVersion(), $file->getBasename()));
             }
 
             $this->addPackage($package);