Skip to content

Commit

Permalink
✨ switched from janitor jobs to cli commands
Browse files Browse the repository at this point in the history
Signed-off-by: bnomei <[email protected]>
  • Loading branch information
bnomei committed Nov 8, 2022
1 parent 5e48ab3 commit ceecb7e
Show file tree
Hide file tree
Showing 11 changed files with 46 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

return (new PhpCsFixer\Config())
->setRules([
'@PSR2' => true,
'@PSR12' => true,
])
->setFinder($finder)
;
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
language: php
php: 8.0
php: 8.1
matrix:
fast_finish: true
install: composer install --no-interaction
Expand Down
4 changes: 2 additions & 2 deletions classes/Lapse.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ public function keyFromObject($key): string
$modified = $key->modified();
}
*/
// @codeCoverageIgnoreEnd
// @codeCoverageIgnoreEnd
} else {
// ... or check file on disk now
if ($key instanceof \Kirby\Cms\Site) {
Expand Down Expand Up @@ -274,7 +274,7 @@ public function updateIndex(?string $key = null, $indexLimit = null): ?int
/**
* @return bool
*/
public function clean(): bool
public function prune(): bool
{
return $this->updateIndex(null, self::INDEX_LIMIT) <= self::INDEX_LIMIT;
}
Expand Down
5 changes: 2 additions & 3 deletions classes/LapseStatic.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

class LapseStatic
{
static array $cache = [];
public static array $cache = [];

static function getOrSet($key, Closure $closure)
public static function getOrSet($key, Closure $closure)
{
$key = Lapse::singleton()->keyFromObject($key);

Expand All @@ -24,4 +24,3 @@ static function getOrSet($key, Closure $closure)
return static::$cache[$key];
}
}

4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "bnomei/kirby3-lapse",
"type": "kirby-plugin",
"version": "3.0.0",
"version": "3.1.0",
"description": "Cache any data until set expiration time",
"license": "MIT",
"authors": [
Expand Down Expand Up @@ -40,7 +40,7 @@
"getkirby/composer-installer": "^1.2"
},
"require-dev": {
"getkirby/cms": "^3.5",
"getkirby/cms": "^3.8.1.1",
"php-coveralls/php-coveralls": "^2.4",
"phpunit/phpunit": "^9.5"
},
Expand Down
18 changes: 13 additions & 5 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,21 @@ function lapseStatic($key, Closure $closure, $expires = null)
'cache' => true,
'expires' => 0,
'indexLimit' => null,
'jobs' => [ // https://github.com/bnomei/kirby3-janitor
'cleanLapse' => function (Kirby\Cms\Page $page = null, string $data = null) {
return \Bnomei\Lapse::singleton()->clean();
],
'commands' => [ // https://github.com/getkirby/cli
'lapse:prune' => [
'description' => 'Prune cache Lapse plugin',
'args' => [],
'command' => static function ($cli) {
return \Bnomei\Lapse::singleton()->prune();
},
'flushLapse' => function (Kirby\Cms\Page $page = null, string $data = null) {
],
'lapse:flush' => [
'description' => 'Flush cache of Lapse plugin',
'args' => [],
'command' => static function ($cli) {
return \Bnomei\Lapse::singleton()->flush();
},
],
]
],
]);
1 change: 1 addition & 0 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

//require_once __DIR__ . '/bootstrap.php';
require_once __DIR__ . '/../vendor/autoload.php';

Expand Down
3 changes: 2 additions & 1 deletion tests/index.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<?php

require __DIR__ . '/../vendor/autoload.php';
echo (new Kirby)->render();
echo (new Kirby())->render();
5 changes: 3 additions & 2 deletions tests/site/templates/default.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?php

echo '<pre>';
var_dump(kirby()->language()->code());
var_dump($page->title()->value());
var_dump($page->modified('c'));
var_dump(\Bnomei\Lapse::hash([$page]));
var_dump($page->modified('c'));
var_dump(\Bnomei\Lapse::hash([$page]));
var_dump(\Bnomei\Lapse::gt([$page]));
17 changes: 15 additions & 2 deletions vendor/autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,21 @@
// autoload.php @generated by Composer

if (PHP_VERSION_ID < 50600) {
echo 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL;
exit(1);
if (!headers_sent()) {
header('HTTP/1.1 500 Internal Server Error');
}
$err = 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL;
if (!ini_get('display_errors')) {
if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
fwrite(STDERR, $err);
} elseif (!headers_sent()) {
echo $err;
}
}
trigger_error(
$err,
E_USER_ERROR
);
}

require_once __DIR__ . '/composer/autoload_real.php';
Expand Down
8 changes: 4 additions & 4 deletions vendor/composer/installed.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php return array(
'root' => array(
'name' => 'bnomei/kirby3-lapse',
'pretty_version' => '3.0.0',
'version' => '3.0.0.0',
'pretty_version' => '3.1.0',
'version' => '3.1.0.0',
'reference' => NULL,
'type' => 'kirby-plugin',
'install_path' => __DIR__ . '/../../',
Expand All @@ -11,8 +11,8 @@
),
'versions' => array(
'bnomei/kirby3-lapse' => array(
'pretty_version' => '3.0.0',
'version' => '3.0.0.0',
'pretty_version' => '3.1.0',
'version' => '3.1.0.0',
'reference' => NULL,
'type' => 'kirby-plugin',
'install_path' => __DIR__ . '/../../',
Expand Down

0 comments on commit ceecb7e

Please sign in to comment.