use WebCoso::Doc::Page;
use WebCoso::Doc::Feed;
class WebCoso {
has $.srcdir;
has $.destdir;
has $!tmpdir = $*SPEC.tmpdir.child('abcde');
has @!docs;
method get-files($dir,$basename,$ext) {
gather {
for $.srcdir,$!tmpdir -> $base {
my @files = try {
CATCH {
when X::IO { }
}
$base.child($dir).dir(
test => /$basename \. .+? \. $ext/,
);
} // ();
take $_ for map {
(.basename ~~ /$basename \. (.+?) \. $ext/)[0]
=>
$_
}, @files;
}
}
}
method put-file($dir,$basename,$lang,$ext,$contents) {
$!tmpdir.child($dir).child("{$basename}.{$lang}.{$ext}").spurt($contents);
return;
}
method new-doc(:$dir) {
@!docs.push(WebCoso::Doc::Page.new(:$dir,wc=>self));
}
method new-feed(:$dir) {
@!docs.push(WebCoso::Doc::Feed.new(:$dir,wc=>self));
}
method run() {
.make() for @!docs;
}
}