Skip to content

Commit

Permalink
refs #31: Configure the validation queue job
Browse files Browse the repository at this point in the history
  • Loading branch information
eFrane committed Nov 24, 2017
1 parent 8510892 commit 1010ec4
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions lib/Spec/Jobs/ValidatorRunJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
namespace OParl\Spec\Jobs;

use App\Jobs\Job;
use EFrane\HubSync\Repository;
use Illuminate\Contracts\Logging\Log;
use Illuminate\Contracts\Filesystem\Filesystem;
use Symfony\Component\Process\Process;

class ValidatorRunJob extends Job
Expand Down Expand Up @@ -42,17 +44,26 @@ public function __construct($endpoint, $email, $canSaveData)
$this->canSaveData = $canSaveData;
}

public function handle(Log $log)
public function handle(Log $log, Filesystem $fs)
{
$this->log = $log;
$log->info("Beginning Validation for {$this->endpoint}");

$validatorRepo = new Repository($fs, 'oparl_validator', '');

$validatorCmd = sprintf('./validate -fjson "%s"', $this->endpoint);

$validator = new Process($validatorCmd);
$validator->start();
$validator->setEnv([
'PATH' => "{$validatorRepo->getAbsolutePath()}:/usr/local/bin:/usr/bin"
]);
$validator->setWorkingDirectory($validatorRepo->getAbsolutePath());

foreach ($validator as $type => $data) {
$this->handleProgress($type, $data);
}
$log->debug("Validator working directory: {$validator->getWorkingDirectory()}");
$log->debug("Validator command line: {$validator->getCommandLine()}");
$log->debug("Validator Environment", $validator->getEnv());

$validator->run([&$this, 'handleProgress']);
}

public function handleProgress($type, $data)
Expand All @@ -65,6 +76,7 @@ public function handleProgress($type, $data)
}
break;
case Process::ERR:
$this->log->error($data);
break;
}
}
Expand Down

0 comments on commit 1010ec4

Please sign in to comment.