Exemplo n.º 1
0
 /**
  * The entry method.
  *
  * @return  void
  */
 public function main()
 {
     $run = 'hoa://Data/Variable/Run';
     while (false !== ($c = $this->getOption($v))) {
         switch ($c) {
             case 'r':
                 $run = $v;
                 break;
             case 'h':
             case '?':
                 return $this->usage();
             case '__ambiguous':
                 $this->resolveOptionAmbiguity($v);
                 break;
         }
     }
     $this->parser->listInputs($workerId);
     if (null === $workerId) {
         return $this->usage();
     }
     $run = resolve($run);
     $protocol = Protocol::getInstance();
     $protocol['Data']['Variable']['Run']->setReach("\r" . $run . DS);
     $password = $this->readPassword('Password: ');
     $sw = new Worker\Backend\Shared($workerId, $password);
     $sw->stop();
     return;
 }
Exemplo n.º 2
0
 public function main()
 {
     $source = null;
     $destination = null;
     while (false !== ($c = $this->getOption($v))) {
         switch ($c) {
             case 's':
                 $source = $v;
                 break;
             case 'd':
                 $destination = $v;
                 break;
             case 'h':
             case '?':
                 return $this->usage();
                 break;
             case '__ambiguous':
                 $this->resolveOptionAmbiguity($v);
                 break;
         }
     }
     if (false === is_dir($source)) {
         throw new Console\Exception('Source %s is not a directory.', 0, $source);
     }
     if (false === is_dir($destination)) {
         throw new Console\Exception('Destination %s is not a directory.', 0, $destination);
     }
     $protocol = Protocol::getInstance();
     $protocol['Jekxyl'][] = new Protocol\Node('Source', "\r" . $source . DS);
     $protocol['Jekxyl'][] = new Protocol\Node('Dist', "\r" . $destination . DS);
     $protocol['Application']->setReach($source . DS);
     $compiler = new Compiler();
     echo 'Reset the destination… ';
     $compiler->reset();
     echo 'OK', "\n";
     echo 'Building pages… ';
     $compiler->buildPages();
     echo 'OK', "\n";
     echo 'Building posts… ';
     $compiler->buildPosts();
     echo 'OK', "\n";
     echo 'Building index… ';
     $compiler->buildIndex();
     echo 'OK', "\n";
     echo 'Building assets… ';
     $compiler->buildAssets();
     echo 'OK', "\n";
     echo 'Building atom feed… ';
     $compiler->buildAtom();
     echo 'OK', "\n";
     return;
 }
Exemplo n.º 3
0
 public function __construct()
 {
     $this->setMethodPrefix('case');
     parent::__construct();
     $protocol = Protocol::getInstance();
     $protocol['Test'] = new Protocol\Node('Test', null);
     $protocol['Test']['Vfs'] = new Test\Protocol\Vfs();
     $constantMocker = new Test\Mocker\Constant($this->getPhpFunctionMocker());
     $this->getAssertionManager()->setPropertyHandler('constant', function () use($constantMocker) {
         return $constantMocker;
     });
     return;
 }
Exemplo n.º 4
0
 public function case_get_root()
 {
     $this->when($result = SUT::getRoot())->then->object($result)->isIdenticalTo(LUT::getInstance());
 }
Exemplo n.º 5
0
 /**
  * The entry method.
  *
  * @return  int
  */
 public function main()
 {
     $exists = true;
     $unfold = false;
     $tree = false;
     $verbose = Console::isDirect(STDOUT);
     while (false !== ($c = $this->getOption($v))) {
         switch ($c) {
             case 'E':
                 $exists = false;
                 break;
             case 'u':
                 $unfold = true;
                 break;
             case 't':
                 $tree = true;
                 break;
             case 'V':
                 $verbose = false;
                 break;
             case 'h':
             case '?':
                 return $this->usage();
             case '__ambiguous':
                 $this->resolveOptionAmbiguity($v);
                 break;
         }
     }
     $this->parser->listInputs($path);
     if (null === $path) {
         return $this->usage();
     }
     if (true === $tree) {
         $protocol = Protocol::getInstance();
         $foo = substr($path, 0, 6);
         if ('hoa://' !== $foo) {
             return;
         }
         $path = substr($path, 6);
         $current = $protocol;
         foreach (explode('/', $path) as $component) {
             if (!isset($current[$component])) {
                 break;
             }
             $current = $current[$component];
         }
         echo $current;
         return;
     }
     if (true === $verbose) {
         echo Console\Cursor::colorize('foreground(yellow)'), $path, Console\Cursor::colorize('normal'), ' is equivalent to:', "\n";
     }
     $resolved = resolve($path, $exists, $unfold);
     foreach ((array) $resolved as $r) {
         echo $r, "\n";
     }
     return;
 }
