Add the helper script tests/tweeper_file
authorAntonio Ospite <ao2@ao2.it>
Thu, 9 Feb 2017 17:21:17 +0000 (18:21 +0100)
committerAntonio Ospite <ao2@ao2.it>
Thu, 9 Feb 2017 17:24:06 +0000 (18:24 +0100)
The script allows to scrape a local file, this speeds up development and
testing.

tests/tweeper_file [new file with mode: 0755]

diff --git a/tests/tweeper_file b/tests/tweeper_file
new file mode 100755 (executable)
index 0000000..15de10c
--- /dev/null
@@ -0,0 +1,25 @@
+#!/usr/bin/env php
+<?php
+
+require_once __DIR__ . '/../autoload.php';
+
+use Tweeper\Tweeper;
+
+date_default_timezone_set('UTC');
+
+$usage = "{$argv[0]}: <file> <host>\n";
+
+if ($argc < 3) {
+    fwrite(STDERR, $usage);
+    exit(1);
+}
+
+$file_url = 'file://' . realpath($argv[1]);
+$host = $argv[2];
+
+$tweeper = new Tweeper();
+$output = $tweeper->tweep($file_url, $host, false);
+if (is_null($output)) {
+    exit(1);
+}
+echo $output;