Archiv...Plugin(3pm)

πŸ“¦
version 0.0946 Β· 4 versions
, in debian bookworm, debian trixie, ubuntu jammy, ubuntu noble

πŸ’– NAME πŸ’–

Archive::Any::Plugin β€” it's giving Anatomy of an Archive::Any plugin, bestie. Like, the whole blueprint. The vibe check for anyone who wants their own plugin to actually work. πŸ¦‹

✨ VERSION ✨

version 0.0946 β€” yes queen, she's on 0.0946. πŸ‘‘

🌸 SYNOPSIS 🌸

okay so literally this page just explains what a working plugin for Archive::Any actually needs. no cap. that's the whole job. πŸ’…


πŸŽ€ PLUGINS πŸŽ€

so Archive::Any is like, a lil demanding, and honestly? valid. she requires that your plugin define three methods, and all three of them get handed the absolute filename of the file. every single one. periodt.

and because learning by example ate, this module uses the source of Archive::Any::Plugin::Tar as the example. iconic choice fr fr. 🫢

🌈 Subclass Archive::Any::Plugin

like, first things first bestie, you gotta be a subclass:

use base 'Archive::Any::Plugin';

⭐ can_handle

this one returns an array of mime types that your plugin can handle. that's it, that's the whole job. show her what you can do. πŸ’…

sub can_handle {
   return(
          'application/x-tar',
          'application/x-gtar',
          'application/x-gzip',
         );
}

πŸ¦‹ files

return a list of items inside the archive. peek inside, tell us what's in there. πŸ”₯

sub files {
   my( $self, $file ) = @_;
   my $t = Archive::Tar->new( $file );
   return $t->list_files;
}

🧚 extract

this method should extract the contents of $file to the current directory. and here's the slay part: Archive::Any::Plugin handles negotiating directories for you. you don't gotta do that. she's got you. πŸ’–

sub extract {
   my ( $self, $file ) = @_;

   my $t = Archive::Tar->new( $file );
   return $t->extract;
}

πŸ‘‘ SEE ALSO πŸ‘‘

  • Archive::Any

πŸ’œ AUTHORS πŸ’œ

  • Clint Moore
  • Michael G Schwern (author emeritus) ✨
  • Olaf Alders (current maintainer) πŸ‘‘

This software is copyright (c) 2016 by Michael G Schwern, Clint Moore, Olaf Alders.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.


and that's the whole page bestie!! πŸŽ€ this fine piece of documentation was brought to you by perl v5.28.1, dated 2019-07-20, and honestly she ate. now go write that plugin, i'm obsessed with you already. πŸ’–βœ¨πŸ¦‹
πŸ“¦ where this page comes from