From 4680e1b5b2dd75a4bdb59672ffb5cb72c95d1efd Mon Sep 17 00:00:00 2001 From: Cameron Ross Date: Fri, 27 Apr 2018 00:17:09 -0300 Subject: [PATCH] update examples so they can compile again, and make them visible to dub --- dub.json | 11 +++++++- examples/constructor/dub.json | 4 +-- examples/constructor/main.d | 2 +- examples/getting_started/dub.json | 4 +-- examples/getting_started/main.d | 2 +- examples/representer/dub.json | 4 +-- examples/representer/main.d | 4 +-- examples/resolver/dub.json | 4 +-- examples/resolver/main.d | 2 +- examples/yaml_bench/dub.json | 10 ++----- examples/yaml_bench/yaml_bench.d | 46 +++++++++++++++---------------- examples/yaml_gen/dub.json | 4 +-- examples/yaml_gen/yaml_gen.d | 4 +-- examples/yaml_stats/dub.json | 4 +-- examples/yaml_stats/yaml_stats.d | 6 ++-- 15 files changed, 57 insertions(+), 54 deletions(-) diff --git a/dub.json b/dub.json index c8d6f66..1108a96 100644 --- a/dub.json +++ b/dub.json @@ -7,5 +7,14 @@ "license": "Boost 1.0", "dependencies": { "tinyendian" : { "version" : "~>0.1.0" } }, "homepage": "https://github.com/dlang-community/D-YAML", - "copyright": "Copyright © 2011-2014, Ferdinand Majerech" + "copyright": "Copyright © 2011-2014, Ferdinand Majerech", + "subPackages": [ + "examples/constructor", + "examples/getting_started", + "examples/representer", + "examples/resolver", + "examples/yaml_bench", + "examples/yaml_gen", + "examples/yaml_stats" + ] } diff --git a/examples/constructor/dub.json b/examples/constructor/dub.json index 4b70bb6..1aca4ee 100644 --- a/examples/constructor/dub.json +++ b/examples/constructor/dub.json @@ -5,6 +5,6 @@ "mainSourceFile": "main.d", "dependencies": { - "dyaml": { "version" : "~>0.5.0"}, - }, + "dyaml": { "version" : "*"} + } } diff --git a/examples/constructor/main.d b/examples/constructor/main.d index f92d62e..0fcec9f 100644 --- a/examples/constructor/main.d +++ b/examples/constructor/main.d @@ -1,6 +1,6 @@ import std.stdio; import std.string; -import dyaml.all; +import dyaml; struct Color { diff --git a/examples/getting_started/dub.json b/examples/getting_started/dub.json index c4cb217..844c006 100644 --- a/examples/getting_started/dub.json +++ b/examples/getting_started/dub.json @@ -5,6 +5,6 @@ "mainSourceFile": "main.d", "dependencies": { - "dyaml": { "version" : "~>0.5.0" }, - }, + "dyaml": { "version" : "*" } + } } diff --git a/examples/getting_started/main.d b/examples/getting_started/main.d index 26172d3..f268d52 100644 --- a/examples/getting_started/main.d +++ b/examples/getting_started/main.d @@ -1,5 +1,5 @@ import std.stdio; -import dyaml.all; +import dyaml; void main() { diff --git a/examples/representer/dub.json b/examples/representer/dub.json index 27b4a33..c46c42f 100644 --- a/examples/representer/dub.json +++ b/examples/representer/dub.json @@ -5,6 +5,6 @@ "mainSourceFile": "main.d", "dependencies": { - "dyaml": { "version" : "~>0.5.0" }, - }, + "dyaml": { "version" : "*" } + } } diff --git a/examples/representer/main.d b/examples/representer/main.d index e01f56c..1e06091 100644 --- a/examples/representer/main.d +++ b/examples/representer/main.d @@ -1,5 +1,5 @@ import std.stdio; -import dyaml.all; +import dyaml; struct Color { @@ -16,7 +16,7 @@ struct Color } } -Node representColor(ref Node node, Representer representer) +Node representColor(ref Node node, Representer representer) @safe { //The node is guaranteed to be Color as we add representer for Color. Color color = node.as!Color; diff --git a/examples/resolver/dub.json b/examples/resolver/dub.json index dfde9dc..30b55d8 100644 --- a/examples/resolver/dub.json +++ b/examples/resolver/dub.json @@ -5,6 +5,6 @@ "mainSourceFile": "main.d", "dependencies": { - "dyaml": { "version" : "~>0.5.0" }, - }, + "dyaml": { "version" : "*" } + } } diff --git a/examples/resolver/main.d b/examples/resolver/main.d index c18f13d..f01ca41 100644 --- a/examples/resolver/main.d +++ b/examples/resolver/main.d @@ -1,6 +1,6 @@ import std.stdio; import std.string; -import dyaml.all; +import dyaml; struct Color { diff --git a/examples/yaml_bench/dub.json b/examples/yaml_bench/dub.json index 2c4e5c0..b4e778f 100644 --- a/examples/yaml_bench/dub.json +++ b/examples/yaml_bench/dub.json @@ -1,16 +1,10 @@ { - "name": "yaml_bench", + "name": "benchmark", "targetType": "executable", "sourceFiles": ["yaml_bench.d"], "mainSourceFile": "yaml_bench.d", "dependencies": { - "dyaml": { "version" : "~>0.5.0" }, - }, - "buildTypes": - { - "debug": { "buildOptions": ["debugMode", "debugInfoC"] }, - "release": { "buildOptions": ["releaseMode", "optimize", "inline", "noBoundsCheck"] }, - "profile": { "buildOptions": ["releaseMode", "optimize", "noBoundsCheck", "debugInfoC"] } + "dyaml": { "version" : "*" } } } diff --git a/examples/yaml_bench/yaml_bench.d b/examples/yaml_bench/yaml_bench.d index e22430d..f203895 100644 --- a/examples/yaml_bench/yaml_bench.d +++ b/examples/yaml_bench/yaml_bench.d @@ -1,32 +1,32 @@ module dyaml.yaml_bench; -//Benchmark that loads, and optionally extracts data from and/or emits a YAML file. +//Benchmark that loads, and optionally extracts data from and/or emits a YAML file. import std.conv; import std.datetime; import std.stdio; import std.string; -import dyaml.all; +import dyaml; ///Print help information. void help() { string help = - "D:YAML benchmark\n" - "Copyright (C) 2011-2014 Ferdinand Majerech\n" - "Usage: yaml_bench [OPTION ...] [YAML_FILE]\n" - "\n" - "Loads and optionally extracts data and/or dumps a YAML file.\n" - "\n" - "Available options:\n" - " -h --help Show this help information.\n" - " -g --get Extract data from the file (using Node.as()).\n" - " -d --dump Dump the loaded data (to YAML_FILE.dump).\n" - " -r --runs=NUM Repeat parsing the file NUM times.\n" - " --reload Reload the file from the diskl on every repeat\n" - " By default, the file is loaded to memory once\n" - " and repeatedly parsed from memory.\n" - " -s --scan-only Do not execute the entire parsing process, only\n" + "D:YAML benchmark\n"~ + "Copyright (C) 2011-2014 Ferdinand Majerech\n"~ + "Usage: yaml_bench [OPTION ...] [YAML_FILE]\n"~ + "\n"~ + "Loads and optionally extracts data and/or dumps a YAML file.\n"~ + "\n"~ + "Available options:\n"~ + " -h --help Show this help information.\n"~ + " -g --get Extract data from the file (using Node.as()).\n"~ + " -d --dump Dump the loaded data (to YAML_FILE.dump).\n"~ + " -r --runs=NUM Repeat parsing the file NUM times.\n"~ + " --reload Reload the file from the diskl on every repeat\n"~ + " By default, the file is loaded to memory once\n"~ + " and repeatedly parsed from memory.\n"~ + " -s --scan-only Do not execute the entire parsing process, only\n"~ " scanning. Overrides '--dump'.\n"; writeln(help); } @@ -71,10 +71,10 @@ void main(string[] args) string file = null; //Parse command line args - foreach(arg; args[1 .. $]) + foreach(arg; args[1 .. $]) { auto parts = arg.split("="); - if(arg[0] == '-') switch(parts[0]) + if(arg[0] == '-') switch(parts[0]) { case "--help", "-h": help(); return; case "--get", "-g": get = true; break; @@ -88,8 +88,8 @@ void main(string[] args) { if(file !is null) { - writeln("\nUnknown argument or file specified twice: ", arg, "\n\n"); - help(); + writeln("\nUnknown argument or file specified twice: ", arg, "\n\n"); + help(); return; } @@ -98,8 +98,8 @@ void main(string[] args) } if(file is null) { - writeln("\nFile not specified.\n\n"); - help(); + writeln("\nFile not specified.\n\n"); + help(); return; } diff --git a/examples/yaml_gen/dub.json b/examples/yaml_gen/dub.json index 65813a0..1f5a2d1 100644 --- a/examples/yaml_gen/dub.json +++ b/examples/yaml_gen/dub.json @@ -5,6 +5,6 @@ "mainSourceFile": "yaml_gen.d", "dependencies": { - "dyaml": { "version" : "~>0.5.0" }, - }, + "dyaml": { "version" : "*" } + } } diff --git a/examples/yaml_gen/yaml_gen.d b/examples/yaml_gen/yaml_gen.d index 96be25a..d987415 100644 --- a/examples/yaml_gen/yaml_gen.d +++ b/examples/yaml_gen/yaml_gen.d @@ -8,7 +8,7 @@ import std.math; import std.random; import std.stdio; import std.string; -import dyaml.all; +import dyaml; Node config; @@ -220,7 +220,7 @@ Node pairs(bool root, bool complex, Node range, string tag) { auto key = generateNode(randomType(typesScalarKey ~ (complex ? typesCollection : []))); // Maps can't contain duplicate keys - while(tag.endsWith("map") && keys[0 .. i].canFind(key)) + while(tag.endsWith("map") && keys[0 .. i].canFind(key)) { key = generateNode(randomType(typesScalarKey ~ (complex ? typesCollection : []))); } diff --git a/examples/yaml_stats/dub.json b/examples/yaml_stats/dub.json index 852cf1a..c86f091 100644 --- a/examples/yaml_stats/dub.json +++ b/examples/yaml_stats/dub.json @@ -5,6 +5,6 @@ "mainSourceFile": "yaml_stats.d", "dependencies": { - "dyaml": { "version" : "~>0.5.0" }, - }, + "dyaml": { "version" : "*" } + } } diff --git a/examples/yaml_stats/yaml_stats.d b/examples/yaml_stats/yaml_stats.d index 4a2877e..3e88d20 100644 --- a/examples/yaml_stats/yaml_stats.d +++ b/examples/yaml_stats/yaml_stats.d @@ -3,7 +3,7 @@ import std.stdio; import std.string; -import dyaml.all; +import dyaml; ///Collects statistics about a YAML document and returns them as string. @@ -66,8 +66,8 @@ string statistics(ref Node document) "\nMappings: %s" ~ "\n\nAverage sequence length: %s" ~ "\nAverage mapping length: %s" ~ - "\n\n%s", - nodes, scalars, sequences, mappings, + "\n\n%s", + nodes, scalars, sequences, mappings, sequences == 0.0 ? 0.0 : cast(real)seqItems / sequences, mappings == 0.0 ? 0.0 : cast(real)mapPairs / mappings, tagStats);