Skip to content

Commit

Permalink
update project configs and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
juliangut committed May 22, 2016
1 parent c3b6268 commit 7e83bba
Show file tree
Hide file tree
Showing 49 changed files with 543 additions and 3,017 deletions.
1 change: 0 additions & 1 deletion .coveralls.yml
@@ -1,2 +1 @@
service_name: travis-ci
src_dir: src
1 change: 0 additions & 1 deletion .gitattributes
Expand Up @@ -7,5 +7,4 @@
.coveralls.yml export-ignore
.scrutinizer.yml export-ignore
Gruntfile.js export-ignore
phpmd.xml export-ignore
phpunit.xml export-ignore
5 changes: 3 additions & 2 deletions .gitignore
@@ -1,6 +1,7 @@
!.gitignore
composer.lock
composer.phar
vendor/
!composer.lock
build/
node_modules/
.yo-rc.json
dist/
6 changes: 2 additions & 4 deletions .scrutinizer.yml
Expand Up @@ -65,14 +65,12 @@ tools:
paths: [src, tests]
php_cpd:
enabled: true
excluded_dirs: [build, tests, vendor]
excluded_dirs: [dist, tests, vendor]
php_mess_detector:
enabled: true
config:
ruleset: phpmd.xml
php_loc:
enabled: true
excluded_dirs: [build, tests, vendor]
excluded_dirs: [dist, tests, vendor]
php_pdepend: true
php_analyzer: true
sensiolabs_security_checker: true
Expand Down
46 changes: 32 additions & 14 deletions .styleci.yml
@@ -1,19 +1,36 @@
preset: psr2

enabled:
- binary_operator_spaces
- blank_line_before_return
- concat_with_spaces
- duplicate_semicolon
#- concat_without_spaces
- function_typehint_space
- multiline_array_trailing_comma
- multiline_spaces_before_semicolon
- newline_after_open_tag
- operators_spaces
- hash_to_slash_comment
- include
- lowercase_cast
- method_separation
- native_function_casing
- no_blank_lines_after_class_opening
- no_blank_lines_between_uses
- no_duplicate_semicolons
- no_leading_import_slash
- no_leading_namespace_whitespace
- no_multiline_whitespace_before_semicolons
- no_php4_constructor
- no_short_bool_cast
- no_singleline_whitespace_before_semicolons
- no_trailing_comma_in_singleline_array
- no_unreachable_default_argument_value
- no_unused_imports
- no_whitespace_before_comma_in_array
- ordered_imports
- phpdoc_align
- phpdoc_indent
- phpdoc_inline_tag
- phpdoc_no_empty_return
- phpdoc_no_access
- phpdoc_no_package
- phpdoc_no_simplified_null_return
- phpdoc_order
- phpdoc_property
- phpdoc_scalar
Expand All @@ -23,16 +40,17 @@ enabled:
- phpdoc_type_to_var
- phpdoc_types
- phpdoc_var_without_name
- remove_leading_slash_use
- remove_lines_between_uses
- return
- print_to_echo
- short_array_syntax
- single_array_no_trailing_comma
- single_blank_line_before_namespace
- spaces_before_semicolon
- short_scalar_cast
- simplified_null_return
- single_quote
- spaces_cast
- standardize_not_equal
- ternary_operator_spaces
- trailing_comma_in_multiline_array
- trim_array_spaces
- unary_operators_spaces
- unused_use
- unary_operator_spaces
#- not_operator_with_successor_space
- whitespace_after_comma_in_array
- whitespacy_lines
12 changes: 6 additions & 6 deletions .travis.yml
Expand Up @@ -16,14 +16,14 @@ matrix:
before_script:
- travis_retry composer self-update
- travis_retry composer install --no-interaction --prefer-source
- if [[ "$TRAVIS_PHP_VERSION" == '5.6' ]]; then travis_retry composer require satooshi/php-coveralls:dev-master ; fi
- if [[ "$TRAVIS_PHP_VERSION" == '5.6' ]]; then travis_retry composer require satooshi/php-coveralls:dev-master --no-interaction ; fi

script:
- vendor/bin/phpcs --standard=PSR2 src tests
- vendor/bin/phpmd src text phpmd.xml
- vendor/bin/phpcpd src
- if [[ "$TRAVIS_PHP_VERSION" != '5.6' ]]; then vendor/bin/phpunit ; fi
- if [[ "$TRAVIS_PHP_VERSION" == '5.6' ]]; then vendor/bin/phpcs --standard=PSR2 src tests ; fi
- if [[ "$TRAVIS_PHP_VERSION" == '5.6' ]]; then vendor/bin/phpmd src text unusedcode,naming,design,controversial,codesize ; fi
- if [[ "$TRAVIS_PHP_VERSION" == '5.6' ]]; then vendor/bin/phpcpd src ; fi
- if [[ "$TRAVIS_PHP_VERSION" == '5.6' ]]; then vendor/bin/phpunit --coverage-clover build/logs/clover.xml ; fi
- if [[ "$TRAVIS_PHP_VERSION" != '5.6' ]]; then vendor/bin/phpunit ; fi

