aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Spek <p.spek@tyil.nl>2017-04-23 21:31:18 +0200
committerPatrick Spek <p.spek@tyil.nl>2017-04-23 21:31:18 +0200
commita5c9ad058898d4467cdc6993a9c1b3b1a096935f (patch)
tree328a326cc926c3a46e9daea253e5e3963ee2d8f9
Initial commit
-rw-r--r--.gitignore2
-rw-r--r--META6.json27
-rw-r--r--README.md15
-rw-r--r--lib/Config/Parser/yaml.pm614
-rw-r--r--t/read.t15
-rw-r--r--t/test.yaml3
6 files changed, 76 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..2d4fdb9
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+.precomp
+
diff --git a/META6.json b/META6.json
new file mode 100644
index 0000000..69f30dc
--- /dev/null
+++ b/META6.json
@@ -0,0 +1,27 @@
+{
+ "perl": "6",
+ "name": "Config::Parser::yaml",
+ "version": "1.0.0",
+ "auth": "github:scriptkitties",
+ "description": "YAML parser for Config.",
+ "license": "GPL-3.0",
+ "depends": [
+ "Config",
+ "YAMLish"
+ ],
+ "provides": {
+ "Config::Parser::yaml": "lib/Config/Parser/yaml.pm6"
+ },
+ "authors": [
+ "Patrick Spek <p.spek@tyil.work>"
+ ],
+ "tags": [
+ "config",
+ "configuration",
+ "yaml"
+ ],
+ "test-depends": [
+ "Test::META"
+ ],
+ "source-url": "https://github.com/scriptkitties/p6-Config-Parser-yaml.git"
+}
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..6c69d0d
--- /dev/null
+++ b/README.md
@@ -0,0 +1,15 @@
+# Config::Parser::yaml
+A YAML parser for Config.
+
+## License
+This program is free software: you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free Software
+Foundation, either version 3 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along with
+this program. If not, see <http://www.gnu.org/licenses/>.
diff --git a/lib/Config/Parser/yaml.pm6 b/lib/Config/Parser/yaml.pm6
new file mode 100644
index 0000000..c0c194e
--- /dev/null
+++ b/lib/Config/Parser/yaml.pm6
@@ -0,0 +1,14 @@
+#! /usr/bin/env false
+
+use v6.c;
+
+use Config::Parser;
+use YAMLish;
+
+class Config::Parser::yaml is Config::Parser
+{
+ method read(Str $path --> Hash)
+ {
+ load-yaml(slurp $path);
+ }
+}
diff --git a/t/read.t b/t/read.t
new file mode 100644
index 0000000..a65e6e8
--- /dev/null
+++ b/t/read.t
@@ -0,0 +1,15 @@
+#! /usr/bin/env perl6
+
+use v6.c;
+use Test;
+use lib "lib";
+
+use Config;
+
+plan 3;
+
+my $config = Config.new();
+
+ok $config.read("t/test.yaml");
+ok $config.get("a") eq "a";
+ok $config.get("b.c") eq "c";
diff --git a/t/test.yaml b/t/test.yaml
new file mode 100644
index 0000000..2b93ee8
--- /dev/null
+++ b/t/test.yaml
@@ -0,0 +1,3 @@
+a: a
+b:
+ c: c