Browse Source

Some fixed code for new refactoring version

* Added Licence
* Added travis file
* Edited README.md
* Added humans
* Fixed some CS
* Added .gitignore
Marc 11 years ago
parent
commit
580b399fb8

+ 12 - 0
.gitignore

@@ -0,0 +1,12 @@
+.idea
+.DS_Store
+build
+phpunit.xml
+Resources/doc/_build/*
+nbproject
+coverage
+composer.lock
+vendor
+composer.phar
+phpcs.lo
+phpcs.log

+ 15 - 0
.travis.yml

@@ -0,0 +1,15 @@
+language: php
+
+php:
+    - 5.3
+    - 5.4
+    - 5.5
+
+matrix:
+    allow_failures:
+        - php: 5.5
+
+before_script:
+    - composer install --dev
+
+script: phpunit

+ 19 - 0
LICENSE

@@ -0,0 +1,19 @@
+Copyright (c) Marc Morera <yuhu@mmoreram.com>
+
+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.

+ 3 - 3
Module/JobClass.php

@@ -84,7 +84,7 @@ class JobClass extends ContainerAware
     /**
      * Construct method
      *
-     * @param JobAnnotation    $jobAnnotation  jobAnnotation class
+     * @param JobAnnotation    $jobAnnotation     JobAnnotation class
      * @param ReflectionMethod $method            ReflextionMethod class
      * @param string           $callableNameClass Callable name class
      * @param array            $servers           Array of servers defined for Worker
@@ -141,8 +141,8 @@ class JobClass extends ContainerAware
     /**
      * Load settings
      * 
-     * @param WorkAnnotation $JobAnnotation   JobAnnotation class
-     * @param array          $defaultSettings Default settings for Worker
+     * @param JobAnnotation $jobAnnotation   JobAnnotation class
+     * @param array         $defaultSettings Default settings for Worker
      * 
      * @return JobClass self Object
      */

+ 0 - 1
Module/WorkerClass.php

@@ -148,7 +148,6 @@ class WorkerClass
         $this->className = $reflectionClass->getName();
         $this->service = $workAnnotation->service;
 
-        
         $this
             ->loadSettings($workAnnotation, $defaultSettings)
             ->loadServers($workAnnotation, $servers)

+ 29 - 0
README.md