after_script:
- if [[ "$TRAVIS_PHP_VERSION" == '5.6' ]]; then php vendor/bin/coveralls -v ; fi
- if [[ "$TRAVIS_PHP_VERSION" == '5.6' ]]; then travis_retry php vendor/bin/coveralls -v ; fi
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Expand Up @@ -15,7 +15,7 @@ Find here a few rules to follow in order to keep the code clean and easy to revi

[Grunt](http://gruntjs.com/) tasks are provided to help you keep code quality and run the test suite

- `grunt check` will run PHP linting, [PHP Code Sniffer](https://github.com/squizlabs/PHP_CodeSniffer) for style guidelines, [PHPMD](https://github.com/phpmd/phpmd) for code smells and [PHPCPD](https://github.com/sebastianbergmann/phpcpd) for copy/paste detection
- `grunt security` will run [Climb](https://github.com/vinkla/climb) to verify Composer dependencies and [Security Checker](https://github.com/sensiolabs/security-checker) to check dependencies known vulnerabilities
- `grunt qa` will run PHP linting, [PHP Code Sniffer](https://github.com/squizlabs/PHP_CodeSniffer) for coding style guidelines, [PHPMD](https://github.com/phpmd/phpmd) for code smells and [PHPCPD](https://github.com/sebastianbergmann/phpcpd) for copy/paste detection
- `grunt test` will run [PHPUnit](https://github.com/sebastianbergmann/phpunit) for unit tests
- `grunt` will run all previous commands at once
- `grunt security` will run [Composer](https://getcomposer.org) (>=1.1.0) for outdated dependencies and [Security checker](https://github.com/sensiolabs/security-checker) for dependencies with known issues
- `grunt` will run `qa` and `test` tasks at once
93 changes: 17 additions & 76 deletions Gruntfile.js
@@ -1,84 +1,25 @@
'use strict';

module.exports = function(grunt) {
require('time-grunt')(grunt);
require('load-grunt-tasks')(grunt);
require('jit-grunt')(grunt);

grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
grunt.loadNpmTasks('grunt-composer');

phplint: {
options: {
swapPath: '/tmp'
},
application: [
'src/**/*.php',
'tests/**/*.php'
]
},
phpcs: {
options: {
bin: 'vendor/bin/phpcs',
standard: 'PSR2'
},
application: {
dir: [
'src',
'tests'
]
}
},
phpmd: {
options: {
bin: 'vendor/bin/phpmd',
rulesets: 'phpmd.xml',
reportFormat: 'text'
},
application: {
dir: 'src'
}
},
phpcpd: {
options: {
bin: 'vendor/bin/phpcpd',
quiet: false,
ignoreExitCode: true
},
application: {
dir: 'src'
}
},
climb: {
options: {
bin: 'vendor/bin/climb',
exclude: [
'phpunit/phpunit'
]
},
application: {
directory: './'
}
},
security_checker: {
options: {
bin: 'vendor/bin/security-checker',
format: 'text'
},
application: {
file: 'composer.json'
},
},
phpunit: {
options: {
bin: 'vendor/bin/phpunit',
coverage: true
},
application: {
coverageHtml: 'build/coverage'
}
var settings = {
config: {
src: ['grunt/*.js']
}
});
};
grunt.initConfig(require('load-grunt-configs')(grunt, settings));

grunt.registerTask('check', ['phplint', 'phpcs', 'phpmd', 'phpcpd']);
grunt.registerTask('security', ['climb', 'security_checker']);
grunt.registerTask('qa', ['phplint', 'phpcs', 'phpmd', 'phpcpd']);
grunt.registerTask('test', ['phpunit']);
grunt.registerTask('default', ['check', 'security', 'test']);
grunt.registerTask('security', ['composer:outdated:direct', 'security_checker']);

grunt.task.registerTask('build', 'Project build', function() {
grunt.log.writeln('Task ready to be implemented');
});

grunt.registerTask('default', ['qa', 'test']);
};
20 changes: 11 additions & 9 deletions README.md
Expand Up @@ -9,13 +9,15 @@

# Janitor

Effortless maintenance management.
Effortless maintenance management for PSR7.

Janitor is a ready to use PSR7 middleware that provides you with an easy configurable and extensible way to handle maintenance mode on your project, because maintenance handling goes beyond responding to the user with an HTTP 503 code and a simple message.
Janitor is a ready to use PSR7 package that provides you with an easy configurable and extensible way to handle maintenance mode on your project, because maintenance handling goes beyond responding to the user with an HTTP 503 code and a simple message.

Set several conditions that will be checked to determine if the maintenance handler should be triggered. This conditions are of two kinds, 'activation' conditions (name `watchers`) and conditions to bypass the normal execution (named `excluders`). Default watchers and excluders allows you to cover a wide range of situations so you can drop Janitor in and start in no time, but if needed it's very easy to create your own conditions.
Set several conditions that will be checked to determine if the maintenance handler should be triggered. This conditions are of two kinds, 'activation' conditions (named `watchers`) and conditions to bypass the normal execution (named `excluders`).

Once Janitor has determine maintenance mode is active it let you use your handler to get a response ready for the user or you can let Janitor handle it all by itself (a nicely formatted 503 response).
Already builtin watchers and excluders allows you to cover a wide range of situations so you can drop Janitor in and start in no time, but at the same time it's very easy to create your own conditions if needed.

Once Janitor has determined maintenance mode is active it let you use your handler to get a response ready for the user or you can let Janitor handle it all by itself (a nicely formatted 503 response).

> Learn more in [Janitor's page](http://juliangut.com/janitor)
Expand Down Expand Up @@ -58,7 +60,7 @@ $excluders = [
];

$handler = function (ServerRequestInterface $request, ResponseInterface $response, Watcher $watcher) {
$response->getBody()->write('I am in maintenance mode!');
$response->getBody()->write('This page is in maintenance mode!');

return $response;
}
Expand All @@ -83,7 +85,7 @@ $response = $janitor(
Watchers serve different means to activate maintenance mode by verifying conditions to be met.

* `Manual` Just set it to be active. Useful to be used with a configuration parameter.
* `File` Checks the existance of the provided file.
* `File` Checks the existence of the provided file.
* `Environment` Checks if an environment variable is set to a value.

```php
Expand All @@ -100,7 +102,7 @@ $envWatcher = new \Janitor\Watcher\Environment('maintenance', 'ON');
$envWatcher->isActive();
```

### Scheduled whatchers
### Scheduled watchers

Scheduled watchers are a special type of watchers that identify a point in time in the future for a maintenance period.

Expand Down Expand Up @@ -181,7 +183,7 @@ function (\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\R
Two really basic handlers are suplied by default to cope with maintenance mode.

* `Render` Sets response with 503 code and add basic formatted maintenance output based on request's Accept header.
* `Redirect` Prepares response to be a 302 redirection to a configured URL (tipically maintenance page).
* `Redirect` Prepares response to be a 302 redirection to a configured URL (typically maintenance page).

Of the two `Render` will be automatically created and used in case none is provided.

Expand Down Expand Up @@ -249,7 +251,7 @@ $app->run();

### Symfony's HttpFoundation

If using Symfony's HttpFoundation you can still add Janitor to your toolbelt by using Symfony's [PSR HTTP message bridge](https://github.com/symfony/psr-http-message-bridge)
If using Symfony's HttpFoundation you can still add Janitor to your tool belt by using Symfony's [PSR HTTP message bridge](https://github.com/symfony/psr-http-message-bridge)

An example using Silex

Expand Down
29 changes: 19 additions & 10 deletions composer.json
@@ -1,32 +1,41 @@
{
"name": "juliangut/janitor",
"description": "Maintenance mode",
"description": "Effortless maintenance management",
"keywords": [
"php"
"php",
"maintenance",
"cron"
],
"homepage": "http://juliangut.com/janitor",
"license": "BSD-3-clause",
"authors": [
{
"name": "Julián Gutiérrez",
"email": "juliangut@gmail.com",
"homepage": "https://github.com/juliangut/janitor"

"homepage": "http://juliangut.com",
"role": "Developer"
}
],
"support": {
"source": "https://github.com/juliangut/janitor",
"issues": "https://github.com/juliangut/janitor/issues"
},
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"php": ">=5.5",
"symfony/polyfill-php56": "^1.0",
"symfony/polyfill-php70": "^1.0",
"zendframework/zend-diactoros": "^1.3",
"psr/http-message": "^1.0",
"mtdowling/cron-expression": "^1.0",
"zendframework/zend-diactoros": "^1.3"
"mtdowling/cron-expression": "^1.0"
},
"require-dev": {
"phpunit/phpunit": "^4.5",
"squizlabs/php_codesniffer": "^2.0",
"phpmd/phpmd": "^2.0",
"phpunit/phpunit": "^4.5|^5.0",
"sebastian/phpcpd": "^2.0",
"vinkla/climb": "~0.8",
"sensiolabs/security-checker": "^3.0"
"sensiolabs/security-checker": "^3.0",
"squizlabs/php_codesniffer": "^2.0"
},
"autoload": {
"psr-4": {
Expand Down

0 comments on commit 7e83bba

Please sign in to comment.