예제 #1
0
 /**
  * Prints out the help for a specific task
  *
  */
 public function action_help()
 {
     $tasks = Minion_Util::compile_task_list(Kohana::list_files('classes/minion/task'));
     $view = NULL;
     if (empty($this->_task)) {
         $view = new View('minion/help/list');
         $view->tasks = $tasks;
     } else {
         $inspector = new ReflectionClass($this->_retrieve_task());
         list($description, $tags) = Minion_Util::parse_doccomment($inspector->getDocComment());
         $view = View::factory('minion/help/task')->set('description', $description)->set('tags', (array) $tags)->set('task', $this->_task);
     }
     echo $view;
 }
예제 #2
0
 /**
  * Compiles a list of available tasks from a directory structure
  *
  * @param  array Directory structure of tasks
  * @return array Compiled tasks
  */
 public static function compile_task_list(array $files, $prefix = '')
 {
     $output = array();
     foreach ($files as $file => $path) {
         $file = substr($file, strrpos($file, DIRECTORY_SEPARATOR) + 1);
         if (is_array($path) and count($path)) {
             $task = Minion_Util::compile_task_list($path, $prefix . $file . Minion_Util::$task_separator);
             if ($task) {
                 $output = array_merge($output, $task);
             }
         } else {
             $output[] = strtolower($prefix . substr($file, 0, -strlen(EXT)));
         }
     }
     return $output;
 }
예제 #3
0
 /**
  * Tests that compile_task_list accurately creates a list of tasks from a directory structure
  *
  * @test
  * @covers Minion_Util::compile_task_list
  * @dataProvider provider_compile_task_list
  * @param array  Expected output
  * @param array  List of files
  * @param string Prefix to use
  * @param string Separator to use
  */
 public function test_compile_task_list($expected, $files, $prefix = '', $separator = ':')
 {
     $this->assertSame($expected, Minion_Util::compile_task_list($files, $prefix, $separator));
 }