From 48a894ff7a9b11611e100db358b755a8afd117c5 Mon Sep 17 00:00:00 2001 From: aB0t Date: Wed, 21 Jun 2023 05:10:02 +0200 Subject: [PATCH] update 2023-06-21 05:10:02 --- README.md | 1 + .../README.md | 8 ++ .../code.php | 20 +++ .../code.power | 19 +++ .../settings.json | 4 + .../README.md | 8 ++ .../code.php | 12 ++ .../code.power | 11 ++ .../settings.json | 7 +- .../README.md | 70 ++++++++++ .../code.php | 120 ++++++++++++++++++ .../code.power | 93 ++++++++++++++ .../settings.json | 27 ++++ super-powers.json | 11 ++ 14 files changed, 410 insertions(+), 1 deletion(-) create mode 100644 src/90f2ee7a-c041-4316-ad54-af4f97fa3003/README.md create mode 100644 src/90f2ee7a-c041-4316-ad54-af4f97fa3003/code.php create mode 100644 src/90f2ee7a-c041-4316-ad54-af4f97fa3003/code.power create mode 100644 src/90f2ee7a-c041-4316-ad54-af4f97fa3003/settings.json diff --git a/README.md b/README.md index e04bea3..12949a0 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,7 @@ This repository contains an index (see below) of all the approved powers within - **Namespace**: [VDM\Joomla\GetBible](#vdm-joomla-getbible) - **abstract class Factory** | [Details](src/11892cfa-374e-4e3f-b0bc-531871c822d9) | [Code](src/11892cfa-374e-4e3f-b0bc-531871c822d9/code.php) | [Settings](src/11892cfa-374e-4e3f-b0bc-531871c822d9/settings.json) | Super__11892cfa_374e_4e3f_b0bc_531871c822d9__Power + - **final class DailyScripture** | [Details](src/90f2ee7a-c041-4316-ad54-af4f97fa3003) | [Code](src/90f2ee7a-c041-4316-ad54-af4f97fa3003/code.php) | [Settings](src/90f2ee7a-c041-4316-ad54-af4f97fa3003/settings.json) | Super__90f2ee7a_c041_4316_ad54_af4f97fa3003__Power - **final class Search** | [Details](src/8336e3c4-f11b-41bc-a2b1-976f99442a84) | [Code](src/8336e3c4-f11b-41bc-a2b1-976f99442a84/code.php) | [Settings](src/8336e3c4-f11b-41bc-a2b1-976f99442a84/settings.json) | Super__8336e3c4_f11b_41bc_a2b1_976f99442a84__Power - **final class Watcher** | [Details](src/f815fb33-f721-48a5-a84e-53f1986e8881) | [Code](src/f815fb33-f721-48a5-a84e-53f1986e8881/code.php) | [Settings](src/f815fb33-f721-48a5-a84e-53f1986e8881/settings.json) | Super__f815fb33_f721_48a5_a84e_53f1986e8881__Power - **class Config** | [Details](src/71075f03-4e77-4fc0-840a-ef55fd9260b2) | [Code](src/71075f03-4e77-4fc0-840a-ef55fd9260b2/code.php) | [Settings](src/71075f03-4e77-4fc0-840a-ef55fd9260b2/settings.json) | Super__71075f03_4e77_4fc0_840a_ef55fd9260b2__Power diff --git a/src/56465044-94ed-4e00-b6db-160c67163df8/README.md b/src/56465044-94ed-4e00-b6db-160c67163df8/README.md index 6d62db4..bba0a90 100644 --- a/src/56465044-94ed-4e00-b6db-160c67163df8/README.md +++ b/src/56465044-94ed-4e00-b6db-160c67163df8/README.md @@ -14,6 +14,7 @@ class App #Gold { + register(Container $container) : void + getConfig(Container $container) : Config + getTable(Container $container) : Table + + getDailyScripture(Container $container) : DailyScripture + getSearch(Container $container) : Search + getWatcher(Container $container) : Watcher } @@ -39,6 +40,13 @@ note right of App::getTable return: Table end note +note right of App::getDailyScripture + Get the Daily Scripture class + + since: 2.0.1 + return: DailyScripture +end note + note right of App::getSearch Get the Search class diff --git a/src/56465044-94ed-4e00-b6db-160c67163df8/code.php b/src/56465044-94ed-4e00-b6db-160c67163df8/code.php index b611c46..f361fa5 100644 --- a/src/56465044-94ed-4e00-b6db-160c67163df8/code.php +++ b/src/56465044-94ed-4e00-b6db-160c67163df8/code.php @@ -16,6 +16,7 @@ use Joomla\DI\Container; use Joomla\DI\ServiceProviderInterface; use VDM\Joomla\GetBible\Config; use VDM\Joomla\GetBible\Table; +use VDM\Joomla\GetBible\DailyScripture; use VDM\Joomla\GetBible\Search; use VDM\Joomla\GetBible\Watcher; @@ -43,6 +44,9 @@ class App implements ServiceProviderInterface $container->alias(Table::class, 'GetBible.Table') ->share('GetBible.Table', [$this, 'getTable'], true); + $container->alias(DailyScripture::class, 'DailyScripture') + ->share('DailyScripture', [$this, 'getDailyScripture'], true); + $container->alias(Search::class, 'GetBible.Search') ->share('GetBible.Search', [$this, 'getSearch'], true); @@ -76,6 +80,22 @@ class App implements ServiceProviderInterface return new Table(); } + /** + * Get the Daily Scripture class + * + * @param Container $container The DI container. + * + * @return DailyScripture + * @since 2.0.1 + */ + public function getDailyScripture(Container $container): DailyScripture + { + return new DailyScripture( + $container->get('GetBible.Config'), + $container->get('GetBible.Utilities.Http') + ); + } + /** * Get the Search class * diff --git a/src/56465044-94ed-4e00-b6db-160c67163df8/code.power b/src/56465044-94ed-4e00-b6db-160c67163df8/code.power index 7e638b2..d79f014 100644 --- a/src/56465044-94ed-4e00-b6db-160c67163df8/code.power +++ b/src/56465044-94ed-4e00-b6db-160c67163df8/code.power @@ -14,6 +14,9 @@ $container->alias(Table::class, 'GetBible.Table') ->share('GetBible.Table', [$this, 'getTable'], true); + $container->alias(DailyScripture::class, 'DailyScripture') + ->share('DailyScripture', [$this, 'getDailyScripture'], true); + $container->alias(Search::class, 'GetBible.Search') ->share('GetBible.Search', [$this, 'getSearch'], true); @@ -47,6 +50,22 @@ return new Table(); } + /** + * Get the Daily Scripture class + * + * @param Container $container The DI container. + * + * @return DailyScripture + * @since 2.0.1 + */ + public function getDailyScripture(Container $container): DailyScripture + { + return new DailyScripture( + $container->get('GetBible.Config'), + $container->get('GetBible.Utilities.Http') + ); + } + /** * Get the Search class * diff --git a/src/56465044-94ed-4e00-b6db-160c67163df8/settings.json b/src/56465044-94ed-4e00-b6db-160c67163df8/settings.json index e124f5f..60144f0 100644 --- a/src/56465044-94ed-4e00-b6db-160c67163df8/settings.json +++ b/src/56465044-94ed-4e00-b6db-160c67163df8/settings.json @@ -20,6 +20,10 @@ "use": "ff8d5fdb-2d1f-4178-bd18-a43b8efd1068", "as": "default" }, + "use_selection4": { + "use": "90f2ee7a-c041-4316-ad54-af4f97fa3003", + "as": "default" + }, "use_selection2": { "use": "8336e3c4-f11b-41bc-a2b1-976f99442a84", "as": "default" diff --git a/src/71075f03-4e77-4fc0-840a-ef55fd9260b2/README.md b/src/71075f03-4e77-4fc0-840a-ef55fd9260b2/README.md index 586c85c..4548616 100644 --- a/src/71075f03-4e77-4fc0-840a-ef55fd9260b2/README.md +++ b/src/71075f03-4e77-4fc0-840a-ef55fd9260b2/README.md @@ -15,6 +15,7 @@ class Config #Gold { # getSchema() : ?string # getDomain() : ?string # getVersion() : ?string + # getDailyscriptureurl() : ?string } note right of Config::getEndpoint @@ -44,6 +45,13 @@ note right of Config::getVersion since: 2.0.1 return: ?string end note + +note right of Config::getDailyscriptureurl + get Daily Scripture URL + + since: 2.0.1 + return: ?string +end note @enduml ``` diff --git a/src/71075f03-4e77-4fc0-840a-ef55fd9260b2/code.php b/src/71075f03-4e77-4fc0-840a-ef55fd9260b2/code.php index 0526c2c..dc0f183 100644 --- a/src/71075f03-4e77-4fc0-840a-ef55fd9260b2/code.php +++ b/src/71075f03-4e77-4fc0-840a-ef55fd9260b2/code.php @@ -12,6 +12,7 @@ namespace VDM\Joomla\GetBible; +use VDM\Joomla\Utilities\GetHelper; use VDM\Joomla\Abstraction\BaseConfig; @@ -64,6 +65,17 @@ class Config extends BaseConfig protected function getVersion(): ?string { return 'v2'; + } + + /** + * get Daily Scripture URL + * + * @return string The Get Daily Scripture URL + * @since 2.0.1 + */ + protected function getDailyscriptureurl(): ?string + { + return 'https://raw.githubusercontent.com/trueChristian/daily-scripture/master/README.today'; } } diff --git a/src/71075f03-4e77-4fc0-840a-ef55fd9260b2/code.power b/src/71075f03-4e77-4fc0-840a-ef55fd9260b2/code.power index f2a54a3..cfc8322 100644 --- a/src/71075f03-4e77-4fc0-840a-ef55fd9260b2/code.power +++ b/src/71075f03-4e77-4fc0-840a-ef55fd9260b2/code.power @@ -40,4 +40,15 @@ protected function getVersion(): ?string { return 'v2'; + } + + /** + * get Daily Scripture URL + * + * @return string The Get Daily Scripture URL + * @since 2.0.1 + */ + protected function getDailyscriptureurl(): ?string + { + return 'https://raw.githubusercontent.com/trueChristian/daily-scripture/master/README.today'; } \ No newline at end of file diff --git a/src/71075f03-4e77-4fc0-840a-ef55fd9260b2/settings.json b/src/71075f03-4e77-4fc0-840a-ef55fd9260b2/settings.json index 0eff836..d49eb64 100644 --- a/src/71075f03-4e77-4fc0-840a-ef55fd9260b2/settings.json +++ b/src/71075f03-4e77-4fc0-840a-ef55fd9260b2/settings.json @@ -9,7 +9,12 @@ "power_version": "1.0.0", "system_name": "JCB.GetBible.Config", "type": "class", - "use_selection": null, + "use_selection": { + "use_selection0": { + "use": "db87c339-5bb6-4291-a7ef-2c48ea1b06bc", + "as": "default" + } + }, "namespace": "VDM\\Joomla\\GetBible\\Config", "description": "GetBible Configurations\r\n\r\n@since 2.0.1", "licensing_template": "\/**\r\n * @package GetBible\r\n *\r\n * @created 30th May, 2023\r\n * @author Llewellyn van der Merwe \r\n * @git GetBible \r\n * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.\r\n * @license GNU General Public License version 2 or later; see LICENSE.txt\r\n *\/\r\n", diff --git a/src/90f2ee7a-c041-4316-ad54-af4f97fa3003/README.md b/src/90f2ee7a-c041-4316-ad54-af4f97fa3003/README.md new file mode 100644 index 0000000..82742d9 --- /dev/null +++ b/src/90f2ee7a-c041-4316-ad54-af4f97fa3003/README.md @@ -0,0 +1,70 @@ +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# final class DailyScripture (Details) +> namespace: **VDM\Joomla\GetBible** +```uml +@startuml +class DailyScripture << (F,LightGreen) >> #Green { + # ?int $book + # ?int $chapter + # ?string $verses + + __construct(Config $config, Http $http) + + book() : ?int + + chapter() : ?int + + verses() : ?string + # parse(string $reference) +} + +note right of DailyScripture::__construct + Constructor + + since: 2.0.1 +end note + +note right of DailyScripture::book + Get the book number from the reference + + since: 2.0.1 + return: ?int +end note + +note right of DailyScripture::chapter + Get the chapter from the reference + + since: 2.0.1 + return: ?int +end note + +note right of DailyScripture::verses + Get the verses from the reference + + since: 2.0.1 + return: ?string +end note + +note right of DailyScripture::parse + Parse the scriptural reference + + since: 2.0.1 +end note + +@enduml +``` + +--- +``` + ██╗ ██████╗██████╗ + ██║██╔════╝██╔══██╗ + ██║██║ ██████╔╝ +██ ██║██║ ██╔══██╗ +╚█████╔╝╚██████╗██████╔╝ + ╚════╝ ╚═════╝╚═════╝ +``` +> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder) + diff --git a/src/90f2ee7a-c041-4316-ad54-af4f97fa3003/code.php b/src/90f2ee7a-c041-4316-ad54-af4f97fa3003/code.php new file mode 100644 index 0000000..63a93ce --- /dev/null +++ b/src/90f2ee7a-c041-4316-ad54-af4f97fa3003/code.php @@ -0,0 +1,120 @@ + + * @git GetBible + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\GetBible; + + +use VDM\Joomla\GetBible\Config; +use VDM\Joomla\GetBible\Utilities\Http; + + +/** + * The GetBible Daily Scripture + * + * @since 2.0.1 + */ +final class DailyScripture +{ + /** + * The book number + * + * @var string|null + * @since 2.0.1 + */ + protected ?int $book = null; + + /** + * The chapter number + * + * @var int|null + * @since 2.0.1 + */ + protected ?int $chapter = null; + + /** + * The verses string + * + * @var string|null + * @since 2.0.1 + */ + protected ?string $verses = null; + + /** + * Constructor + * + * @param Config $config The config object. + * @param Http $http The http object. + * + * @since 2.0.1 + */ + public function __construct(Config $config, Http $http) + { + $response = $http->get($config->daily_scripture_url); + + // make sure we got the correct response + if ($response->code == 200 && isset($response->body) && is_string($response->body)) + { + $this->parse($response->body); + } + } + + /** + * Get the book number from the reference + * + * @return int|null Book number + * @since 2.0.1 + */ + public function book(): ?int + { + return $this->book; + } + + /** + * Get the chapter from the reference + * + * @return int|null Chapter number + * @since 2.0.1 + */ + public function chapter(): ?int + { + return $this->chapter; + } + + /** + * Get the verses from the reference + * + * @return string|null Verses + * @since 2.0.1 + */ + public function verses(): ?string + { + return $this->verses; + } + + /** + * Parse the scriptural reference + * + * @param string $reference The scriptural reference. + * + * @since 2.0.1 + */ + protected function parse(string $reference) + { + $parts = explode(' ', $reference); + + $this->book = isset($parts[0]) ? intval($parts[0]) : null; + $chapterVerses = isset($parts[1]) ? explode(':', $parts[1]) : [null, null]; + + $this->chapter = isset($chapterVerses[0]) ? intval($chapterVerses[0]) : null; + $this->verses = isset($chapterVerses[1]) ? trim($chapterVerses[1]) : null; + } +} + diff --git a/src/90f2ee7a-c041-4316-ad54-af4f97fa3003/code.power b/src/90f2ee7a-c041-4316-ad54-af4f97fa3003/code.power new file mode 100644 index 0000000..450c2a5 --- /dev/null +++ b/src/90f2ee7a-c041-4316-ad54-af4f97fa3003/code.power @@ -0,0 +1,93 @@ + /** + * The book number + * + * @var string|null + * @since 2.0.1 + */ + protected ?int $book = null; + + /** + * The chapter number + * + * @var int|null + * @since 2.0.1 + */ + protected ?int $chapter = null; + + /** + * The verses string + * + * @var string|null + * @since 2.0.1 + */ + protected ?string $verses = null; + + /** + * Constructor + * + * @param Config $config The config object. + * @param Http $http The http object. + * + * @since 2.0.1 + */ + public function __construct(Config $config, Http $http) + { + $response = $http->get($config->daily_scripture_url); + + // make sure we got the correct response + if ($response->code == 200 && isset($response->body) && is_string($response->body)) + { + $this->parse($response->body); + } + } + + /** + * Get the book number from the reference + * + * @return int|null Book number + * @since 2.0.1 + */ + public function book(): ?int + { + return $this->book; + } + + /** + * Get the chapter from the reference + * + * @return int|null Chapter number + * @since 2.0.1 + */ + public function chapter(): ?int + { + return $this->chapter; + } + + /** + * Get the verses from the reference + * + * @return string|null Verses + * @since 2.0.1 + */ + public function verses(): ?string + { + return $this->verses; + } + + /** + * Parse the scriptural reference + * + * @param string $reference The scriptural reference. + * + * @since 2.0.1 + */ + protected function parse(string $reference) + { + $parts = explode(' ', $reference); + + $this->book = isset($parts[0]) ? intval($parts[0]) : null; + $chapterVerses = isset($parts[1]) ? explode(':', $parts[1]) : [null, null]; + + $this->chapter = isset($chapterVerses[0]) ? intval($chapterVerses[0]) : null; + $this->verses = isset($chapterVerses[1]) ? trim($chapterVerses[1]) : null; + } \ No newline at end of file diff --git a/src/90f2ee7a-c041-4316-ad54-af4f97fa3003/settings.json b/src/90f2ee7a-c041-4316-ad54-af4f97fa3003/settings.json new file mode 100644 index 0000000..e3134b2 --- /dev/null +++ b/src/90f2ee7a-c041-4316-ad54-af4f97fa3003/settings.json @@ -0,0 +1,27 @@ +{ + "add_head": "0", + "add_licensing_template": "2", + "extends": "0", + "guid": "90f2ee7a-c041-4316-ad54-af4f97fa3003", + "implements": null, + "load_selection": null, + "name": "DailyScripture", + "power_version": "1.0.0", + "system_name": "Joomla.GetBible.DailyScripture", + "type": "final class", + "use_selection": { + "use_selection0": { + "use": "71075f03-4e77-4fc0-840a-ef55fd9260b2", + "as": "default" + }, + "use_selection1": { + "use": "b8c66089-735e-4081-825c-8fe36b28e4a6", + "as": "default" + } + }, + "namespace": "VDM\\Joomla\\GetBible\\DailyScripture", + "description": "The GetBible Daily Scripture\r\n\r\n@since 2.0.1", + "licensing_template": "\/**\r\n * @package GetBible\r\n *\r\n * @created 30th May, 2023\r\n * @author Llewellyn van der Merwe \r\n * @git GetBible \r\n * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.\r\n * @license GNU General Public License version 2 or later; see LICENSE.txt\r\n *\/\r\n", + "head": "", + "composer": "" +} \ No newline at end of file diff --git a/super-powers.json b/super-powers.json index eb24c19..be88797 100644 --- a/super-powers.json +++ b/super-powers.json @@ -87,6 +87,17 @@ "spk": "Super__8336e3c4_f11b_41bc_a2b1_976f99442a84__Power", "guid": "8336e3c4-f11b-41bc-a2b1-976f99442a84" }, + "90f2ee7a-c041-4316-ad54-af4f97fa3003": { + "name": "DailyScripture", + "type": "final class", + "namespace": "VDM\\Joomla\\GetBible", + "code": "src\/90f2ee7a-c041-4316-ad54-af4f97fa3003\/code.php", + "power": "src\/90f2ee7a-c041-4316-ad54-af4f97fa3003\/code.power", + "settings": "src\/90f2ee7a-c041-4316-ad54-af4f97fa3003\/settings.json", + "path": "src\/90f2ee7a-c041-4316-ad54-af4f97fa3003", + "spk": "Super__90f2ee7a_c041_4316_ad54_af4f97fa3003__Power", + "guid": "90f2ee7a-c041-4316-ad54-af4f97fa3003" + }, "91b37bd7-b314-48be-91cf-434ec823bd80": { "name": "Upsert", "type": "final class",