dynamic page-name publishing for mediawiki
[scpubgit/System-Introspector-Report.git] / lib / System / Introspector / Report / Publish / API.pm
CommitLineData
499ebcdd 1package System::Introspector::Report::Publish::API;
2use Moo::Role;
3
4requires qw(
5 publish
6);
7
8sub _prepare_matcher_from {
9 my ($self, $matchers) = @_;
10 my $pattern = join '|', map {
11 my @elements = split m{:}, $_;
12 join qr{\0}, map {
13 ($_ eq '*') ? qr{[^\0]+} : qr{\Q$_\E};
14 } split m{:}, $_;
15 } ref($matchers) ? @$matchers : $matchers;
16 return qr{^(?:$pattern)$};
17}
18
19sub _match_id {
20 my ($self, $report, $match) = @_;
21 $match = $self->_prepare_matcher_from($match)
22 unless ref($match) eq 'Regexp';
23 my $id = join "\0", ref($report->{id})
24 ? @{$report->{id}}
25 : ($report->{id});
26 return $id =~ $match;
27}
28
291;