svn: /pear2/sandbox/SimpleChannelServer/trunk/src/SimpleChannelServer/ CLI.php Main.php

From: Date: Fri, 20 Nov 2009 14:20:54 +0000
Subject: svn: /pear2/sandbox/SimpleChannelServer/trunk/src/SimpleChannelServer/ CLI.php Main.php
Groups: php.pear.cvs php.pear.core 
Request: Send a blank email to pear-core+get-9043@lists.php.net to get a copy of this message
saltybeagle Fri, 20 Nov 2009 14:20:54 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=291085 Log: Create the main scs object in one place, and use that throughout. Use the correct path to files when using the categorize and add-category commands. Changed paths: U pear2/sandbox/SimpleChannelServer/trunk/src/SimpleChannelServer/CLI.php U pear2/sandbox/SimpleChannelServer/trunk/src/SimpleChannelServer/Main.php Modified: pear2/sandbox/SimpleChannelServer/trunk/src/SimpleChannelServer/CLI.php =================================================================== --- pear2/sandbox/SimpleChannelServer/trunk/src/SimpleChannelServer/CLI.php 2009-11-20 13:52:40 UTC (rev 291084) +++ pear2/sandbox/SimpleChannelServer/trunk/src/SimpleChannelServer/CLI.php 2009-11-20 14:20:54 UTC (rev 291085) @@ -18,13 +18,21 @@ public $pyruspath = false; + /** + * The simplechannelserver object + * + * @var pear2\SimpleChannelServer\Main + */ + public $scs; + public function __construct() { $channel_file = getcwd() . '/channel.xml'; + $this->dir = getcwd(); if (file_exists($channel_file)) { $this->channel = new \pear2\Pyrus\Channel(new \pear2\Pyrus\ChannelFile($channel_file)); + $this->scs = new Main($this->channel, $this->dir); } - $this->dir = getcwd(); } public function process() @@ -40,8 +48,6 @@ case 'create': return $this->handleCreate(); case 'add-maintainer': - $scs = new Main($this->channel, - $this->dir); // is this even needed? // yes, new maintainers that have not yet released anything. break; @@ -70,15 +76,7 @@ $args = array(); $args['package'] = $_SERVER['argv'][2]; $args['category'] = $_SERVER['argv'][3]; - $categories = new Categories($this->channel); - if (!$categories->exists($args['category'])) { - echo 'That category doesn\'t exist yet. Use add-category first' . PHP_EOL; - } - $categories->linkPackageToCategory($args['package'], $args['category']); - $category = new REST\Category($this->dir . '/rest', $this->channel->name, 'rest/', $categories); - $category->saveAllCategories(); - $category->savePackages($args['category']); - $category->savePackagesInfo($args['category']); + $this->scs->categorize($args['package'], $args['category']); echo "Added {$args['package']} to {$args['category']} \n"; } @@ -177,7 +175,7 @@ $maintainer = \pear2\Pyrus\Config::current()->handle; \pear2\Pyrus\Config::current()->default_channel = $chan; } - $scs = new Main($this->channel, $this->dir); + $dirname = $this->dir . '/get/'; $dir = new \DirectoryIterator($dirname); $errs = new \pear2\MultiErrors; @@ -187,7 +185,7 @@ && substr($file->getFilename(), -3) != 'tar' && substr($file->getFilename(), 0, 1) != '.') { try { - $scs->saveRelease($dirname.$file->getFilename(), $maintainer); + $this->scs->saveRelease($dirname.$file->getFilename(), $maintainer); echo $file->getFilename().' successfully saved.'.PHP_EOL; } catch(\Exception $e) { echo $file->getFilename().' '.$e->getMessage().PHP_EOL; @@ -218,8 +216,7 @@ $args['maintainer'] = \pear2\Pyrus\Config::current()->handle; \pear2\Pyrus\Config::current()->default_channel = $chan; } - $scs = new Main($this->channel, $this->dir, $this->pyruspath); - $scs->saveRelease($args['path'], $args['maintainer']); + $this->scs->saveRelease($args['path'], $args['maintainer']); echo 'Release successfully saved.'.PHP_EOL; } Modified: pear2/sandbox/SimpleChannelServer/trunk/src/SimpleChannelServer/Main.php =================================================================== --- pear2/sandbox/SimpleChannelServer/trunk/src/SimpleChannelServer/Main.php 2009-11-20 13:52:40 UTC (rev 291084) +++ pear2/sandbox/SimpleChannelServer/trunk/src/SimpleChannelServer/Main.php 2009-11-20 14:20:54 UTC (rev 291085) @@ -19,9 +19,15 @@ * @var string */ protected $webpath; + /** + * Path to rest files * @var string */ + protected $restpath; + /** + * @var string + */ protected $uri; /** * REST manager @@ -64,11 +70,13 @@ if (dirname($restpath . 'a') . '/' !== $restpath) { $restpath .= '/'; } - $this->uri = 'http://' . $channel->name . '/'; - $this->channel = $channel; - $this->rest = new REST\Manager($webpath.'/'.$restpath, $channel, - $restpath); - $this->get = new Get($webpath.'/get', $pyruspath); + $this->restpath = $webpath.'/'.$restpath; + $this->uri = 'http://' . $channel->name . '/'; + $this->channel = $channel; + $this->rest = new REST\Manager($this->restpath, + $channel, + $restpath); + $this->get = new Get($webpath.'/get', $pyruspath); try { $a = \pear2\Pyrus\Config::singleton($pyruspath); } catch (Exception $e) { @@ -76,6 +84,18 @@ $e); } } + + function categorize($package, $category) + { + $categories = new Categories($this->channel); + if (!$categories->exists($category)) { + echo 'That category doesn\'t exist yet. Use add-category first' . PHP_EOL; + } + $categories->linkPackageToCategory($package, $category); + $rcat = new REST\Category($this->restpath, $this->channel, 'rest/', $categories); + $rcat->savePackages($category); + $rcat->savePackagesInfo($category); + } function saveRelease($package, $releaser) {

« previous php.pear.core (#9043) next »