From a5c9ad058898d4467cdc6993a9c1b3b1a096935f Mon Sep 17 00:00:00 2001 From: Patrick Spek Date: Sun, 23 Apr 2017 21:31:18 +0200 Subject: Initial commit --- .gitignore | 2 ++ META6.json | 27 +++++++++++++++++++++++++++ README.md | 15 +++++++++++++++ lib/Config/Parser/yaml.pm6 | 14 ++++++++++++++ t/read.t | 15 +++++++++++++++ t/test.yaml | 3 +++ 6 files changed, 76 insertions(+) create mode 100644 .gitignore create mode 100644 META6.json create mode 100644 README.md create mode 100644 lib/Config/Parser/yaml.pm6 create mode 100644 t/read.t create mode 100644 t/test.yaml 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 " + ], + "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 . 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 -- cgit v1.1