aboutsummaryrefslogtreecommitdiff
path: root/lib/Config
diff options
context:
space:
mode:
authorPatrick Spek <p.spek@tyil.nl>2020-07-04 13:46:25 +0200
committerPatrick Spek <p.spek@tyil.nl>2023-07-25 02:17:24 +0200
commitbb450bd96b02b48ed8b277fa0a6ca5c97037a680 (patch)
tree974bf72d443dbf0d1bffea29793becee806b43bc /lib/Config
parent86d3fe57ceb163d9ff31d131568f4a9caca8bbc5 (diff)
Overhaul Config to 3.0.0
Diffstat (limited to 'lib/Config')
-rw-r--r--lib/Config/Parser.pm629
-rw-r--r--lib/Config/Parser/NULL.pm645
2 files changed, 25 insertions, 49 deletions
diff --git a/lib/Config/Parser.pm6 b/lib/Config/Parser.pm6
index d067513..5d0343b 100644
--- a/lib/Config/Parser.pm6
+++ b/lib/Config/Parser.pm6
@@ -1,26 +1,13 @@
#! /usr/bin/env false
-use v6.c;
+use v6.d;
-use Config::Exception::UnimplementedMethodException;
+unit class Config::Parser;
-class Config::Parser
-{
- #| Attempt to read the file at a given $path, and returns its
- #| parsed contents as a Hash.
- method read(Str $path --> Hash)
- {
- Config::Exception::UnimplementedMethodException.new(
- method => "read"
- ).throw();
- }
+#| Attempt to read the file at a given $path, and returns its
+#| parsed contents as a Hash.
+method read(IO() $path --> Hash) { … }
- #| Attempt to write the $config Hash at a given $path. Returns
- #| True on success, False on failure.
- method write(Str $path, Hash $config --> Bool)
- {
- Config::Exception::UnimplementedMethodException.new(
- method => "write"
- ).throw();
- }
-}
+#| Attempt to write the $config Hash at a given $path. Returns
+#| True on success, False on failure.
+method write(IO() $path, Hash $config --> Bool) { … }
diff --git a/lib/Config/Parser/NULL.pm6 b/lib/Config/Parser/NULL.pm6
index 2352cfc..2845e3c 100644
--- a/lib/Config/Parser/NULL.pm6
+++ b/lib/Config/Parser/NULL.pm6
@@ -1,41 +1,30 @@
#! /usr/bin/env false
-use v6.c;
+use v6.d;
use Config::Parser;
#| The Config::Parser::NULL is a parser to mock with for testing purposes.
#| It exposes an additional method, set-config, so you can set a config
#| Hash to return when calling `read`.
-class Config::Parser::NULL is Config::Parser
-{
- my %mock-config = ();
-
- #| Return the mock config, skipping the file entirely.
- multi method read(Str $path --> Hash)
- {
- %mock-config;
- }
+unit class Config::Parser::NULL is Config::Parser;
- multi method read(IO::Path $path --> Hash)
- {
- %mock-config;
- }
+my %mock-config;
- #| Set the mock config to return on read.
- method set-config(Hash $config)
- {
- %mock-config = $config;
- }
+#| Return the mock config, skipping the file entirely.
+multi method read(IO() $path --> Hash)
+{
+ %mock-config;
+}
- #| Return True, as if writing succeeded.
- multi method write(Str $path, Hash $config --> Bool)
- {
- True;
- }
+#| Set the mock config to return on read.
+method set-config(Hash $config)
+{
+ %mock-config = $config;
+}
- multi method write(IO::Path $path, Hash $config --> Bool)
- {
- True;
- }
+#| Return True, as if writing succeeded.
+multi method write(IO() $path, Hash $config --> Bool)
+{
+ True;
}