From 6987884c0ace83f214d8cdafc28af3a82d3052d5 Mon Sep 17 00:00:00 2001 From: a-Sansara Date: Tue, 7 Aug 2018 20:14:38 +0200 Subject: [PATCH] update meson.build & samples for docker pluie/libyaml image --- README.md | 14 ++++++++++++++ build.sh | 7 +++++-- install.vala.in | 2 +- meson.build | 6 +++++- samples/json-loader.vala | 2 +- samples/yaml-config.vala | 2 +- samples/yaml-finder.vala | 2 +- samples/yaml-imports.vala | 2 +- samples/yaml-loader.vala | 2 +- samples/yaml-traversing.vala | 2 +- src/vala/Pluie/Yaml.Config.vala | 1 - 11 files changed, 31 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index a44ccff..103d680 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,11 @@ the lib does not manage yet tag directives and tag values. ![pluie-yaml](https://www.meta-tech.academy/img/pluie-yaml-imports2.png) +_legend display_childs_ : + +``` +[ node.name [refCount] node.parent.name node.level node.ntype.infos () node.count () node.uuid ] +``` ## License GNU GPL v3 @@ -52,6 +57,15 @@ a demo image will be available soon on docker hub. you will be able to run a con docker run --rm -it pluie/libyaml ``` +then you can execute any samples : + +``` +./json-loader +``` + +![pluie-yaml-json](https://www.meta-tech.academy/img/pluie-yaml-json.png) + + ## Usage ------------------- diff --git a/build.sh b/build.sh index 45c1347..7cc37b6 100755 --- a/build.sh +++ b/build.sh @@ -61,9 +61,12 @@ function build.lib() { cd "$DIR" build.title "$lib LIB BUILD" - echo meson --prefix=/usr ./ build - sudo ninja -v install -C build + if [ "$UID" != "0" ]; then + sudo ninja -v install -C build + else + ninja -v install -C build + fi local rs=$? build.title "$lib LIB BUILD" $rs return $rs diff --git a/install.vala.in b/install.vala.in index 0f0f87d..c3a7f79 100644 --- a/install.vala.in +++ b/install.vala.in @@ -31,7 +31,7 @@ namespace Pluie namespace Yaml { protected const string INSTALL_PATH = "@INSTALL_PATH@"; - protected const string DATA_PATH = "@DATA_PATH@"; + public const string DATA_PATH = "@DATA_PATH@"; public const string VERSION = "@VERSION@"; } } diff --git a/meson.build b/meson.build index b50ec2d..e6f756c 100644 --- a/meson.build +++ b/meson.build @@ -41,7 +41,7 @@ dep_yaml = cc.find_library('yaml', required : true) version = '0.4' bindir = join_paths(get_option('prefix'), get_option('bindir')) -datadir = join_paths(get_option('prefix'), get_option('datadir'), 'pluie') +datadir = join_paths(get_option('prefix'), get_option('datadir'), 'pluie/yaml') libdir = join_paths(get_option('prefix'), get_option('libdir'), 'pkgconfig') incdir = join_paths(get_option('prefix'), get_option('includedir'), 'pluie') @@ -77,7 +77,11 @@ sources = [ 'src/c/yaml.c' ] +install_data('resources/main.yml', install_dir : datadir) install_data('resources/test.yml', install_dir : datadir) +install_data('resources/test.json', install_dir : datadir) +install_data('resources/config/db.yml', install_dir : join_paths(datadir, 'config')) +install_data('resources/config/subdir/test.yml', install_dir : join_paths(datadir, 'config/subdir')) libpluie_yaml = library( 'pluie-yaml-' + version, diff --git a/samples/json-loader.vala b/samples/json-loader.vala index 43484d8..18dc639 100644 --- a/samples/json-loader.vala +++ b/samples/json-loader.vala @@ -35,7 +35,7 @@ int main (string[] args) { Echo.init(false); - var path = "resources/test.json"; + var path = Yaml.DATA_PATH + "/test.json"; var done = false; of.title ("Pluie Yaml Library", Pluie.Yaml.VERSION, "a-sansara"); diff --git a/samples/yaml-config.vala b/samples/yaml-config.vala index 8ad0048..d9aa34c 100644 --- a/samples/yaml-config.vala +++ b/samples/yaml-config.vala @@ -35,7 +35,7 @@ int main (string[] args) { Echo.init(false); - var path = "resources/config/db.yml"; + var path = Yaml.DATA_PATH + "/config/db.yml"; var done = false; of.title ("Pluie Yaml Library", Pluie.Yaml.VERSION, "a-sansara"); diff --git a/samples/yaml-finder.vala b/samples/yaml-finder.vala index e3670ff..8d08c66 100644 --- a/samples/yaml-finder.vala +++ b/samples/yaml-finder.vala @@ -35,7 +35,7 @@ int main (string[] args) { Echo.init(false); - var path = "resources/test.yml"; + var path = Yaml.DATA_PATH + "/test.yml"; var done = false; of.title ("Pluie Yaml Library", Pluie.Yaml.VERSION, "a-sansara"); diff --git a/samples/yaml-imports.vala b/samples/yaml-imports.vala index 04ebde1..8257f61 100644 --- a/samples/yaml-imports.vala +++ b/samples/yaml-imports.vala @@ -35,7 +35,7 @@ int main (string[] args) { Echo.init(false); - var path = "./resources/main.yml"; + var path = Yaml.DATA_PATH + "/main.yml"; var done = false; of.title ("Pluie Yaml Library", Pluie.Yaml.VERSION, "a-sansara"); diff --git a/samples/yaml-loader.vala b/samples/yaml-loader.vala index c817e61..0c0f22e 100644 --- a/samples/yaml-loader.vala +++ b/samples/yaml-loader.vala @@ -35,7 +35,7 @@ int main (string[] args) { Echo.init(false); - var path = "resources/test.yml"; + var path = Yaml.DATA_PATH + "/test.yml"; var done = false; of.title ("Pluie Yaml Library", Pluie.Yaml.VERSION, "a-sansara"); diff --git a/samples/yaml-traversing.vala b/samples/yaml-traversing.vala index 728c552..28772af 100644 --- a/samples/yaml-traversing.vala +++ b/samples/yaml-traversing.vala @@ -35,7 +35,7 @@ int main (string[] args) { Echo.init(false); - var path = "resources/test.yml"; + var path = Yaml.DATA_PATH + "/test.yml"; var done = false; of.title ("Pluie Yaml Library", Pluie.Yaml.VERSION, "a-sansara"); diff --git a/src/vala/Pluie/Yaml.Config.vala b/src/vala/Pluie/Yaml.Config.vala index cb7fda3..e448338 100644 --- a/src/vala/Pluie/Yaml.Config.vala +++ b/src/vala/Pluie/Yaml.Config.vala @@ -137,7 +137,6 @@ public class Pluie.Yaml.Config Yaml.Node? n = null; Yaml.Config? conf = null; foreach(var entry in this.paths.entries) { - of.keyval(entry.key, entry.value); conf = new Yaml.Config(entry.value, this.displayFile); sub = conf.loader.get_nodes (); n = new Yaml.Mapping (root, entry.key);