From 99f8ccd6cddc6fa9a021d4118e6a706a19e474b1 Mon Sep 17 00:00:00 2001 From: dakkar Date: Thu, 10 Sep 2015 15:46:11 +0100 Subject: maybe I got deps working I'd still like to make the whole thing more readable, though --- lib/WebCoso/Maker.pm | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) (limited to 'lib/WebCoso/Maker.pm') diff --git a/lib/WebCoso/Maker.pm b/lib/WebCoso/Maker.pm index 91ceb03..b64c9cf 100644 --- a/lib/WebCoso/Maker.pm +++ b/lib/WebCoso/Maker.pm @@ -4,7 +4,7 @@ role WebCoso::Maker[$from,$to] { has $.basename; has $.dir; - method process-contents(:$src,:@deps) { ... } + method process-contents($src) { ... } method dest-files() { say "Maker[$from,$to]($.dir/$.basename)::dest-files"; @@ -16,8 +16,16 @@ role WebCoso::Maker[$from,$to] { return $.wc.get-files($.dir,$.basename,$from); } + method get-file($path) { + return $.wc.get-file($.dir,$path); + } + method dep-files() { - return Hash; + return $.wc.load-deps($.dir,$.basename,$to); + } + + method set-deps(%deps) { + $.wc.save-deps($.dir,$.basename,$to,%deps); } method make() { @@ -34,20 +42,22 @@ role WebCoso::Maker[$from,$to] { my @deps = %deps{$lang} // (); say "Maker[$from,$to]($.dir/$.basename)::make lang $lang"; say "Maker[$from,$to]($.dir/$.basename)::make dst modified {$dst ?? $dst.modified !! 'not-there'} src modified {$src.modified}"; - next if $dst and $dst.modified after + next if $dst and not $dst.modified before all($src.modified,@depsĀ».modified.flat); say "Maker[$from,$to]($.dir/$.basename)::make processing $lang"; - my $processed-contents = self.process-contents( - src => $src.slurp, - deps => @depsĀ».slurp, + my ($processed-contents,@new_deps) = self.process-contents( + $src, ); - # that .Str.IO is a hack to work around - # https://rt.perl.org/Public/Bug/Display.html?id=126006 %dsts{$lang} = $.wc.put-file($.dir,$.basename,$lang,$to, - $processed-contents).Str.IO; + $processed-contents); + %deps{$lang} = @new_deps + if @new_deps; } + + $.set-deps(%deps); + return %dsts; } } -- cgit v1.2.3