From f9c94b7a883547c33aa2ff3d07a5e98c3a5307fe Mon Sep 17 00:00:00 2001 From: Alexey Melezhik Date: Fri, 12 Jul 2024 12:58:08 +0000 Subject: [PATCH] Fix issues with a usage of group variables and template varibaes together --- Changes | 5 +++++ bin/sparky-web.raku | 17 +++++++++++++---- templates/build.crotmp | 7 ++++++- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/Changes b/Changes index 9793f2c..82116a3 100644 --- a/Changes +++ b/Changes @@ -2,6 +2,11 @@ Revision history for Sparky {{$NEXT}} + - Fix issues with a usage of + group variables + and template varibaes + together + 0.2.7 2024-06-14T13:30:00Z - Huge overhaul of documentation diff --git a/bin/sparky-web.raku b/bin/sparky-web.raku index 7f8c464..59946cc 100644 --- a/bin/sparky-web.raku +++ b/bin/sparky-web.raku @@ -823,9 +823,18 @@ sub create-cro-app ($pool) { } - my @group_vars = %project-conf || []; + my @vars; - for (%project-conf<> || []).grep({$group ?? @group_vars.Bag ∩ $_<>.Bag !! True}) -> $v { + for (%project-conf<> || []) -> $v { + + if ($v && %project-conf<>.Bag ∩ $v<>.Bag) { + say "{$v} group:{$v} is added by group condition ..."; + } else { + say "{$v} group:{($v||[]).perl} is filtered out by group condition ..."; + next; + } + + @vars.push($v); if $v { for $v ~~ m:global/"%" (\S+?) "%"/ -> $c { @@ -908,7 +917,7 @@ sub create-cro-app ($pool) { http-root => sparky-http-root(), sparky-tcp-port => sparky-tcp-port(), group_vars => $group ?? [] !! %project-conf || [], - render-vars => $group ?? True !! ( @group_vars ?? False !! True ), + render-vars => $group ?? True !! ( @vars.elems > 0 ?? True !! False ), css =>css(), navbar => navbar($user, $token), project => $project, @@ -916,7 +925,7 @@ sub create-cro-app ($pool) { disabled => %project-conf || False, project-conf-str => $project-conf-str || "configuration not found", project-conf => %project-conf || {}, - vars => (%project-conf || []).grep({$group ?? [$group].Bag ∩ $_<>.Bag !! True}) || [], + vars => @vars, scenario-code => "$root/$project/sparrowfile".IO ~~ :e ?? "$root/$project/sparrowfile".IO.slurp !! "scenario not found", error => $error } diff --git a/templates/build.crotmp b/templates/build.crotmp index ba4df8d..ef8f22b 100644 --- a/templates/build.crotmp +++ b/templates/build.crotmp @@ -36,7 +36,12 @@ + + + + + @@ -56,7 +61,7 @@