From 3d037ec2b3f336feec380f1cbb0883f6033767e7 Mon Sep 17 00:00:00 2001 From: Steffen Lange Date: Wed, 1 Apr 2020 17:25:40 +0200 Subject: [PATCH] New feature: Branch name for software products --- Database.php | 6 +++--- PatchBase.php | 4 ++-- PatchCollector.php | 1 + PatchObject.php | 3 +++ PatchTwitter.php | 5 ++++- 5 files changed, 13 insertions(+), 6 deletions(-) diff --git a/Database.php b/Database.php index 146c4fb..5a4476c 100644 --- a/Database.php +++ b/Database.php @@ -45,16 +45,16 @@ class Database { } function find(string $id) : PatchObject { foreach ($this->data as $obj) { - if (strcmp($obj->GetId(), $id) == 0) { + if (strcmp($obj->getId(), $id) == 0) { return $obj; } } return new PatchObject(); } function addOrUpdate(PatchObject $patch) { - $patch->SetTimestamp($this->time); + $patch->setTimestamp($this->time); foreach ($this->data as &$obj) { - if (strcmp($obj->GetId(), $patch->GetId()) == 0) { + if (strcmp($obj->getId(), $patch->getId()) == 0) { $obj = $patch; return; } diff --git a/PatchBase.php b/PatchBase.php index 442ce61..4d6347e 100644 --- a/PatchBase.php +++ b/PatchBase.php @@ -34,7 +34,7 @@ abstract class PatchBase { } protected function parse(string $re) : bool { if ($str = $this->regex_str($re)) { - $this->patch->SetVersion($str); + $this->patch->setVersion($str); return true; } return false; @@ -42,7 +42,7 @@ abstract class PatchBase { protected function parse_json(string $key) : bool { $flat = iterator_to_array(new \RecursiveIteratorIterator(new \RecursiveArrayIterator($this->data))); if (!empty($flat[$key])) { - $this->patch->SetVersion($flat[$key]); + $this->patch->setVersion($flat[$key]); return true; } return false; diff --git a/PatchCollector.php b/PatchCollector.php index ace729a..a85d7c1 100644 --- a/PatchCollector.php +++ b/PatchCollector.php @@ -13,6 +13,7 @@ foreach (new \DirectoryIterator(__DIR__ . '/modules') as $file) { } } } +shuffle($list); $db = new Database(__DIR__ . '/db.json'); echo 'Time: ' . date('c', $db->time()) . PHP_EOL; diff --git a/PatchObject.php b/PatchObject.php index 3706637..74f0a46 100644 --- a/PatchObject.php +++ b/PatchObject.php @@ -32,6 +32,9 @@ class PatchObject { function getBranch() : string { return $this->branch; } + function setBranch(string $branch) { + $this->branch = $branch; + } function getVersion() : string { return $this->version; } diff --git a/PatchTwitter.php b/PatchTwitter.php index 4dacba4..6070079 100644 --- a/PatchTwitter.php +++ b/PatchTwitter.php @@ -31,7 +31,10 @@ $twitter = new Twitter($TwitterConsumerKey, $TwitterConsumerSecret, $TwitterAcce for ($i = 0; $i < $db->count(); $i++) { $patch = $db->get($i); if ($last < $patch->getTimestamp()) { - $s = $patch->getVendor() . ' released #' . $patch->getProduct() . ' version ' . $patch->getVersion() . '. ' . $patch->getURL(); + $s = $patch->getVendor() . ' released #' . $patch->getProduct(); + if (!empty($patch->getBranch())) + $s .= ' ' . $patch->getBranch(); + $s .= ' version ' . $patch->getVersion() . '. ' . $patch->getURL(); try { $twitter->send($s); } catch (DG\Twitter\Exception $e) {