Permalink
Browse files

Quick commit just cleaning up some code in preparation

Whitespace corrections
  • Loading branch information...
1 parent 5b529b8 commit a28e2b8877f2e8e74fc75fae8764fdb1d58456ad @seejohnrun committed Jan 23, 2012
View
@@ -44,4 +44,4 @@ And then you can load the package like so:
Go to your favorite CI project, and run (must have CURL installed):
- $ php -r "$(curl -fsSL http://www.getsparks.org/static/install.php)"
+ $ php -r "$(curl -fsSL http://www.getsparks.org/static/install.php)"
View
@@ -92,7 +92,7 @@ private function lister()
if (!is_dir(SPARK_PATH . "/$item/$ver") || $ver[0] == '.') continue;
Spark_utils::line("$item ($ver)");
}
- }
+ }
}
private function version()
@@ -145,7 +145,7 @@ private function failtown($error_message)
private function remove($args)
{
-
+
list($flats, $flags) = $this->prep_args($args);
if (count($flats) != 1)
@@ -172,11 +172,11 @@ private function remove($args)
{
Spark_utils::notice('Spark removed successfully!');
}
- else
+ else
{
Spark_utils::warning('Looks like that spark isn\'t installed');
}
- // attempt to clean up - will not remove unless empty
+ // attempt to clean up - will not remove unless empty
@rmdir(SPARK_PATH . "/$spark_name");
}
@@ -221,7 +221,7 @@ private function install($args)
private function reinstall($args)
{
-
+
list($flats, $flags) = $this->prep_args($args);
if (count($flats) != 1)
@@ -236,17 +236,17 @@ private function reinstall($args)
{
throw new Spark_exception("Please specify a version to reinstall, or use -f to remove all versions and install latest.");
}
-
+
$this->remove($args);
$this->install($args);
}
/**
* Prepares the command line arguments for use.
- *
+ *
* Usage:
* list($flats, $flags) = $this->prep_args($args);
- *
+ *
* @param array the arguments array
* @return array the flats and flags
*/
@@ -262,7 +262,7 @@ private function prep_args($args)
if (count($matches) != 3) continue;
$matches[0][0] == '-' ? $flags[$matches[1][1]] = $matches[2] : $flats[] = $matches[0];
}
-
+
return array($flats, $flags);
}
@@ -16,7 +16,7 @@ function __construct($url)
$this->version_data = json_decode(@file_get_contents("http://$this->url/api/system/latest"));
$this->version = $this->version_data->spark_manager;
$this->warn_if_outdated();
- }
+ }
function get_url()
{
@@ -87,7 +87,7 @@ function outdated() {
return SPARK_VERSION;
}
}
-
+
private function get_spark($data)
{
if ($data->repository_type == 'hg') return Mercurial_spark::get_spark($data);
View
@@ -19,7 +19,7 @@ function __construct($data)
{
if (!property_exists($this, $k)) $this->$k = $v;
}
-
+
// used internally
$this->temp_token = 'spark-' . $this->spark_id . '-' . time();
$this->temp_path = sys_get_temp_dir() . '/' . $this->temp_token;
@@ -47,43 +47,43 @@ function install()
@mkdir(SPARK_PATH . "/$this->name");
Spark_utils::full_move($this->temp_path, $this->installation_path);
Spark_utils::remove_full_directory($this->temp_path);
- $this->installed_path = $this->installation_path;
+ $this->installed_path = $this->installation_path;
}
- private function recurseMove($src,$dst)
- {
- $dir = opendir($src);
- @mkdir($dst);
- while(false !== ( $file = readdir($dir)) ) {
- if (( $file != '.' ) && ( $file != '..' )) {
- if ( is_dir($src . '/' . $file) ) {
- $this->recurseMove($src . '/' . $file,$dst . '/' . $file);
- }
- else {
- rename($src . '/' . $file,$dst . '/' . $file);
- }
- }
- }
- closedir($dir);
+ private function recurseMove($src,$dst)
+ {
+ $dir = opendir($src);
+ @mkdir($dst);
+ while(false !== ( $file = readdir($dir)) ) {
+ if (( $file != '.' ) && ( $file != '..' )) {
+ if ( is_dir($src . '/' . $file) ) {
+ $this->recurseMove($src . '/' . $file,$dst . '/' . $file);
+ }
+ else {
+ rename($src . '/' . $file,$dst . '/' . $file);
+ }
+ }
+ }
+ closedir($dir);
}
-
- private function rrmdir($dir)
- {
- if (is_dir($dir)) {
- $files = scandir($dir);
- foreach ($files as $file) {
- if ($file != "." && $file != "..") {
+
+ private function rrmdir($dir)
+ {
+ if (is_dir($dir)) {
+ $files = scandir($dir);
+ foreach ($files as $file) {
+ if ($file != "." && $file != "..") {
if (is_dir($dir . "/" . $file)) {
- $this->rrmdir($dir . "/" . $file);
+ $this->rrmdir($dir . "/" . $file);
}
else {
- unlink($dir . "/" . $file);
+ unlink($dir . "/" . $file);
}
- }
- }
- reset($files);
- rmdir($dir);
- }
+ }
+ }
+ reset($files);
+ rmdir($dir);
+ }
}
function install_dependency($dependency_data) {
@@ -103,7 +103,7 @@ function install_dependency($dependency_data) {
Spark_utils::warning("Dependency $spark->name is already installed.");
}
}
-
+
function verify($break_on_already_installed = true)
{
// see if this is deactivated
@@ -12,7 +12,7 @@ function __construct($data)
function location_detail()
{
return "ZIP archive at $this->archive_url";
- }
+ }
private static function unzip_installed()
{
@@ -22,7 +22,7 @@ private static function unzip_installed()
function retrieve()
{
file_put_contents($this->temp_file, file_get_contents($this->archive_url));
- // Try a few ways to unzip
+ // Try a few ways to unzip
if (class_exists('ZipArchive'))
{
$zip = new ZipArchive;
View
@@ -54,7 +54,7 @@ static function remove_full_directory($dir, $vocally = false)
{
if (is_dir($dir))
{
- $objects = scandir($dir);
+ $objects = scandir($dir);
foreach ($objects as $object)
{
if ($object != '.' && $object != '..')
@@ -66,14 +66,14 @@ static function remove_full_directory($dir, $vocally = false)
else
{
if ($vocally) self::notice("Removing $dir/$object");
- unlink($dir . '/' . $object);
+ unlink($dir . '/' . $object);
}
- }
- }
- reset($objects);
- return rmdir($dir);
- }
- }
+ }
+ }
+ reset($objects);
+ return rmdir($dir);
+ }
+ }
static function notice($msg)
{
View
@@ -7,17 +7,19 @@ function test_install_with_version()
$clines = $this->capture_buffer_lines(function($cli) {
$cli->execute('install', array('-v1.0', 'example-spark'));
});
- $success = (bool) (strpos(end($clines), chr(27) . '[1;36m[ SPARK ]' . chr(27) . '[0m Spark installed') === 0);
+ $success = (bool) (strpos(end($clines), chr(27) . '[1;36m[ SPARK ]' .
+ chr(27) . '[0m Spark installed') === 0);
Spark_utils::remove_full_directory(SPARK_PATH . '/example-spark');
$this->assertEquals(true, $success);
}
- function test_install_without_version()
+ function test_install_without_version()
{
$clines = $this->capture_buffer_lines(function($cli) {
$cli->execute('install', array('example-spark'));
});
- $success = (bool) (strpos(end($clines), chr(27) . '[1;36m[ SPARK ]' . chr(27) . '[0m Spark installed') === 0);
+ $success = (bool) (strpos(end($clines), chr(27) . '[1;36m[ SPARK ]' .
+ chr(27) . '[0m Spark installed') === 0);
Spark_utils::remove_full_directory(SPARK_PATH . '/example-spark');
$this->assertEquals(true, $success);
}
@@ -27,7 +29,8 @@ function test_install_with_invalid_spark()
$clines = $this->capture_buffer_lines(function($cli) {
$cli->execute('install', array('jjks7878erHjhsjdkksj'));
});
- $success = (bool) (strpos(end($clines), chr(27) . '[1;31m[ ERROR ]' . chr(27) . '[0m Unable to find spark') === 0);
+ $success = (bool) (strpos(end($clines), chr(27) . '[1;31m[ ERROR ]' .
+ chr(27) . '[0m Unable to find spark') === 0);
Spark_utils::remove_full_directory(SPARK_PATH . '/example-spark');
$this->assertEquals(true, $success);
}
@@ -37,7 +40,8 @@ function test_install_with_invalid_spark_version()
$clines = $this->capture_buffer_lines(function($cli) {
$cli->execute('install', array('v9.4', 'example-spark'));
});
- $success = (bool) (strpos(reset($clines), chr(27) . '[1;31m[ ERROR ]' . chr(27) . '[0m Uh-oh!') === 0);
+ $success = (bool) (strpos(reset($clines), chr(27) . '[1;31m[ ERROR ]' .
+ chr(27) . '[0m Uh-oh!') === 0);
Spark_utils::remove_full_directory(SPARK_PATH . '/example-spark');
$this->assertEquals(true, $success);
}

0 comments on commit a28e2b8

Please sign in to comment.