package System::Introspector::Report::Publish::StdOut;
use Moo;
use JSON::PP;

has report => (is => 'ro');

my $_json = JSON::PP->new->utf8->pretty;

sub publish {
  my ($self, $reports) = @_;
  my $match = $self->report;
  return unless defined $match;
  $match = $self->_prepare_matcher_from($match);
  for my $idx (0 .. $#$reports) {
    my $report = $reports->[$idx];
    next unless $self->_match_id($report, $match);
    print $_json->encode($report), "\n";
    print "---\n"
      if $idx < $#$reports;
  }
  return 1;
}

with $_ for qw(
  System::Introspector::Report::Publish::API
);

1;
