Fixed bug in MagicDbTestData class

Added support for serialized sample arrays
Finished MagicDb parsing implementation
Began to implement analyzing
Updated tests

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5732 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
the_undefined 2007-10-08 01:25:33 +00:00
parent 366cb23a64
commit 8963c16c77
2 changed files with 51 additions and 8 deletions

View file

@ -40,6 +40,13 @@ class MagicDb extends Object {
**/
var $db = array();
/**
* The file currently being read. Can be a string or a file resource
*
* @var mixed
*/
var $_file = null;
/**
* Reads a MagicDb from various formats
*
@ -85,7 +92,7 @@ class MagicDb extends Object {
if (is_array($data)) {
return $data;
}
if (empty($data)) {
if ($data === null) {
return $this->db;
}
@ -117,11 +124,13 @@ class MagicDb extends Object {
$columns = explode("\t", $line);
if (in_array($columns[0]{0}, array('&', '>'))) {
$format[] = $columns;
} else {
} elseif (!empty($format)) {
$db['database'][] = $format;
$format = array();
}
}
return $db;
}
/**
@ -150,6 +159,16 @@ class MagicDb extends Object {
* @access public
*/
function analyze($file, $options = array()) {
if (!is_string($file)) {
return false;
}
if (file_exists($file)) {
$this->_file =& new File($file);
} else {
$this->_file = $file;
}
}
}

File diff suppressed because one or more lines are too long