aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Spek <p.spek@tyil.nl>2017-04-26 07:53:05 +0200
committerPatrick Spek <p.spek@tyil.nl>2017-04-26 07:53:05 +0200
commitcac9a5f9e429d2461bd2830bc983eced5ef14e1a (patch)
treea86da52ebed362f7c622937026554dcaf81e1abe
parentacdac7ea2f81e739c7e2b5cb37d3f3cdc71962a8 (diff)
Make .read() merge the hashes and allow an array of paths to load
-rw-r--r--META6.json2
-rw-r--r--lib/Config.pm614
2 files changed, 13 insertions, 3 deletions
diff --git a/META6.json b/META6.json
index a3614c3..cfb38a3 100644
--- a/META6.json
+++ b/META6.json
@@ -6,7 +6,7 @@
"description": "Extensible library for reading and writing configuration files.",
"license": "GPL-3.0",
"depends": [
-
+ "Hash::Merge"
],
"provides": {
"Config": "lib/Config.pm6",
diff --git a/lib/Config.pm6 b/lib/Config.pm6
index 2fa01bf..372eb3b 100644
--- a/lib/Config.pm6
+++ b/lib/Config.pm6
@@ -2,6 +2,8 @@
use v6.c;
+use Hash::Merge;
+
use Config::Exception::MissingParserException;
use Config::Exception::UnknownTypeException;
use Config::Exception::FileNotFoundException;
@@ -109,15 +111,23 @@ class Config is export
}
require ::($!parser);
- $!content = ::($!parser).read($path);
+
+ $!content.merge(::($!parser).read($path));
}
return True;
}
+ multi method read(Array $paths, Str $parser = "")
+ {
+ for $paths -> $path {
+ self.read($path, $parser);
+ }
+ }
+
multi method read(Hash $hash)
{
- $!content = $hash;
+ $!content.merge($hash);
}
method set(Str $key, Any $value)