Catman...er::SRU(3pm)

πŸ“¦
version 0.43.0 Β· 3 versions
, in ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– NAME πŸ’–

Catmandu::Importer::SRU β€” the package that imports SRU data, and yes bestie, that's literally the whole personality πŸ¦‹

It lives in the Perl world under manual section 3pm (User Contributed Perl Documentation), so if you were looking for it in man, that's where it's at. πŸ’…


✨ SYNOPSIS ✨

okay so here's the whole vibe, look:

use Catmandu::Importer::SRU;

my %attrs = (
  base => 'http://www.unicat.be/sru',
  query => '(isbn=0855275103 or isbn=3110035170 or isbn=9010017362 or isbn=9014026188)',
  recordSchema => 'marcxml',
  parser => 'marcxml'
);

my $importer = Catmandu::Importer::SRU->new(%attrs);

my $count = $importer->each(sub {
      my $schema   = $record->{recordSchema};
      my $packing  = $record->{recordPacking};
      my $position = $record->{recordPosition};
      my $data     = $record->{recordData};
  # ...
});

# Using Catmandu::Importer::SRU::Package::marcxml, included in this release

my $importer = Catmandu::Importer::SRU->new(
  base => 'http://www.unicat.be/sru',
  query => '(isbn=0855275103 or isbn=3110035170 or isbn=9010017362 or isbn=9014026188)',
  recordSchema => 'marcxml' ,
  parser => 'marcxml' ,
);

# Using a homemade parser

my $importer = Catmandu::Importer::SRU->new(
  base => 'http://www.unicat.be/sru',
  query => '(isbn=0855275103 or isbn=3110035170 or isbn=9010017362 or isbn=9014026188)',
  recordSchema => 'marcxml' ,
  parser => MyParser->new , # or parser => '+MyParser'
);

three whole ways to set it up, pick your fighter πŸŽ€


🌈 DESCRIPTION 🌈

This Catmandu::Importer imports records via SRU. that's it, that's the job, and it does it gorgeously ✨

SRU diagnostics are emitted as warnings β€” except for when parser is set to "meta". noted, so you're not out here confused when your terminal starts yelling at you 😭


🧚 CONFIGURATION 🧚

every knob you can turn, in order, no skips, we don't do skips here πŸ‘‘

  • base β€” the base URL of the SRU server. required, so like, don't forget it πŸ’€
  • query β€” the CQL query. also required. both of these are non-negotiable bestie 🫢
  • limit β€” how many records get fetched in one batch. defaults to 10. this gets translated into the SRU request parameter "maximumRecords".

Records come in multiple batches of this size, or smaller. so if you set a limit, that's the ceiling per batch, not the total. iykyk ✨

  • total β€” the total number of records this importer may return.

Not set by default. so it's a free-for-all unless you cap it 🌸

  • recordSchema β€” set to "dc" by default πŸŽ€
  • sortkeys β€” optional sorting. optional!! no pressure πŸ’œ
  • operation β€” set to "searchRetrieve" by default 🌟
  • version β€” set to 1.1 by default ⭐
  • userAgent β€” the HTTP user agent, set to "Mozilla/5.0" by default. yes, it's cosplaying as a browser, let it live πŸ¦‹
  • http_client β€” an instance of HTTP::Tiny or a compatible class to fetch URLs with. bring your own, if you want πŸ”₯
  • parser β€” this one controls how records get parsed before importing. the options are:
    • An instance of a Perl package that implements a parse subroutine. peep the default value Catmandu::Importer::SRU::Parser if you want an example πŸ‘€
    • The name of a Perl package that implements a parse subroutine. the name must be prepended with "+", or it gets prefixed with Catmandu::Importer::SRU::Parser::. for instance, "marcxml" will create a Catmandu::Importer::SRU::Parser::marcxml. that's the glow-up pipeline ✨
    • A function reference that gets passed the unparsed record. roll your own, main character energy πŸ’…

πŸ‘‘ METHODS πŸ‘‘

All methods of Catmandu::Importer and, by extension, Catmandu::Iterable are inherited. they're yours now, no cap 🫢

On top of those, here's the extra:

πŸ’œ url

Return the current SRU request URL. useful for debugging β€” literally the "what am i even requesting rn" button, obsessed πŸ”


πŸ”₯ SEE ALSO πŸ”₯


okay and for the cute sign-off: this whole thing is documented as perl v5.38.2, dated 2021-09-02, and it's the Catmandu::Importer::SRU(3pm) page β€” so if you need to cite it, that's the receipt πŸ§ΎπŸ’– now go fetch some records, bestie, you're gonna ate 🌈✨

πŸ“¦ where this page comes from