Skip to content

Commit

Permalink
tasks can be injected in others
Browse files Browse the repository at this point in the history
  • Loading branch information
DavertMik committed Apr 27, 2014
1 parent 5136314 commit b2dbeba
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 6 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

#### 0.4.0 04/27/2014

* CommandInterface added to make generated commands to be passed to other tasks
* PHPUnit task improved
* Codeception task


#### 0.3.3 04/25/2014

* Task descriptions taken from first line of annotations
Expand All @@ -10,7 +17,7 @@
#### 0.3.3 02/25/2014

* PHPUnit basic task
* fixed doc geenration
* fixed doc generation


#### 0.3.5 02/21/2014
Expand Down
1 change: 0 additions & 1 deletion src/Task/Codeception.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ protected function taskCodecept($pathToCodeception = '')
* ->run();
* ?>
* ```
*
*/
class CodeceptionTask implements TaskInterface, CommandInterface{
use \Robo\Output;
Expand Down
4 changes: 2 additions & 2 deletions src/Task/Exec.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ protected function taskExecStack($command)
*/
class ExecTask implements TaskInterface, CommandInterface{
use \Robo\Output;
use Shared\CommandInjected;

protected $command;
protected $background = false;
Expand All @@ -57,8 +58,7 @@ class ExecTask implements TaskInterface, CommandInterface{

public function __construct($command)
{
if ($command instanceof CommandInterface) $command = $command->getCommand();
$this->command = $command;
$this->command = $this->retrieveCommand($command);
}

public function getCommand()
Expand Down
5 changes: 3 additions & 2 deletions src/Task/ParallelExec.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
namespace Robo\Task;
use Robo\Result;
use Robo\Task\Shared\TaskException;
use Symfony\Component\Console\Helper\ProgressHelper;
use Symfony\Component\Process\Exception\ProcessTimedOutException;
use Symfony\Component\Process\Process;
Expand Down Expand Up @@ -33,15 +34,15 @@ class ParallelExecTask implements Shared\TaskInterface
{
use \Robo\Output;
use Shared\DynamicConfig;
use Shared\CommandInjected;

protected $processes = [];
protected $timeout = 3600;
protected $idleTimeout = 60;

public function process($command)
{
if ($command instanceof Shared\CommandInterface) $command = $command->getCommand();
$this->processes[] = new Process($command);
$this->processes[] = new Process($this->retrieveCommand($command));
return $this;
}

Expand Down
18 changes: 18 additions & 0 deletions src/Task/Shared/CommandInjected.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php
namespace Robo\Task\Shared;

trait CommandInjected {

public function retrieveCommand($command)
{
if (!is_object($command)) {
return $command;
}
if ($command instanceof CommandInterface) {
return $command->getCommand();
} else {
throw new TaskException($this, get_class($command) . " does not implement CommandInterface, so can't be passed into this task");
}

}
}

0 comments on commit b2dbeba

Please sign in to comment.