From cd8cecc2a64e623d1342b7b37aa1506ad40c3a6e Mon Sep 17 00:00:00 2001 From: dakkar Date: Sat, 5 Sep 2015 16:35:10 +0100 Subject: deps test fails --- lib/WebCoso.pm | 4 ++-- lib/WebCoso/Doc/Base.pm | 22 ++++++++++++++++------ lib/WebCoso/Doc/Feed.pm | 3 ++- lib/WebCoso/Doc/Page.pm | 3 ++- run.p6 | 4 ++-- t/tests/page.t | 34 ++++++++++++++++++++++++++++++++++ 6 files changed, 58 insertions(+), 12 deletions(-) create mode 100644 t/tests/page.t diff --git a/lib/WebCoso.pm b/lib/WebCoso.pm index 66fbf5f..37111b5 100644 --- a/lib/WebCoso.pm +++ b/lib/WebCoso.pm @@ -37,10 +37,10 @@ class WebCoso { return $f; } - method new-doc(:$dir) { + method new-page($dir) { @!docs.push(WebCoso::Doc::Page.new(:$dir,wc=>self)); } - method new-feed(:$dir) { + method new-feed($dir) { @!docs.push(WebCoso::Doc::Feed.new(:$dir,wc=>self)); } method run() { diff --git a/lib/WebCoso/Doc/Base.pm b/lib/WebCoso/Doc/Base.pm index 9ceefa1..46afce8 100644 --- a/lib/WebCoso/Doc/Base.pm +++ b/lib/WebCoso/Doc/Base.pm @@ -4,16 +4,26 @@ use WebCoso::Maker::RST; use WebCoso::Maker::XHTML; use WebCoso::Maker::HTML; -role WebCoso::Doc::Base[$basename] { +class WebCoso::Doc::Base { has $!wc; has $.dir; - has $.tt = WebCoso::Maker::TT.new(:$basename,:$!dir,:$!wc); - has $.rst = WebCoso::Maker::RST.new(:$basename,:$!dir,:$!wc); - has $.xhtml = WebCoso::Maker::XHTML.new(:$basename,:$!dir,:$!wc); - has $.html = WebCoso::Maker::HTML.new(:$basename,:$!dir,:$!wc); + has $.tt; + has $.rst; + has $.xhtml; + has $.html; + method basename() { ... } + + submethod BUILD(:$wc,:$dir) { + my $basename = self.basename; + $!tt = WebCoso::Maker::TT.new(:$basename,:$dir,:$wc); + $!rst = WebCoso::Maker::RST.new(:$basename,:$dir,:$wc); + $!xhtml = WebCoso::Maker::XHTML.new(:$basename,:$dir,:$wc); + $!html = WebCoso::Maker::HTML.new(:$basename,:$dir,:$wc); + } + method make() { - .html.get-files(); + $.html.get-files(); } } diff --git a/lib/WebCoso/Doc/Feed.pm b/lib/WebCoso/Doc/Feed.pm index 2b36c1e..1fda60a 100644 --- a/lib/WebCoso/Doc/Feed.pm +++ b/lib/WebCoso/Doc/Feed.pm @@ -1,4 +1,5 @@ # -*- mode: perl6 -*- use WebCoso::Doc::Base; -class WebCoso::Doc::Feed does WebCoso::Doc::Base['feed'] { +class WebCoso::Doc::Feed is WebCoso::Doc::Base { + method basename { 'feed' } } diff --git a/lib/WebCoso/Doc/Page.pm b/lib/WebCoso/Doc/Page.pm index be92d8c..438ef4a 100644 --- a/lib/WebCoso/Doc/Page.pm +++ b/lib/WebCoso/Doc/Page.pm @@ -1,4 +1,5 @@ # -*- mode: perl6 -*- use WebCoso::Doc::Base; -class WebCoso::Doc::Page does WebCoso::Doc::Base['document'] { +class WebCoso::Doc::Page is WebCoso::Doc::Base { + method basename() { 'document' } } diff --git a/run.p6 b/run.p6 index a041423..d5967b4 100644 --- a/run.p6 +++ b/run.p6 @@ -7,7 +7,7 @@ my $wc = WebCoso.new( ); -$wc.new-doc(dir => $_) for «one one/two three/four»; -$wc.new-feed(dir => $_) for «tags/one tags/two»; +$wc.new-page($_) for «one one/two three/four»; +$wc.new-feed($_) for «tags/one tags/two»; $wc.run; diff --git a/t/tests/page.t b/t/tests/page.t new file mode 100644 index 0000000..e42e738 --- /dev/null +++ b/t/tests/page.t @@ -0,0 +1,34 @@ +# -*- mode: perl6 -*- +use Test; +use lib 't/lib'; +use Test::WebCoso; +use File::Temp; +use WebCoso; + +my $testdir = tempdir.IO; +my $srcdir = $testdir.child('src'); +my $destdir = $testdir.child('dst'); + +$srcdir.mkdir; +$destdir.mkdir; + +$srcdir.child('document.it.tt').spurt('it'); +$srcdir.child('document.en.rest.txt').spurt('en'); + +my $wc = WebCoso.new(:$srcdir,:$destdir); +$wc.new-page(Nil); +$wc.run(); + +my %output = $wc.get-files(Nil,'document','html'); +dd %output; + +cmp-files( + %output, + { + it => { $^x.slurp eq 'it expanded parsed converted decorated' }, + en => { $^x.slurp eq 'en parsed converted decorated' }, + }, + 'built everyting', +); + +done-testing; -- cgit v1.2.3