From e897eee6d6157314ef3396a4afca3c331eee9fe1 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Wed, 3 Mar 2021 10:51:41 -0500 Subject: make set_depends run dub describe, track json output - traded $PWD for project root as ./, i.e. from dub describe json - dub describe deletes parts of dependencies that are unreferenced by the project build; these are available elsewhere and there is little reason to keep them --- .../D-YAML/examples/yaml_stats/dub.json | 10 -- .../D-YAML/examples/yaml_stats/small.yaml | 4 - .../D-YAML/examples/yaml_stats/yaml_stats.d | 106 --------------------- 3 files changed, 120 deletions(-) delete mode 100644 src/ext_depends/D-YAML/examples/yaml_stats/dub.json delete mode 100644 src/ext_depends/D-YAML/examples/yaml_stats/small.yaml delete mode 100644 src/ext_depends/D-YAML/examples/yaml_stats/yaml_stats.d (limited to 'src/ext_depends/D-YAML/examples/yaml_stats') diff --git a/src/ext_depends/D-YAML/examples/yaml_stats/dub.json b/src/ext_depends/D-YAML/examples/yaml_stats/dub.json deleted file mode 100644 index c86f091..0000000 --- a/src/ext_depends/D-YAML/examples/yaml_stats/dub.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "name": "yaml_stats", - "targetType": "executable", - "sourceFiles": ["yaml_stats.d"], - "mainSourceFile": "yaml_stats.d", - "dependencies": - { - "dyaml": { "version" : "*" } - } -} diff --git a/src/ext_depends/D-YAML/examples/yaml_stats/small.yaml b/src/ext_depends/D-YAML/examples/yaml_stats/small.yaml deleted file mode 100644 index 4f5c0ea..0000000 --- a/src/ext_depends/D-YAML/examples/yaml_stats/small.yaml +++ /dev/null @@ -1,4 +0,0 @@ -- 1 -- 2 : 'a' - 3 : 'b' -- 4 : [1.0, 2.1, 3.2] diff --git a/src/ext_depends/D-YAML/examples/yaml_stats/yaml_stats.d b/src/ext_depends/D-YAML/examples/yaml_stats/yaml_stats.d deleted file mode 100644 index b3f6c17..0000000 --- a/src/ext_depends/D-YAML/examples/yaml_stats/yaml_stats.d +++ /dev/null @@ -1,106 +0,0 @@ - -///Example D:YAML application that displays statistics about YAML documents. - -import std.stdio; -import std.string; -import dyaml; - - -///Collects statistics about a YAML document and returns them as string. -string statistics(ref Node document) -{ - size_t nodes; - size_t scalars, sequences, mappings; - size_t seqItems, mapPairs; - - size_t[string] tags; - - void crawl(ref Node root) - { - ++nodes; - if((root.tag in tags) is null) - { - tags[root.tag] = 0; - } - ++tags[root.tag]; - final switch (root.nodeID) - { - case NodeID.scalar: - ++scalars; - return; - case NodeID.sequence: - ++sequences; - seqItems += root.length; - foreach(ref Node node; root) - { - crawl(node); - } - return; - case NodeID.mapping: - ++mappings; - mapPairs += root.length; - foreach(ref Node key, ref Node value; root) - { - crawl(key); - crawl(value); - } - return; - case NodeID.invalid: - assert(0); - } - } - - crawl(document); - - string tagStats = "\nTag statistics:\n"; - foreach(tag, count; tags) - { - tagStats ~= format("\n%s : %s", tag, count); - } - - return format( "\nNodes: %s" ~ - "\n\nScalars: %s" ~ - "\nSequences: %s" ~ - "\nMappings: %s" ~ - "\n\nAverage sequence length: %s" ~ - "\nAverage mapping length: %s" ~ - "\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); -} - -void main(string[] args) -{ - //Help message - if(args.length == 1) - { - writeln("Usage: yaml_stats [YAML_FILE ...]\n"); - writeln("Analyzes YAML files with provided filenames and displays statistics."); - return; - } - - //Print stats about every document in every file. - foreach(file; args[1 .. $]) - { - writeln("\nFile ", file); - writeln("------------------------------------------------------------"); - try - { - auto loader = Loader.fromFile(file); - - size_t idx = 0; - foreach(ref document; loader) - { - writeln("\nDocument ", idx++); - writeln("----------------------------------------"); - writeln(statistics(document)); - } - } - catch(YAMLException e) - { - writeln("ERROR: ", e.msg); - } - } -} -- cgit v1.2.3