major refactoring under the hood
[pharext/pharext] / src / pharext / Task / BundleGenerator.php
diff --git a/src/pharext/Task/BundleGenerator.php b/src/pharext/Task/BundleGenerator.php
new file mode 100644 (file)
index 0000000..aabf9c8
--- /dev/null
@@ -0,0 +1,28 @@
+<?php
+
+namespace pharext\Task;
+
+use pharext\Task;
+
+use RecursiveDirectoryIterator;
+use RecursiveIteratorIterator;
+
+/**
+ * List all library files of pharext to bundle with a phar
+ */
+class BundleGenerator implements Task
+{
+       /**
+        * @param bool $verbose
+        * @return Generator
+        */
+       public function run($verbose = false) {
+               $rdi = new RecursiveDirectoryIterator(dirname(dirname(__DIR__)));
+               $rii = new RecursiveIteratorIterator($rdi);
+               for ($rii->rewind(); $rii->valid(); $rii->next()) {
+                       if (!$rii->isDot()) {
+                               yield $rii->getSubPathname() => $rii->key();
+                       }
+               }
+       }
+}