diff options
Diffstat (limited to 'lib/WebCoso')
-rw-r--r-- | lib/WebCoso/Doc/Base.pm | 13 | ||||
-rw-r--r-- | lib/WebCoso/Maker.pm | 15 | ||||
-rw-r--r-- | lib/WebCoso/Maker/HTML.pm | 7 | ||||
-rw-r--r-- | lib/WebCoso/Maker/RST.pm | 7 | ||||
-rw-r--r-- | lib/WebCoso/Maker/TT.pm | 7 | ||||
-rw-r--r-- | lib/WebCoso/Maker/XHTML.pm | 7 |
6 files changed, 45 insertions, 11 deletions
diff --git a/lib/WebCoso/Doc/Base.pm b/lib/WebCoso/Doc/Base.pm index 2d6bb1a..9ceefa1 100644 --- a/lib/WebCoso/Doc/Base.pm +++ b/lib/WebCoso/Doc/Base.pm @@ -1,12 +1,17 @@ # -*- mode: perl6 -*- +use WebCoso::Maker::TT; +use WebCoso::Maker::RST; +use WebCoso::Maker::XHTML; +use WebCoso::Maker::HTML; + role WebCoso::Doc::Base[$basename] { has $!wc; has $.dir; - has $.tt = Maker::TT.new(:$basename,:$!dir,:$!wc); - has $.rst = Maker::RST.new(:$basename,:$!dir,:$!wc); - has $.xhtml = Maker::XHTML.new(:$basename,:$!dir,:$!wc); - has $.html = Maker::HTML.new(:$basename,:$!dir,:$!wc); + 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); method make() { .html.get-files(); diff --git a/lib/WebCoso/Maker.pm b/lib/WebCoso/Maker.pm index e9564fa..5aae4f8 100644 --- a/lib/WebCoso/Maker.pm +++ b/lib/WebCoso/Maker.pm @@ -1,21 +1,22 @@ # -*- mode: perl6 -*- -role Maker[:$from,:$to] { - has $!wc; +role WebCoso::Maker[$from,$to] { + has $.wc; has $.basename; has $.dir; - method process-contents(:$from-contents) { ... } + method process-contents($from-contents) { ... } method get-files() { - my %dsts = $!wc.get-files($.dir,$.basename,$from); - my %srcs = $!wc.get-files($.dir,$.basename,$to); + my %srcs = $.wc.get-files($.dir,$.basename,$from); + my %dsts = $.wc.get-files($.dir,$.basename,$to); for %srcs.keys -> $lang { my $src = %srcs{$lang}; next if %dsts{$lang} and %dsts{$lang}.modified after $src.modified; - my $processed-contents = .process-contents($src.slurp); - %dsts{$lang} = $!wc.put-file($.dir,$.basename,$lang,$to, + my $processed-contents = self.process-contents($src.slurp); + %dsts{$lang} = $.wc.put-file($.dir,$.basename,$lang,$to, $processed-contents) } + return %dsts; } } diff --git a/lib/WebCoso/Maker/HTML.pm b/lib/WebCoso/Maker/HTML.pm new file mode 100644 index 0000000..1003cbc --- /dev/null +++ b/lib/WebCoso/Maker/HTML.pm @@ -0,0 +1,7 @@ +# -*- mode: perl6 -*- +use WebCoso::Maker; +class WebCoso::Maker::HTML does WebCoso::Maker['xhtml','html'] { + method process-contents($xhtml) { + return "{$xhtml} decorated"; + } +} diff --git a/lib/WebCoso/Maker/RST.pm b/lib/WebCoso/Maker/RST.pm new file mode 100644 index 0000000..bf75ab1 --- /dev/null +++ b/lib/WebCoso/Maker/RST.pm @@ -0,0 +1,7 @@ +# -*- mode: perl6 -*- +use WebCoso::Maker; +class WebCoso::Maker::RST does WebCoso::Maker['rest.txt','du.xml'] { + method process-contents($rst) { + return "{$rst} parsed"; + } +} diff --git a/lib/WebCoso/Maker/TT.pm b/lib/WebCoso/Maker/TT.pm new file mode 100644 index 0000000..eb5e390 --- /dev/null +++ b/lib/WebCoso/Maker/TT.pm @@ -0,0 +1,7 @@ +# -*- mode: perl6 -*- +use WebCoso::Maker; +class WebCoso::Maker::TT does WebCoso::Maker['tt','rest.txt'] { + method process-contents($tt) { + return "{$tt} expanded"; + } +} diff --git a/lib/WebCoso/Maker/XHTML.pm b/lib/WebCoso/Maker/XHTML.pm new file mode 100644 index 0000000..d33c447 --- /dev/null +++ b/lib/WebCoso/Maker/XHTML.pm @@ -0,0 +1,7 @@ +# -*- mode: perl6 -*- +use WebCoso::Maker; +class WebCoso::Maker::XHTML does WebCoso::Maker['du.xml','xhtml'] { + method process-contents($du) { + return "{$du} converted"; + } +} |