@@ -1,5 +1,27 @@
+![Gearman Bundle](http://mmoreram.github.io/gearman-bundle/gearmanbundle-logo.png)
+
+[![Scrutinizer Quality Score](https://scrutinizer-ci.com/g/mmoreram/gearman-bundle/badges/quality-score.png?s=1b65ccb8a983546f3ed776ebc33bc0d63d956e93)](https://scrutinizer-ci.com/g/mmoreram/gearman-bundle/)
+
 #GearmanBundle for Symfony2
 
+> This bundle is being refactored.  
+> All tests are being performed and will be published as soon as possible.  
+> All help will be very grateful.  
+> My apologies for all possible issues caused by this changed.  
+> I am at your disposal.  
+>  
+> Marc Morera  
+
+##About
+
+GearmanBundle is a bundle for Symfony2 intended to provide an easy way to support developers who need to use job queues. For example: mail queues, Solr generation queues or Database upload queues.
+
+##Branches
+
+* Use version `2.1` for Symfony2 `2.1.*`
+* Use version `2.2` for Symfony2 `2.2.*`
+* Use version `2.3` or the `master` for Symfony2 `2.3.*`
+
 ##Installation
 You have to add require line into you composer.json file
 
@@ -391,3 +413,10 @@ You can request a Job by using the gearman service.
 * addTaskLowBackground : Add a low priority background task to be run in parallel
 * runTasks : Run a list of tasks in parallel
 
+##Contribute
+
+All code is Symfony2 Code formatted, so every pull request must validate phpcs standards.  
+You should read [Symfony2 coding standards](http://symfony.com/doc/current/contributing/code/standards.html) and install [this](https://github.com/opensky/Symfony2-coding-standard) CodeSniffer to check all code is validated.  
+
+There is also a policy for contributing to this project. All pull request must be all explained step by step, to make us more understandable and easier to merge pull request. All new features must be tested with PHPUnit.
+

+ 8 - 2
Service/GearmanCacheWrapper.php

@@ -252,6 +252,9 @@ class GearmanCacheWrapper
 
     /**
      * Load all workers with their jobs
+     * 
+     * @param Finder $finder Finder
+     * @param Reader $reader Reader
      *
      * @return WorkerCollection collection of all info
      */
@@ -259,7 +262,7 @@ class GearmanCacheWrapper
     {
 
         $workerCollection = new WorkerCollection;
-        
+
         /**
          * Every file found is parsed
          */
@@ -302,14 +305,17 @@ class GearmanCacheWrapper
      * @param string $file A PHP file path
      *
      * @return string|false Full class name if found, false otherwise
+     * 
+     * @todo Find another way more tidy and clean of getting file namespace
      */
     protected function getFileClassNamespace($file)
     {
         $class = false;
         $namespace = false;
         $tokens = token_get_all(file_get_contents($file));
+
         for ($i = 0, $count = count($tokens); $i < $count; $i++) {
-            
+
             $token = $tokens[$i];
 
             if (!is_array($token)) {

+ 2 - 2
Service/GearmanClient.php

@@ -15,8 +15,8 @@ use Mmoreram\GearmanBundle\Exceptions\NoCallableGearmanMethodException;
 
 /**
  * Implementation of GearmanInterface
- *
- * @author Marc Morera <yuhu@mmoreram.com>
+ * 
+ * @todo Find the way of reducing number of class methods
  */
 class GearmanClient extends AbstractGearmanService
 {

+ 0 - 2
Service/GearmanDescriber.php

@@ -68,7 +68,6 @@ class GearmanDescriber
         $output->writeln('<info>    @job\supervisord : </info><comment>/usr/bin/php ' . $script.' ' . $job['realCallableName'] . ' --no-interaction</comment>');
         $output->writeln('<info>    @job\iterations : ' . $job['iterations'] . '</info>');
         $output->writeln('<info>    @job\defaultMethod : ' . $job['defaultMethod'] . '</info>');
-        
 
         /**
          * Printed every server is defined for current job
@@ -127,7 +126,6 @@ class GearmanDescriber
         $output->writeln('<info>    @worker\iterations : ' . $worker['iterations'] . '</info>');
         $output->writeln('<info>    @Worker\#jobs : '.count($worker['jobs']).'</info>');
 
-
         if ($tinyJobDescription) {
             $output->writeln('<info>    @Worker\jobs</info>');
             $output->writeln('');

+ 2 - 2
Service/GearmanExecute.php

@@ -86,7 +86,7 @@ class GearmanExecute extends AbstractGearmanService
 
         $objInstance = $this->createJob($worker);
         $this->runJob($gearmanWorker, $objInstance, $jobs);
-        
+
         return $this;
     }
 
@@ -94,7 +94,7 @@ class GearmanExecute extends AbstractGearmanService
     /**
      * Given a worker settings, return Job instance
      * 
-     * @parma array $worker Worker settings
+     * @param array $worker Worker settings
      * 
      * @return Object Job instance
      */

+ 9 - 4
composer.json

@@ -19,10 +19,15 @@
         }
     ],
     "require": {
-        "php": ">=5.3.2",
-        "symfony/framework-bundle": ">=2.0",
-        "liip/doctrine-cache-bundle": "dev-master",
-        "ext-gearman": "*"
+        "php": ">=5.3.3",
+        "ext-gearman": "*",
+        "symfony/framework-bundle": ">=2.2.3",
+        "doctrine/annotations": "1.0.*@dev",
+        "symfony/console": ">=2.2.3",
+        "symfony/config": ">=2.2.3",
+        "symfony/http-kernel": ">=2.2.3",
+        "symfony/dependency-injection": ">=2.2.3",
+        "liip/doctrine-cache-bundle": "dev-master"
     },
     "target-dir": "Mmoreram/GearmanBundle",
     "autoload": {

+ 12 - 0
humans.txt

@@ -0,0 +1,12 @@
+/* TEAM */            
+Creator : Marc Morera 
+Site: https://github.com/mmoreram/gearman-bundle
+Contact: yuhu at mmoreram dot com
+Twitter: mmoreram                   
+Location: Barcelona, Catalunya, Catalunya.
+
+/* THANKS */
+http://gearman.org/
+http://github.com
+http://symfony.com
+Fabien Potencier