Skip to content

Commit

Permalink
BUGFIX: updated compass to support load Gem_Path rather than the olde…
Browse files Browse the repository at this point in the history
…r load syntax. MINOR: remove inconsistencies in required gem definition
  • Loading branch information
wilr committed Jul 28, 2011
1 parent dfd09f9 commit 22c2288
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
19 changes: 11 additions & 8 deletions code/Compass.php
Expand Up @@ -23,20 +23,20 @@ class Compass extends Controller {
/**
* @var float Which version of sass should we use
*/
static $sass_version = 3;
static $sass_version = '3';

/**
* @var array map of required gems for each version
*/
static $required_gems = array(
2 => array(
'yard', 'maruku', 'haml' => '~> 2.2', 'compass' => '~> 0.8.0', 'compass-colors'
'2' => array(
'yard' => '', 'maruku' => '', 'haml' => '~> 2.2', 'compass' => '~> 0.8.0', 'compass-colors' => ''
),
3 => array(
'yard', 'maruku', 'haml-edge' => '~> 3.0', 'compass' => '~> 0.10.6', 'compass-colors' // requires edge as it has scss support
'3' => array(
'yard' => '', 'maruku' => '', 'haml' => '~> 3.1', 'compass' => '~> 0.11.5', 'compass-colors' => ''
),
'latest' => array(
'yard', 'maruku', 'haml-edge', 'compass', 'compass-colors'
'yard' => '', 'maruku' => '', 'haml-edge' => '', 'compass' => '', 'compass-colors' => ''
)
);

Expand All @@ -51,8 +51,11 @@ protected function checkGems() {
self::$check_gems_result = true;

foreach (self::$required_gems[self::$sass_version] as $gem => $version) {
if (is_numeric($gem)) { $gem = $version; $version = null; }
if ($error = Rubygems::require_gem($gem, $version)) self::$check_gems_result = $error;
if(!$version) $version = ">= 0";

if($error = Rubygems::require_gem($gem, $version)) {
self::$check_gems_result = $error;
}
}
}

Expand Down
14 changes: 11 additions & 3 deletions code/Rubygems.php
Expand Up @@ -120,13 +120,21 @@ static function run($gems, $command, $args="", &$out, &$err) {
if (is_string($gems)) $reqs[] = "-e 'gem \"$gem\", \">= 0\"'";
else {
foreach ($gems as $gem => $version) {
if (is_numeric($gem)) { $gem = $version; $version = '>= 0'; }
if (!$version) {
$version = '>= 0';
}

$reqs[] = "-e 'gem \"$gem\", \"$version\"'";
}
}

$version = (isset($gems[$command])) ? $gems[$command] : ">= 0";

$reqs = implode(' ', $reqs);

return self::_run("ruby -rubygems $reqs -e 'load \"$command\"' -- $args", $out, $err);
return self::_run(
sprintf("ruby -rubygems $reqs -e 'load Gem.bin_path(\"%s\", \"%s\", \"%s\")' -- $args", $command, $command, $version),
$out,
$err
);
}
}

0 comments on commit 22c2288

Please sign in to comment.