App-MARC-Validator-Report

 view release on metacpan or  search on metacpan

Report.pm  view on Meta::CPAN

	foreach my $plugin (keys %{$self->{'_list'}}) {
		if ($self->{'_opts'}->{'p'} eq 'all' || $self->{'_opts'}->{'p'} eq $plugin) {
			if (keys %{$self->{'_list'}->{$plugin}} == 0) {
				next;
			}
			print "Plugin '$plugin':\n";
			foreach my $error (sort keys %{$self->{'_list'}->{$plugin}}) {
				if ($self->{'_opts'}->{'e'} eq 'all' || $self->{'_opts'}->{'e'} eq $error) {
					print "- $error\n";
					foreach my $id (sort @{$self->{'_list'}->{$plugin}->{$error}}) {
						my @err = @{$self->{'_report'}->{$plugin}->{'checks'}->{'not_valid'}->{$id}};
						my $struct_hr = {};
						foreach my $err_hr (@err) {
							if ($err_hr->{'error'} eq $error) {
								$struct_hr = $err_hr->{'params'};
							}
						}
						print "-- $id";
						my $i = 0;
						foreach my $param_key (keys %{$struct_hr}) {
							if ($i == 0) {

Report.pm  view on Meta::CPAN


	# JSON output.
	my $j = Cpanel::JSON::XS->new;
	$self->{'_report'} = $j->decode($report);

	$self->{'_list'} = {};
	foreach my $plugin (keys %{$self->{'_report'}}) {
		if (! exists $self->{'_report'}->{$plugin}->{'checks'}) {
			err "Doesn't exist key '".$self->{'_report'}->{$plugin}->{'checks'}." in plugin $plugin.";
		}
		if (! exists $self->{'_report'}->{$plugin}->{'checks'}->{'not_valid'}) {
			err "Doesn't exist key '".$self->{'_report'}->{$plugin}->{'checks'}->{'not_valid'}." in plugin $plugin.";
		}
		if (! exists $self->{'_list'}->{$plugin}) {
			$self->{'_list'}->{$plugin} = {};
		}
		my $not_valid_hr = $self->{'_report'}->{$plugin}->{'checks'}->{'not_valid'};
		foreach my $record_id (keys %{$not_valid_hr}) {
			foreach my $error_hr (@{$not_valid_hr->{$record_id}}) {
				if (! exists $self->{'_list'}->{$plugin}->{$error_hr->{'error'}}) {
					$self->{'_list'}->{$plugin}->{$error_hr->{'error'}} = [$record_id];
				} else {
					push @{$self->{'_list'}->{$plugin}->{$error_hr->{'error'}}}, $record_id;
				}
			}
		}
	}

	return 0;

t/data/report1.json  view on Meta::CPAN

{
   "field_008" : {
      "checks" : {
         "not_valid" : {}
      },
      "datetime" : "2025-07-02T20:03:53",
      "module_name" : "MARC::Validator::Plugin::Field008",
      "module_version" : 0.01,
      "name" : "field_008"
   },
   "field_260" : {
      "checks" : {
         "not_valid" : {
            "cnb001926336" : [
               {
                  "error" : "Bad year in parenthesis in MARC field 260 $c.",
                  "params" : {
                     "Value" : "(1933)"
                  }
               }
            ]
         }
      },
      "datetime" : "2025-07-02T20:03:53",
      "module_name" : "MARC::Validator::Plugin::Field260",
      "module_version" : 0.01,
      "name" : "field_260"
   },
   "field_264" : {
      "checks" : {
         "not_valid" : {}
      },
      "datetime" : "2025-07-02T20:03:53",
      "module_name" : "MARC::Validator::Plugin::Field264",
      "module_version" : 0.01,
      "name" : "field_264"
   }
}



( run in 1.087 second using v1.01-cache-2.11-cpan-0a987023a57 )