示例#1
0
 /**
  * Execute task and return report info
  *
  * @return \Deployer\Task\Min
  */
 public function execute()
 {
     $info = '';
     $dir = \Deployer::applyGlobalParams($this->param('dir'));
     $finder = new Finder();
     $iterator = $finder->files();
     $overallDecrease = 0;
     foreach ($this->param('name') as $name) {
         $iterator->name(\Deployer::applyGlobalParams($name));
     }
     $files = $iterator->in($dir);
     foreach ($files as $file) {
         $fileName = str_replace('/', DIRECTORY_SEPARATOR, $file);
         list($decreasePrecent, $decreaseBytes) = $this->_min($fileName);
         $overallDecrease += $decreaseBytes;
         $info .= sprintf('%s file decreased at %01.2f%% (%s)', \Deployer::censor($fileName), $decreasePrecent, \Deployer::size($decreaseBytes)) . PHP_EOL;
     }
     $message = sprintf('%d files minifyed at %s', sizeof($files), \Deployer::size($overallDecrease));
     \Deployer::messageInfo($message);
     $info .= $message . PHP_EOL;
     if (!empty($info)) {
         return $this->info($info);
     }
     return $this;
 }
示例#2
0
 /**
  * Send deployment report to dropbox account
  *
  * @return \Deployer
  */
 public function report()
 {
     $reports = array();
     $allReports = sizeof($this->_report);
     if ($allReports > 0) {
         self::messageHeader('Sending reports');
     }
     foreach ($this->_report as $report) {
         $provider = $report['provider'];
         $format = isset($report['format']) ? $report['format'] : 'txt';
         if (!isset($reports[$format])) {
             list($reports[$format]['mime'], $reports[$format]['data']) = $this->_logger->report($format);
             $reprts[$format]['data'] = \Deployer::censor($reports[$format]['data']);
         }
         $message = \Deployer\Report::instance($provider)->params($report)->mime($reports[$format]['mime'])->data($reports[$format]['data'])->send()->report();
         \Deployer\CLI::writeLn(sprintf(' * %s', $message));
     }
     if ($allReports > 0) {
         \Deployer\CLI::writeLn();
     }
     return $this;
 }