Exemplo n.º 6
0
    /**
     * Component's name.
     *
     * @var string
     */
    protected $_name = 'Stream';
    /**
     * ID of the component.
     *
     * @param   string  $id    ID of the component.
     * @return  mixed
     */
    public function reachId($id)
    {
        return Stream::getStreamHandler($id);
    }
}
/**
 * Flex entity.
 */
Consistency::flexEntity('Hoa\\Stream\\Stream');
/**
 * Shutdown method.
 */
Consistency::registerShutdownFunction(xcallable('Hoa\\Stream\\Stream::_Hoa_Stream'));
/**
 * Add the `hoa://Library/Stream` node. Should be use to reach/get an entry
 * in the stream register.
 */
$protocol = Protocol::getInstance();
$protocol['Library'][] = new _Protocol();
Exemplo n.º 7
0
Arquivo: Xyl.php Projeto: Jir4/Xyl
 /**
  * Destruct XYL object.
  *
  * @return  void
  */
 public function __destruct()
 {
     $protocol = Protocol::getInstance();
     unset($protocol['Library']['Xyl[' . $this->_i . ']']);
     return;
 }
Exemplo n.º 8
0
 /**
  * Get root the protocol.
  *
  * @return  \Hoa\Protocol\Node\Node
  */
 public static function getRoot()
 {
     return Protocol::getInstance();
 }
Exemplo n.º 9
0
 /**
  * The entry method.
  *
  * @return  void
  */
 public function main()
 {
     $run = 'hoa://Data/Variable/Run';
     while (false !== ($c = $this->getOption($v))) {
         switch ($c) {
             case 'r':
                 $run = $v;
                 break;
             case 'h':
             case '?':
                 return $this->usage();
                 break;
             case '__ambiguous':
                 $this->resolveOptionAmbiguity($v);
                 break;
         }
     }
     $run = resolve($run);
     $protocol = Protocol::getInstance();
     $protocol['Data']['Variable']['Run']->setReach("\r" . $run . DS);
     $outi = [['ID', 'PID', 'Socket', 'Uptime', 'Messages', 'Last']];
     $outm = [];
     $now = new \DateTime();
     $t = 0;
     echo Console\Chrome\Text::colorize('Shared worker information', 'foreground(yellow)'), "\n\n";
     foreach (glob($run . DS . '*.wid') as $wid) {
         $worker = new Worker\Shared(substr(basename($wid), 0, -4));
         $infos = $worker->getInformation();
         $uptime = new \DateTime();
         $uptime->setTimestamp((int) $infos['start']);
         $last = new \DateTime();
         $last->setTimestamp((int) $infos['last_message']);
         $outi[] = [$infos['id'], $infos['pid'], $infos['socket'], $uptime->diff($now)->format('%ad%H:%I:%S'), $infos['messages'], 0 === $infos['last_message'] ? '-' : $last->diff($now)->format('%ad%H:%I:%S')];
         $outm[] = $infos;
         ++$t;
     }
     echo Console\Chrome\Text::columnize($outi, 0, 1, '|'), "\n";
     $max_id = 0;
     $max_peak = 0;
     foreach ($outm as $m) {
         $max_id < strlen($m['id']) and $max_id = strlen($m['id']);
         $max_peak < $m['memory_peak'] and $max_peak = $m['memory_peak'];
     }
     foreach ($outm as $m) {
         $outmm = str_pad($m['id'], $max_id) . '  ';
         $max = (int) ($m['memory_peak'] * 39 / $max_peak);
         $peak = (int) ($m['memory_allocated_peak'] * 40 / $max_peak);
         $memory = (int) ($m['memory_allocated'] * 40 / $max_peak);
         for ($i = 0; $i < $memory - 1; ++$i) {
             $outmm .= Console\Chrome\Text::colorize('|', 'foreground(green)');
         }
         for (; $i < $peak; ++$i) {
             $outmm .= Console\Chrome\Text::colorize('|', 'foreground(yellow)');
         }
         for (; $i < $max; ++$i) {
             $outmm .= ' ';
         }
         $outmm .= Console\Chrome\Text::colorize('|', 'foreground(red)');
         for (++$i; $i < 40; ++$i) {
             $outmm .= ' ';
         }
         $outmm .= '  ' . Console\Chrome\Text::colorize(number_format($m['memory_allocated'] / 1024) . 'Kb', 'foreground(green)') . ' ' . Console\Chrome\Text::colorize(number_format($m['memory_allocated_peak'] / 1024) . 'Kb', 'foreground(yellow)') . ' ' . Console\Chrome\Text::colorize(number_format($m['memory_peak'] / 1024) . 'Kb', 'foreground(red)');
         echo $outmm . "\n";
     }
     echo "\n", $t, ' shared worker', $t > 1 ? 's are' : ' is', ' running.', "\n";
     return;
 }