function SassyBaseUnitTest::requirePHPSassLibrary in Sassy 7.2
Require the PHPSass Library.
We try to include it from the local site if it's around, otherwise we try a few known locations, and then failing all of that we fall back to downloading it from the web.
1 call to SassyBaseUnitTest::requirePHPSassLibrary()
- SassyBaseUnitTest::setUp in ./
sassy.test - Sets up a Drupal site for running functional and integration tests.
File
- ./
sassy.test, line 37
Class
- SassyBaseUnitTest
- Base class for Sassy tests.
Code
function requirePHPSassLibrary() {
// Allow people to specify the library before we are called.
if (isset($this->phpsass_library_path)) {
}
elseif (($library_path = libraries_get_path('phpsass')) && file_exists($library_path . '/SassParser.php')) {
$this->phpsass_library_path = $library_path;
}
elseif (file_exists(drupal_get_path('module', 'sassy') . '/phpsass/SassParser.php')) {
$this->phpsass_library_path = drupal_get_path('module', 'sassy') . '/phpsass';
}
else {
// We try to download the zipball or tarball for PHPSass.
// Include some files we're going to need.
include DRUPAL_ROOT . '/includes/archiver.inc';
module_enable(array(
'update',
));
module_load_include('inc', 'update', 'update.manager');
module_load_include('inc', 'system', 'system.archiver');
// Get details of all archivers.
$archiver_info = archiver_get_info();
$url = '';
if (isset($archiver_info['zip'])) {
$url = 'https://github.com/richthegeek/phpsass/zipball/master';
$extension = '.zip';
}
elseif (isset($archiver_info['tar'])) {
$url = 'https://github.com/richthegeek/phpsass/tarball/master';
$extension = '.tar.gz';
}
if (!empty($url) && ($local_cache = update_manager_file_get($url))) {
$local_cache = file_unmanaged_copy($local_cache, $local_cache . '.phpsass' . $extension, FILE_EXISTS_REPLACE);
$extract_directory = $this
->libraryExtractLocation();
try {
update_manager_archive_extract($local_cache, $extract_directory);
$dirs = file_scan_directory($extract_directory, '/.*/', array(
'recurse' => FALSE,
));
foreach ($dirs as $uri => $dir) {
if (file_exists($uri . '/SassParser.php')) {
$this->phpsass_library_path = drupal_realpath($uri);
break;
}
}
} catch (Exception $e) {
$this
->error($e
->getMessage());
}
}
}
if (isset($this->phpsass_library_path)) {
require_once $this->phpsass_library_path . '/SassParser.php';
}
else {
throw new Exception('Could not find PHPSass compiler.');
}
}