Skip to content

Commit

Permalink
Merge pull request kamicane#1 from theshock/master
Browse files Browse the repository at this point in the history
Overall file
  • Loading branch information
slik committed Jul 20, 2011
2 parents d6159c5 + 48413a4 commit 19d2855
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions packager.php
Expand Up @@ -11,9 +11,10 @@ public static function warn($message){
fclose($std_err);
}

private $packages = array();
private $packages = array();
private $manifests = array();
private $root = null;
private $root = null;
private $overall = null;

public function __construct($package_paths){
foreach ((array)$package_paths as $package_path) $this->parse_manifest($package_path);
Expand Down Expand Up @@ -58,13 +59,21 @@ private function parse_manifest($path){
$manifest['manifest'] = $manifest_path;

$this->manifests[$package_name] = $manifest;

if(!is_array($manifest['sources'])){
$manifest['sources'] = $this->bfglob($package_path, $manifest['sources'], 0, 5);
$patternUsed = true;
}

if ( !empty($manifest['sources']) ) $this->overall = $manifest['sources'];

foreach ($manifest['sources'] as $i => $path){


if ($this->overall == $path) {
unset($manifest['sources'][$i]);
continue;
}

if(!isset($patternUsed)) $path = $package_path . $path;

// this is where we "hook" for possible other replacers.
Expand Down Expand Up @@ -99,7 +108,6 @@ private function parse_manifest($path){
));

}

}

public function add_package($package_path){
Expand Down Expand Up @@ -181,6 +189,12 @@ public function component_exists($name){
public function package_exists($name){
return array_contains($this->get_packages(), $name);
}

public function wrap_all ($code) {
if (!$this->overall) return $code;

return str_replace('/*** [Code] ***/', $code, file_get_contents( $this->overall ));
}

public function validate($more_files = array(), $more_components = array(), $more_packages = array()){

Expand Down Expand Up @@ -235,7 +249,7 @@ public function build($files = array(), $components = array(), $packages = array
$source = preg_replace_callback("%(/[/*])\s*<$block>(.*?)</$block>(?:\s*\*/)?%s", array($this, "block_replacement"), $source);
}

return $source . "\n";
return $this->wrap_all($source);
}

private function block_replacement($matches){
Expand Down

0 comments on commit 19d2855

Please sign in to comment.