Merge branch 'dev'
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -12,3 +12,4 @@ Thumbs.db
|
||||
example/
|
||||
vendor/
|
||||
.env
|
||||
/.phpunit.result.cache
|
||||
|
||||
@@ -6,6 +6,9 @@ services:
|
||||
|
||||
config:
|
||||
class: '\Magdev\Dossier\Service\ConfigService'
|
||||
|
||||
system:
|
||||
class: '\Magdev\Dossier\Service\SystemService'
|
||||
|
||||
monolog:
|
||||
class: '\Magdev\Dossier\Service\MonologService'
|
||||
@@ -21,7 +24,7 @@ services:
|
||||
|
||||
git:
|
||||
class: '\Magdev\Dossier\Service\GitService'
|
||||
arguments: ['@config', '@monolog']
|
||||
arguments: ['@config', '@monolog', '@system']
|
||||
|
||||
translator:
|
||||
class: '\Magdev\Dossier\Service\TranslatorService'
|
||||
|
||||
1
bin/.gitignore
vendored
1
bin/.gitignore
vendored
@@ -3,3 +3,4 @@ lessc
|
||||
pscss
|
||||
.directory
|
||||
/phpca
|
||||
/phpunit
|
||||
|
||||
@@ -27,19 +27,10 @@
|
||||
* @package magdev/dossier
|
||||
* @license http://opensource.org/licenses/MIT MIT License
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
define('DOSSIER_ROOT', dirname(__DIR__));
|
||||
define('DOSSIER_CACHE', getenv('HOME').'/.dossier/cache');
|
||||
define('PROJECT_ROOT', getcwd());
|
||||
require(dirname(__DIR__).'/src/bootstrap.php');
|
||||
define('DOSSIER_LOGO', 'DQogX19fX19fX18gICAgICAgICAgICAgICAgICAgICAgLl9fICAgICAgICAgICAgICANCiBcX19fX19fIFwgICBfX19fICBfX19fX18gX19fX198X198IF9fX19fX19fX19fIA0KICB8ICAgIHwgIFwgLyAgXyBcLyAgX19fLy8gIF9fXy8gIHwvIF9fIFxfICBfXyBcDQogIHwgICAgYCAgICggIDxfPiApX19fIFwgXF9fXyBcfCAgXCAgX19fL3wgIHwgXC8NCiAvX19fX19fXyAgL1xfX19fL19fX18gID5fX19fICA+X198XF9fXyAgPl9ffCAgIA0KICAgICAgICAgXC8gICAgICAgICAgIFwvICAgICBcLyAgICAgICAgXC8gICAgICAgDQo=');
|
||||
|
||||
if (!is_dir(DOSSIER_CACHE)) {
|
||||
mkdir(DOSSIER_CACHE, 0700, true);
|
||||
}
|
||||
|
||||
require DOSSIER_ROOT.'/vendor/autoload.php';
|
||||
|
||||
use Magdev\Dossier\Application;
|
||||
use Magdev\Dossier\Command;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name" : "magdev/dossier",
|
||||
"type" : "project",
|
||||
"description" : "Create your dossier from Markdown files",
|
||||
"description" : "Create a personal dossier from Markdown files",
|
||||
"license" : "MIT",
|
||||
"authors" : [{
|
||||
"name" : "Marco Grätsch",
|
||||
@@ -13,6 +13,11 @@
|
||||
"Magdev\\Dossier\\" : "src"
|
||||
}
|
||||
},
|
||||
"autoload-dev" : {
|
||||
"psr-4" : {
|
||||
"Magdev\\DossierTests\\" : "tests"
|
||||
}
|
||||
},
|
||||
"require" : {
|
||||
"php" : "~7.2",
|
||||
"ext-phar" : "*",
|
||||
@@ -39,6 +44,10 @@
|
||||
"pdfshift/pdfshift-php" : "~1.0.2",
|
||||
"raivisdejus/html-minifier" : "~0.5"
|
||||
},
|
||||
"require-dev" : {
|
||||
"wapmorgan/php-code-analyzer" : "^1.0",
|
||||
"phpunit/phpunit" : "~8.1"
|
||||
},
|
||||
"config" : {
|
||||
"bin-dir" : "bin"
|
||||
},
|
||||
@@ -64,8 +73,5 @@
|
||||
"url" : "git@github.com:magdev/console-form.git",
|
||||
"name" : "magdev/console-form"
|
||||
}
|
||||
],
|
||||
"require-dev" : {
|
||||
"wapmorgan/php-code-analyzer" : "^1.0"
|
||||
}
|
||||
]
|
||||
}
|
||||
1904
composer.lock
generated
1904
composer.lock
generated
File diff suppressed because it is too large
Load Diff
17
phpunit.xml
Normal file
17
phpunit.xml
Normal file
@@ -0,0 +1,17 @@
|
||||
<phpunit
|
||||
backupGlobals="false"
|
||||
backupStaticAttributes="false"
|
||||
bootstrap="src/bootstrap.php"
|
||||
colors="true"
|
||||
convertErrorsToExceptions="true"
|
||||
convertNoticesToExceptions="true"
|
||||
convertWarningsToExceptions="true"
|
||||
processIsolation="false"
|
||||
stopOnFailure="false">
|
||||
|
||||
<testsuites>
|
||||
<testsuite name="dossier">
|
||||
<directory>tests</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
</phpunit>
|
||||
@@ -102,17 +102,17 @@ class DossierStatusCommand extends BaseCommand
|
||||
);
|
||||
$status[] = new TableSeparator();
|
||||
|
||||
$files = new \FilesystemIterator(PROJECT_ROOT.'/cv');
|
||||
$files = new \FilesystemIterator(PROJECT_ROOT.'/cv', \FilesystemIterator::SKIP_DOTS);
|
||||
foreach ($files as $file) {
|
||||
/* @var $file \SplFileInfo */
|
||||
$document = $markdown->getDocument($file->getPathname());
|
||||
$entry = new Entry($document);
|
||||
$status[] = array(get_class($entry), 'cv/'.$file->getFilename(),
|
||||
$status[$entry->getStartDate()->format('Ymd')] = array(get_class($entry), 'cv/'.$file->getFilename(),
|
||||
$this->io->align($this->io->bool($entry->useInResume()), 9, DossierStyle::ALIGN_CENTER),
|
||||
$this->io->align($this->io->percent($analyzer->analyze($entry), $thresholds), 6, DossierStyle::ALIGN_RIGHT)
|
||||
);
|
||||
}
|
||||
|
||||
ksort($status);
|
||||
$this->io->table(array('Model', 'File',
|
||||
$this->io->align('In Resume', 9),
|
||||
$this->io->align('Status', 6, DossierStyle::ALIGN_RIGHT)
|
||||
|
||||
@@ -129,7 +129,7 @@ final class Entry extends BaseModel implements PhotoInterface, AnalyzableInterfa
|
||||
|
||||
|
||||
/**
|
||||
* Constrctor
|
||||
* Constructor
|
||||
*
|
||||
* @param \Mni\FrontYAML\Document $document
|
||||
*/
|
||||
|
||||
@@ -30,8 +30,6 @@
|
||||
|
||||
namespace Magdev\Dossier\Service;
|
||||
|
||||
// git branch | grep \* | cut -d ' ' -f2
|
||||
|
||||
class GitService
|
||||
{
|
||||
/**
|
||||
@@ -46,17 +44,25 @@ class GitService
|
||||
*/
|
||||
protected $logger = null;
|
||||
|
||||
/**
|
||||
* System service
|
||||
* @var \Magdev\Dossier\Service\SystemService
|
||||
*/
|
||||
protected $system = null;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param \Magdev\Dossier\Service\ConfigService $config
|
||||
* @param \Magdev\Dossier\Service\MonologService $logger
|
||||
* @param \Magdev\Dossier\Service\SystemService $system
|
||||
*/
|
||||
public function __construct(ConfigService $config, MonologService $logger)
|
||||
public function __construct(ConfigService $config, MonologService $logger, SystemService $system)
|
||||
{
|
||||
$this->config = $config;
|
||||
$this->logger = $logger;
|
||||
$this->system = $system;
|
||||
}
|
||||
|
||||
|
||||
@@ -68,7 +74,7 @@ class GitService
|
||||
public function init(): bool
|
||||
{
|
||||
if (!$this->isGitRepository()) {
|
||||
$this->exec('git init');
|
||||
$this->system->exec('git init');
|
||||
}
|
||||
return $this->isGitRepository();
|
||||
}
|
||||
@@ -84,8 +90,7 @@ class GitService
|
||||
if (!$this->isGitRepository()) {
|
||||
return $this->config->get('output.docname');
|
||||
}
|
||||
$output = $this->exec('git branch | grep \\\* | cut -d \' \' -f2');
|
||||
return $output[0];
|
||||
return $this->system->exec('git branch | grep \\\* | cut -d \' \' -f2', self::MODE_LASTLINE);
|
||||
}
|
||||
|
||||
|
||||
@@ -96,20 +101,6 @@ class GitService
|
||||
*/
|
||||
public function isGitRepository(): bool
|
||||
{
|
||||
return is_dir(PROJECT_ROOT.'/.git') && file_exists(PROJECT_ROOT.'/.git/config');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Execute a system command
|
||||
*
|
||||
* @param string $cmd
|
||||
* @return array
|
||||
*/
|
||||
protected function exec(string $cmd): array
|
||||
{
|
||||
$output = array();
|
||||
exec($cmd, $output);
|
||||
return $output;
|
||||
return is_dir(PROJECT_ROOT.'/.git') && file_exists(PROJECT_ROOT.'/.git/HEAD');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ class MarkdownService
|
||||
$intro = new Intro($this->getDocument(PROJECT_ROOT.'/intro.md'));
|
||||
|
||||
$cv = new CurriculumVitae($this->formatter);
|
||||
$files = new \FilesystemIterator(PROJECT_ROOT.'/cv');
|
||||
$files = new \FilesystemIterator(PROJECT_ROOT.'/cv', \FilesystemIterator::SKIP_DOTS);
|
||||
foreach ($files as $file) {
|
||||
/* @var $file \SplFileInfo */
|
||||
$document = $this->getDocument($file->getPathname());
|
||||
|
||||
59
src/Service/SystemService.php
Normal file
59
src/Service/SystemService.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
/**
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2019 magdev
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* @author magdev
|
||||
* @copyright 2019 Marco Grätsch
|
||||
* @package magdev/dossier
|
||||
* @license http://opensource.org/licenses/MIT MIT License
|
||||
*/
|
||||
|
||||
namespace Magdev\Dossier\Service;
|
||||
|
||||
class SystemService
|
||||
{
|
||||
const MODE_OUTPUT = 1;
|
||||
const MODE_RETURN = 2;
|
||||
const MODE_LASTLINE = 3;
|
||||
|
||||
|
||||
/**
|
||||
* Execute a system command
|
||||
*
|
||||
* @param string $cmd
|
||||
* @param int $mode
|
||||
* @param array $output
|
||||
* @param int $return
|
||||
* @return string|int|array
|
||||
*/
|
||||
protected function exec(string $cmd, int $mode = self::MODE_OUTPUT, &$output = array(), int &$return = 0)
|
||||
{
|
||||
$lastline = exec($cmd, $output, $return);
|
||||
switch ($mode) {
|
||||
case self::MODE_LASTLINE: return $lastline;
|
||||
case self::MODE_RETURN: return $return;
|
||||
default:
|
||||
case self::MODE_OUTPUT: return $output;
|
||||
}
|
||||
}
|
||||
}
|
||||
41
src/bootstrap.php
Normal file
41
src/bootstrap.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
/**
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2019 magdev
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* @author magdev
|
||||
* @copyright 2019 Marco Grätsch
|
||||
* @package magdev/dossier
|
||||
* @license http://opensource.org/licenses/MIT MIT License
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
define('DOSSIER_ROOT', dirname(__DIR__));
|
||||
define('DOSSIER_CACHE', getenv('HOME').'/.dossier/cache');
|
||||
define('PROJECT_ROOT', getcwd());
|
||||
|
||||
if (!is_dir(DOSSIER_CACHE)) {
|
||||
mkdir(DOSSIER_CACHE, 0700, true);
|
||||
}
|
||||
|
||||
require DOSSIER_ROOT.'/vendor/autoload.php';
|
||||
56
tests/ApplicationTest.php
Normal file
56
tests/ApplicationTest.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
/**
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2019 magdev
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* @author magdev
|
||||
* @copyright 2019 Marco Grätsch
|
||||
* @package magdev/dossier
|
||||
* @license http://opensource.org/licenses/MIT MIT License
|
||||
*/
|
||||
|
||||
namespace Magdev\DossierTests;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Magdev\Dossier\Application;
|
||||
use Magdev\Dossier\Service\GitService;
|
||||
|
||||
class ApplicationTest extends TestCase
|
||||
{
|
||||
private $app = null;
|
||||
|
||||
public function setup(): void
|
||||
{
|
||||
$this->app = new Application();
|
||||
}
|
||||
|
||||
public function testGetContainer()
|
||||
{
|
||||
$this->assertInstanceOf(ContainerBuilder::class, $this->app->getContainer());
|
||||
}
|
||||
|
||||
public function testGetValidService()
|
||||
{
|
||||
$this->assertInstanceOf(GitService::class, $this->app->getService('git'));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user