-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #52 from stekycz/improvements
Move to newer version and prepare version 2.0.0
- Loading branch information
Showing
39 changed files
with
934 additions
and
1,376 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
.gitattributes export-ignore | ||
.gitignore export-ignore | ||
.travis.yml export-ignore | ||
phpstan.neon export-ignore | ||
tests export-ignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ | |
|
||
Simple tool which helps with maintenance of cron tasks. | ||
|
||
It requires **PHP >= 5.3.3** and **Nette Framework >= 2.0.0**. | ||
It requires **PHP >= 7.0.0** and **Nette Framework >= 2.4.0**. | ||
|
||
## Usage | ||
|
||
|
@@ -169,33 +169,3 @@ start from any reason. | |
* @cronner-time 11:00, 23:30 - 05:00 | ||
*/ | ||
``` | ||
|
||
## Author | ||
|
||
My name is Martin Štekl. Feel free to contact me on [e-mail](mailto:[email protected]) | ||
or follow me on [Twitter](https://twitter.com/stekycz). | ||
|
||
## License | ||
|
||
Copyright (c) 2013 Martin Štekl <[email protected]> | ||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
Copyright (c) 2013 Martin Štekl <[email protected]> | ||
Copyright (c) 2017 Martin Štekl <[email protected]> | ||
|
||
Permission is hereby granted, free of charge, to any person | ||
obtaining a copy of this software and associated documentation | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
parameters: | ||
projectDir: %rootDir%/../../.. | ||
autoload_files: | ||
- %projectDir%/vendor/autoload.php | ||
excludes_analyse: | ||
- %projectDir%/tests/ | ||
- %projectDir%/vendor/ | ||
ignoreErrors: | ||
- '#.*Cronner::onTaskBegin\(\).*#' | ||
- '#.*Cronner::onTaskFinished\(\).*#' | ||
- '#.*Cronner::onTaskError\(\).*#' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,12 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace stekycz\Cronner; | ||
|
||
use Nette\Object; | ||
use Nette\Utils\FileSystem; | ||
|
||
|
||
|
||
/** | ||
* @author Martin Štekl <[email protected]> | ||
*/ | ||
class CriticalSection extends Object | ||
{ | ||
|
||
|
@@ -23,27 +20,17 @@ class CriticalSection extends Object | |
*/ | ||
private $lockFilesDir; | ||
|
||
|
||
|
||
/** | ||
* @param string $lockFilesDir | ||
*/ | ||
public function __construct($lockFilesDir) | ||
public function __construct(string $lockFilesDir) | ||
{ | ||
$lockFilesDir = rtrim($lockFilesDir, DIRECTORY_SEPARATOR); | ||
FileSystem::createDir($lockFilesDir); | ||
$this->lockFilesDir = $lockFilesDir; | ||
} | ||
|
||
|
||
|
||
/** | ||
* Enters critical section. | ||
* | ||
* @param string $label | ||
* @return bool | ||
*/ | ||
public function enter($label) | ||
public function enter(string $label) : bool | ||
{ | ||
if ($this->isEntered($label)) { | ||
return FALSE; | ||
|
@@ -57,22 +44,18 @@ public function enter($label) | |
$locked = flock($handle, LOCK_EX | LOCK_NB); | ||
if ($locked === FALSE) { | ||
fclose($handle); | ||
|
||
return FALSE; | ||
} | ||
$this->locks[$label] = $handle; | ||
|
||
return TRUE; | ||
} | ||
|
||
|
||
|
||
/** | ||
* Leaves critical section. | ||
* | ||
* @param string $label | ||
* @return bool | ||
*/ | ||
public function leave($label) | ||
public function leave(string $label) : bool | ||
{ | ||
if (!$this->isEntered($label)) { | ||
return FALSE; | ||
|
@@ -89,26 +72,15 @@ public function leave($label) | |
return TRUE; | ||
} | ||
|
||
|
||
|
||
/** | ||
* Returns TRUE if critical section is entered. | ||
* | ||
* @param string $label | ||
* @return bool | ||
*/ | ||
public function isEntered($label) | ||
public function isEntered(string $label) : bool | ||
{ | ||
return array_key_exists($label, $this->locks) && $this->locks[$label] !== NULL; | ||
} | ||
|
||
|
||
|
||
/** | ||
* @param string $label | ||
* @return string | ||
*/ | ||
private function getFilePath($label) | ||
private function getFilePath(string $label) : string | ||
{ | ||
return $this->lockFilesDir . "/" . sha1($label); | ||
} | ||
|
Oops, something went wrong.