Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added rsync extension

  • Loading branch information...
commit ac70915ce208a413e63585826f06876b85861953 1 parent eb4b165
Michele Orselli micheleorselli authored
33 composer.lock
View
@@ -3,17 +3,17 @@
"packages": [
{
"name": "symfony/console",
- "version": "2.0.x-dev",
+ "version": "v2.0.23",
"target-dir": "Symfony/Component/Console",
"source": {
"type": "git",
- "url": "https://github.com/symfony/Console",
- "reference": "v2.0.13"
+ "url": "https://github.com/symfony/Console.git",
+ "reference": "v2.0.23"
},
"dist": {
"type": "zip",
- "url": "https://github.com/symfony/Console/zipball/v2.0.13",
- "reference": "v2.0.13",
+ "url": "https://api.github.com/repos/symfony/Console/zipball/v2.0.23",
+ "reference": "v2.0.23",
"shasum": ""
},
"require": {
@@ -25,26 +25,23 @@
"Symfony\\Component\\Console": ""
}
},
+ "notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
- "email": "fabien@symfony.com",
- "homepage": null,
- "role": null
+ "email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
- "email": null,
- "homepage": "http://symfony.com/contributors",
- "role": null
+ "homepage": "http://symfony.com/contributors"
}
],
"description": "Symfony Console Component",
"homepage": "http://symfony.com",
- "time": "2012-04-29 19:28:50"
+ "time": "2013-02-27 09:08:35"
},
{
"name": "symfony/process",
@@ -70,7 +67,7 @@
"Symfony\\Component\\Process": ""
}
},
- "notification-url": "http://packagist.org/downloads/",
+ "notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
@@ -89,12 +86,20 @@
"time": "2013-02-18 21:27:57"
}
],
- "packages-dev": null,
+ "packages-dev": [
+
+ ],
"aliases": [
],
"minimum-stability": "stable",
"stability-flags": [
+ ],
+ "platform": [
+
+ ],
+ "platform-dev": [
+
]
}
43 src/Idephix/Extension/Project/Project.php
View
@@ -0,0 +1,43 @@
+<?php
+
+namespace Idephix\Extension\Project;
+
+use Idephix\Idephix;
+use Idephix\Extension\IdephixAwareInterface;
+
+/**
+ * @todo:
+ * - allow for $exclude to be an array
+ * - manage ports different from the default one
+ * - check to undefined params in currentTarget
+ */
+class Project implements IdephixAwareInterface
+{
+ private $idx;
+
+ public function setIdephix(Idephix $idx)
+ {
+ $this->idx = $idx;
+ }
+
+ public function rsyncProject($remote_dir, $local_dir = null, $exclude = null, $extra_opts = null, $ssh_opts = null)
+ {
+ if (substr($remote_dir, -1) != '/')
+ {
+ $remote_dir .= '/';
+ }
+
+ $target = $this->idx->getCurrentTarget();
+ $user = $target['ssh_params']['user'];
+ $host = $this->idx->getCurrentTargetHost();
+
+ if (file_exists($exclude))
+ {
+ $extra_opts .= ' --exclude-from='.$exclude;
+ }
+
+ $cmd = "rsync -rlDcz --force --delete --progress $extra_opts -e 'ssh' ./ $user@$host:$remote_dir";
+
+ return $this->idx->local($cmd);
+ }
+}
38 tests/Idephix/Extension/Project/ProjectTest.php
View
@@ -0,0 +1,38 @@
+<?php
+namespace Idephix\Extension\Project;
+
+use Idephix\Extension\Project\Project;
+
+class ProjectTest extends \PHPUnit_Framework_TestCase
+{
+ public function setUp()
+ {
+ $this->idx = $this->getMockBuilder('Idephix\Idephix')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->idx->expects($this->exactly(1))
+ ->method('local')
+ ->will($this->returnArgument(0));
+
+ $this->idx->expects($this->exactly(1))
+ ->method('getCurrentTarget')
+ ->will($this->returnValue(array('ssh_params' => array('user' => 'kea'))));
+
+ $this->idx->expects($this->exactly(1))
+ ->method('getCurrentTargetHost')
+ ->will($this->returnValue('banana.com'));
+
+ $this->project = new Project();
+ $this->project->setIdephix($this->idx);
+
+ }
+
+ public function testRsyncProject()
+ {
+ $result = $this->project->rsyncProject('/a/remote');
+
+ $this->assertEquals("rsync -rlDcz --force --delete --progress -e 'ssh' ./ kea@banana.com:/a/remote/", $result);
+ }
+
+}
Please sign in to comment.
Something went wrong with that request. Please try again.