Skip to content

Commit

Permalink
Merge pull request #1 from ivarb/master
Browse files Browse the repository at this point in the history
Update AB remote with latest changes from master
  • Loading branch information
ivarb committed Apr 7, 2015
2 parents 28bf80d + 6dfe030 commit 794b503
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 7 deletions.
4 changes: 3 additions & 1 deletion src/Naneau/ProjectVersioner/Reader/Composer.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

namespace Naneau\ProjectVersioner\Reader;

use Naneau\ProjectVersioner\ReaderInterface;

/**
* Composer
*
Expand All @@ -17,7 +19,7 @@
* @package ProjectVersioner
* @subpackage Reader
*/
class Composer
class Composer implements ReaderInterface
{
/**
* {@inheritdoc}
Expand Down
50 changes: 50 additions & 0 deletions src/Naneau/ProjectVersioner/Reader/ComposerJson.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php
/**
* ComposerJson.php
*
* @package ProjectVersioner
* @subpackage Reader
*/

namespace Naneau\ProjectVersioner\Reader;

use Naneau\ProjectVersioner\ReaderInterface;

use \RuntimeException;
use \stdClass;

/**
* Finds the "version" from the composer.json file
*
* @category Naneau
* @package ProjectVersioner
* @subpackage Reader
*/
class ComposerJson implements ReaderInterface
{
/**
* {@inheritdoc}
**/
public function canRead($directory)
{
return is_readable($directory . '/composer.json');
}

/**
* {@inheritdoc}
**/
public function read($directory)
{
$json = @file_get_contents($directory . '/composer.json');
if ($json === false) {
return false;
}

$json = json_decode($json);
if (!($json instanceof stdClass) || empty($json->version)) {
return false;
}

return trim($json->version);
}
}
4 changes: 3 additions & 1 deletion src/Naneau/ProjectVersioner/Reader/ComposerPackage.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

namespace Naneau\ProjectVersioner\Reader;

use Naneau\ProjectVersioner\ReaderInterface;

/**
* ComposerPackage
*
Expand All @@ -17,7 +19,7 @@
* @package ProjectVersioner
* @subpackage Reader
*/
class ComposerPackage
class ComposerPackage implements ReaderInterface
{
/**
* The page name to look for
Expand Down
4 changes: 2 additions & 2 deletions src/Naneau/ProjectVersioner/Reader/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@ public function __construct($file)
**/
public function canRead($directory)
{
return is_readable($directory . '/' . $this->getFile());
return is_readable($directory . DIRECTORY_SEPARATOR . $this->getFile());
}

/**
* {@inheritdoc}
**/
public function read($directory)
{
return trim(file_get_contents($directory . '/' . $this->getFile()));
return trim(file_get_contents($directory . DIRECTORY_SEPARATOR . $this->getFile()));
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/Naneau/ProjectVersioner/Versioner.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,12 @@ public function setReaders(array $readers)
/**
* Add a reader
*
* @param Reader[] $readers
* @param Reader[] $reader
* @return Versioner
*/
public function addReaders()
public function addReader(Reader $reader)
{
$this->readers[] = $readers;
$this->readers[] = $reader;

return $this;
}
Expand Down

0 comments on commit 794b503

Please sign in to comment.