Koha-QA

 view release on metacpan or  search on metacpan

lib/Koha/QA/Base.pm  view on Meta::CPAN

package Koha::QA::Base;

use Modern::Perl;
use File::Slurp qw(read_file);
use File::Temp  qw(tempfile);

=head1 NAME

Koha::QA::Base - Base class for Koha QA modules

=head1 SYNOPSIS

  use base 'Koha::QA::Base';

  sub new {
      my ($class, $params) = @_;
      my $self = $class->SUPER::new($params);
      # ... child class initialization
      return $self;
  }

=head1 DESCRIPTION

This is the base class for Koha QA modules. It provides common functionality
for file/content handling and error management.

=head1 METHODS

=head2 new

  my $checker = $class->SUPER::new({file => $file_path});
  my $checker = $class->SUPER::new({content => $template_content});

Creates a new QA checker instance.
Accepts either a 'file' parameter (path to a file to read) or a 'content' parameter (string content).

=head2 content

  my $content = $checker->content;

Returns the content being checked.

=head2 file

  my $file_path = $checker->file;

Returns the file path being checked. If the object was created with content
instead of a file, this method will generate a temporary file with the content.

=head2 errors

  my @errors = $checker->errors;

Returns array of error hashrefs.

=cut

sub new {
    my ( $class, $params ) = @_;

    my $content =
          exists $params->{content} ? $params->{content}
        : exists $params->{file}    ? read_file( $params->{file} )



( run in 1.156 second using v1.01-cache-2.11-cpan-eb134014566 )