Ejemplo n.º 1
0
 /**
  * Registers the filter to compile an array of files.
  *
  * @param T_Code_Group  group of files to compile
  * @return T_Compile  fluent interface
  */
 function compile(T_Code_Files $files)
 {
     // get source code
     $src = '';
     foreach ($files->getPaths() as $p) {
         $src .= file_get_contents($p);
     }
     // issue non-blocking request to google closure API to parse and optimize
     // the code
     $level = $files->isComplete() ? 'ADVANCED_OPTIMIZATIONS' : 'SIMPLE_OPTIMIZATIONS';
     $url = 'http://closure-compiler.appspot.com/compile';
     $params = array('output_format' => 'text', 'compilation_level' => $level, 'js_code' => $src, 'output_info' => 'compiled_code');
     $request = new T_Curl_Post($url, $params);
     $this->curl->queue($request);
     $this->request[] = $request;
     return $this;
 }
Ejemplo n.º 2
0
 function testCanSwitchIsCompleteOnFromDefaultOff()
 {
     $names = array('test1', 'test2');
     $ext = '.js';
     foreach ($names as $fn) {
         $p = T_CACHE_DIR . $fn . $ext;
         $expect[] = $p;
         touch($p);
     }
     $files = new T_Code_Files(T_CACHE_DIR, $names, $ext);
     $this->assertFalse($files->isComplete());
     $this->assertSame($files, $files->setComplete());
     $this->assertTrue($files->isComplete());
     foreach ($expect as $p) {
         @unlink($p);
     }
 }