/**
  * Fetches this origin into a given target folder
  *
  * @param  io.Folder $target
  */
 public function fetchInto(Folder $target)
 {
     $r = $this->client->execute($this->release);
     if (200 !== $r->status()) {
         throw new \lang\IllegalArgumentException($r->message() . ': ' . $this->release->toString());
     }
     $release = $r->data();
     Console::writeLine('Release ', $release['version']['number'], ' published ', $release['published']);
     // Download files
     $pth = create(new File($target, 'class.pth'))->getOutputStream();
     foreach ($release['files'] as $file) {
         $d = $this->client->execute(new RestRequest($file['link']));
         $f = new File($target, $file['name']);
         Console::writeLine('>> ', $file['name']);
         $tran = new StreamTransfer($d->stream(), $f->getOutputStream());
         $tran->transferAll();
         $tran->close();
         $ext = substr($file['name'], strrpos($file['name'], '.'));
         if ('.php' === $ext || '.xar' === $ext) {
             $pth->write($file['name'] . "\n");
         }
     }
     $pth->close();
 }
 public function nothingAvailableAfterTransfer()
 {
     $in = new MemoryInputStream('Hello');
     $s = new StreamTransfer($in, new MemoryOutputStream());
     $s->transferAll();
     $this->assertEquals(0, $in->available());
 }
 /**
  * Fetches this origin into a given target folder
  *
  * @param  io.Folder $target
  */
 public function fetchInto(Folder $target)
 {
     $zip = $this->zipBallOf($this->url);
     $i = 0;
     with($iter = $zip->iterator());
     $base = rtrim($iter->next()->getName() . '/', '/');
     Console::write('Extracting (', $base, ') [');
     while ($iter->hasNext()) {
         $entry = $iter->next();
         $relative = str_replace($base, '', $entry->getName());
         if ($entry->isDirectory()) {
             $folder = new Folder($target, $relative);
             $folder->exists() || $folder->create(0755);
         } else {
             $file = new File($target, $relative);
             $tran = new StreamTransfer($entry->getInputStream(), $file->getOutputStream());
             $tran->transferAll();
             $tran->close();
         }
         $i++ % 10 || Console::write('.');
     }
     $zip->close();
     Console::writeLine(']');
 }