[limb-svn] r5548 - in 3.x/trunk/limb/file_schema: src tests/cases

svn at limb-project.com svn at limb-project.com
Fri Apr 6 11:39:14 MSD 2007


Author: pachanga
Date: 2007-04-06 11:39:14 +0400 (Fri, 06 Apr 2007)
New Revision: 5548
URL: http://fisheye.limb-project.com/changelog/limb/?cs=5548

Modified:
   3.x/trunk/limb/file_schema/src/lmbCachingFileLocator.class.php
   3.x/trunk/limb/file_schema/src/lmbFileAliasTools.class.php
   3.x/trunk/limb/file_schema/tests/cases/lmbCachingFileLocatorTest.class.php
Log:
-- lmbCachingFileLocator LIMB_VAR_DIR dependency removed, cache dir must be specified explicitly
-- lmbFileAliasTools passes LIMB_VAR_DIR . '/locators/' when instantiating lmbCachingFileLocator

Modified: 3.x/trunk/limb/file_schema/src/lmbCachingFileLocator.class.php
===================================================================
--- 3.x/trunk/limb/file_schema/src/lmbCachingFileLocator.class.php	2007-04-06 06:47:15 UTC (rev 5547)
+++ 3.x/trunk/limb/file_schema/src/lmbCachingFileLocator.class.php	2007-04-06 07:39:14 UTC (rev 5548)
@@ -1,13 +1,13 @@
 <?php
-/**
- * Limb Web Application Framework
- *
- * @link http://limb-project.com
- *
- * @copyright  Copyright &copy; 2004-2007 BIT
- * @license    LGPL http://www.gnu.org/copyleft/lesser.html
- * @version    $Id$
- * @package    file_schema
+/**
+ * Limb Web Application Framework
+ *
+ * @link http://limb-project.com
+ *
+ * @copyright  Copyright &copy; 2004-2007 BIT
+ * @license    LGPL http://www.gnu.org/copyleft/lesser.html
+ * @version    $Id$
+ * @package    file_schema
  */
 lmb_require('limb/file_schema/src/lmbFileLocatorDecorator.class.php');
 lmb_require('limb/util/src/system/lmbFs.class.php');
@@ -18,9 +18,10 @@
   protected $_changed = false;
   protected $_cache_name;
 
-  function __construct($locator, $_cache_name = 'generic')
+  function __construct($locator, $cache_dir, $cache_name = 'default')
   {
-    $this->_cache_name = $_cache_name;
+    $this->_cache_name = $cache_name;
+    $this->_cache_dir = $cache_dir;
 
     parent :: __construct($locator);
 
@@ -34,9 +35,8 @@
 
   function getCacheFile()
   {
-    $cache_file = LIMB_VAR_DIR . '/locators/' . $this->_cache_name  . '_locator.cache';
-    lmbFs :: mkdir(LIMB_VAR_DIR . '/locators/');
-
+    lmbFs :: mkdir($this->_cache_dir);
+    $cache_file = $this->_cache_dir . '/' . $this->_cache_name  . '_locator.cache';
     return $cache_file;
   }
 
@@ -49,7 +49,7 @@
       unlink($cache_file);
   }
 
-  protected function _loadCache()
+  function _loadCache()
   {
     $cache_file = $this->getCacheFile();
     if(!file_exists($cache_file))

Modified: 3.x/trunk/limb/file_schema/src/lmbFileAliasTools.class.php
===================================================================
--- 3.x/trunk/limb/file_schema/src/lmbFileAliasTools.class.php	2007-04-06 06:47:15 UTC (rev 5547)
+++ 3.x/trunk/limb/file_schema/src/lmbFileAliasTools.class.php	2007-04-06 07:39:14 UTC (rev 5548)
@@ -18,25 +18,27 @@
 {
   protected $file_locators = array();
 
-  function findFileAlias($name, $paths, $file_group)
+  function findFileAlias($name, $paths, $files_group)
   {
-    $locator = $this->toolkit->getFileLocator($paths, $file_group);
+    $locator = $this->toolkit->getFileLocator($paths, $files_group);
     return $locator->locate($name);
   }
 
-  function getFileLocator($path, $file_group)
+  function getFileLocator($path, $files_group)
   {
-    if(isset($this->file_locators[$path][$file_group]))
-       return $this->file_locators[$path][$file_group];
+    if(isset($this->file_locators[$path][$files_group]))
+       return $this->file_locators[$path][$files_group];
 
     $file_locations = new lmbIncludePathFileLocations(explode(';', $path));
 
     if(defined('LIMB_VAR_DIR'))
-      $locator = new lmbCachingFileLocator(new lmbFileLocator($file_locations), $file_group);
+      $locator = new lmbCachingFileLocator(new lmbFileLocator($file_locations),
+                                           LIMB_VAR_DIR . '/locators/',
+                                           $files_group);
     else
       $locator = new lmbFileLocator($file_locations);
 
-    $this->file_locators[$path][$file_group] = $locator;
+    $this->file_locators[$path][$files_group] = $locator;
     return $locator;
   }
 }

Modified: 3.x/trunk/limb/file_schema/tests/cases/lmbCachingFileLocatorTest.class.php
===================================================================
--- 3.x/trunk/limb/file_schema/tests/cases/lmbCachingFileLocatorTest.class.php	2007-04-06 06:47:15 UTC (rev 5547)
+++ 3.x/trunk/limb/file_schema/tests/cases/lmbCachingFileLocatorTest.class.php	2007-04-06 07:39:14 UTC (rev 5548)
@@ -1,13 +1,13 @@
 <?php
-/**
- * Limb Web Application Framework
- *
- * @link http://limb-project.com
- *
- * @copyright  Copyright &copy; 2004-2007 BIT
- * @license    LGPL http://www.gnu.org/copyleft/lesser.html
- * @version    $Id$
- * @package    file_schema
+/**
+ * Limb Web Application Framework
+ *
+ * @link http://limb-project.com
+ *
+ * @copyright  Copyright &copy; 2004-2007 BIT
+ * @license    LGPL http://www.gnu.org/copyleft/lesser.html
+ * @version    $Id$
+ * @package    file_schema
  */
 lmb_require('limb/file_schema/src/lmbFileLocator.class.php');
 lmb_require('limb/file_schema/src/lmbCachingFileLocator.class.php');
@@ -23,7 +23,7 @@
   {
     $this->wrapped_locator = new MockFileLocator();
 
-    $this->locator = new lmbCachingFileLocator($this->wrapped_locator);
+    $this->locator = new lmbCachingFileLocator($this->wrapped_locator, LIMB_VAR_DIR);
     $this->locator->flushCache();
 
     $this->cache_file = $this->locator->getCacheFile();
@@ -84,7 +84,7 @@
 
     $this->assertTrue(file_exists($this->cache_file));
 
-    $locator = new lmbCachingFileLocator($this->wrapped_locator);
+    $locator = new lmbCachingFileLocator($this->wrapped_locator, LIMB_VAR_DIR);
 
     unlink($this->cache_file);
 
@@ -112,7 +112,7 @@
 
     $this->wrapped_locator->expectNever('locate');
 
-    $local_locator = new lmbCachingFileLocator($this->wrapped_locator);
+    $local_locator = new lmbCachingFileLocator($this->wrapped_locator, LIMB_VAR_DIR);
 
     $this->assertEqual($local_locator->locate('path-to-file'), 'located-path-to-file');
 



More information about the limb-svn mailing list