Permalink
Browse files

refactored

  • Loading branch information...
1 parent 98699d8 commit 28ed8863789dbb1bce0c98489cfa2f101e1cc07d @juzna committed Aug 1, 2012
View
@@ -20,10 +20,10 @@
"nette/nette": "2.0.*"
},
"autoload": {
- "psr-0": { "": "./" }
+ "psr-0": { "Nette\\Addons": "src/" }
},
"extra": {
- "class": "NetteAddonInstaller"
+ "class": "Nette\\Addons\\Installer"
},
"require-dev": {
"composer/composer": "1.0.*"
@@ -0,0 +1,42 @@
+<?php
+
+namespace Nette\Addons\CustomInstallers;
+
+use Composer\Package\PackageInterface;
+use Composer\Repository\InstalledRepositoryInterface;
+
+
+/**
+ * Interface for the package installation manager.
+ * (inpired by Composer's installers)
+ *
+ * @author Jan Dolecek <juzna.cz@gmail.com>
+ */
+interface IInstaller
+{
+ /**
+ * Installs specific package.
+ *
+ * @param InstalledRepositoryInterface $repo repository in which to check
+ * @param PackageInterface $package package instance
+ */
+ function install(InstalledRepositoryInterface $repo, PackageInterface $package);
+
+ /**
+ * Updates specific package.
+ *
+ * @param InstalledRepositoryInterface $repo repository in which to check
+ * @param PackageInterface $initial already installed package version
+ * @param PackageInterface $target updated version
+ */
+ function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target);
+
+ /**
+ * Uninstalls specific package.
+ *
+ * @param InstalledRepositoryInterface $repo repository in which to check
+ * @param PackageInterface $package package instance
+ */
+ function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package);
+
+}
@@ -1,5 +1,7 @@
<?php
+namespace Nette\Addons;
+
use Composer\Package\PackageInterface;
use Composer\Repository\InstalledRepositoryInterface;
use Composer\Installer\LibraryInstaller;
@@ -9,7 +11,7 @@
*
* @author Jan Dolecek <juzna.cz@gmail.com>
*/
-class NetteAddonInstaller extends LibraryInstaller
+class Installer extends LibraryInstaller
{
private static $supportedTypes = array(
'nette-addon',
@@ -36,13 +38,13 @@ public function getInstallPath(PackageInterface $package)
{
switch($package->getType()) {
case 'nette-assets':
- throw new Exception("Not implemented yet");
+ throw new \Exception("Not implemented yet");
case 'nette-addon':
return parent::getInstallPath($package);
default:
- throw new Exception("Not recognized package type '{$package->getType()}'");
+ throw new \Exception("Not recognized package type '{$package->getType()}'");
}
}
@@ -10,7 +10,11 @@
* @package Nette
*/
+namespace Nette\Addons;
+/**
+ * FIXME: remove this and require it as a dependancy
+ */
/**
* Simple parser & generator for Nette Object Notation.
@@ -61,7 +65,7 @@ class Neon
*/
public static function encode($var, $options = NULL)
{
- if ($var instanceof DateTime) {
+ if ($var instanceof \DateTime) {
return $var->format('Y-m-d H:i:s O');
} elseif ($var instanceof NeonEntity) {
@@ -123,7 +127,7 @@ public static function encode($var, $options = NULL)
public static function decode($input)
{
if (!is_string($input)) {
- throw new InvalidArgumentException("Argument must be a string, " . gettype($input) . " given.");
+ throw new \InvalidArgumentException("Argument must be a string, " . gettype($input) . " given.");
}
if (!self::$re) {
self::$re = '~(' . implode(')|(', self::$patterns) . ')~Ami';
@@ -298,7 +302,7 @@ private function parse($indent = NULL, $result = NULL)
} elseif (is_numeric($t)) {
$value = $t * 1;
} elseif (preg_match('#\d\d\d\d-\d\d?-\d\d?(?:(?:[Tt]| +)\d\d?:\d\d:\d\d(?:\.\d*)? *(?:Z|[-+]\d\d?(?::\d\d)?)?)?$#A', $t)) {
- $value = new DateTime($t);
+ $value = new \DateTime($t);
} else { // literal
$value = $t;
}
@@ -376,7 +380,7 @@ private function error($message = "Unexpected '%s'")
/**
* The exception that indicates error of NEON decoding.
*/
-class NeonEntity extends stdClass
+class NeonEntity extends \stdClass
{
public $value;
public $attributes;
@@ -387,6 +391,6 @@ class NeonEntity extends stdClass
/**
* The exception that indicates error of NEON decoding.
*/
-class NeonException extends Exception
+class NeonException extends \Exception
{
}

0 comments on commit 28ed886

Please sign in to comment.