mediawiki report publishing
[scpubgit/System-Introspector-Report.git] / lib / System / Introspector / Report / Publish / API.pm
1 package System::Introspector::Report::Publish::API;
2 use Moo::Role;
3
4 requires qw(
5   publish
6 );
7
8 sub _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
19 sub _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
29 1;