Dist::...Struct(3pm)

πŸ“¦
version 0.927 Β· 4 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– Dist::...Struct πŸ’–

okay so bestie, you know how this is a page from the User Contributed Perl Documentation section of the manual β€” the Dist::...Struct(3pm) one β€” and it's literally all about letting Dist::Metadata vibe with a plain old data structure instead of an actual dist sitting on your disk? yeah. that's the whole thing. let's get into it 🫢


✨ NAME ✨

Dist::Metadata::Struct β€” it's giving "enable Dist::Metadata for a data structure". that's it, that's the name. no cap.


🌸 VERSION 🌸

version 0.927 β€” yes, the good version, the one you're looking at right now πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

my $dm = Dist::Metadata->new(struct => {
  files => {
    'lib/Mod.pm' => 'package Mod; sub something { ... }',
    'README'     => 'this is a fake dist, useful for testing',
  }
});

look at her go. a whole fake dist, conjured out of thin air, no filesystem required ✨


πŸ¦‹ DESCRIPTION πŸ¦‹

okay so this is a subclass of Dist::Metadata::Dist, and its entire job is enabling you to mock up a dist out of perl data structures. like, manifesting a dist but for real, in memory, no cap.

it's mostly used for testing β€” that's the main character use case β€” but lowkey it might also be useful if you already have an in-memory representation of a dist and you'd like to examine it. cute, right?

but listen. it's probably not very useful on it's own though, and you should really be using it from "new" in Dist::Metadata. don't come for me, that's just what the page says. use it through the parent, bestie.

🧚 METHODS 🧚

new

$dist = Dist::Metadata::Struct->new(files => {
  'lib/Mod.pm' => 'package Mod; sub something { ... }',
});

this accepts a files parameter, and that parameter should be a hash of { name => content, }. and the content? it can be a string, a reference to a string, or an IO object. three whole options, we love flexibility 🫢

default_file_spec

"Unix" is the default for consistency/simplicity β€” keeping it simple, keeping it cute β€” but "file_spec" can be overridden in the constructor if you're feeling spicy. go off πŸ‘‘

file_content

returns the string content for the specified name. that's the whole thing. it just hands you the content. iconic behaviour honestly.

find_files

returns the keys of the files hash. all of them. every single one. slay.


πŸ’œ AUTHOR πŸ’œ

Randy Stauner <rwstauner@cpan.org> β€” the author, the legend, the blueprint πŸ™Œ


This software is copyright (c) 2011 by Randy Stauner.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. fr fr, free as in do-whatever-the-perl-terms-say πŸ’–


and that's the whole page, bestie!! 🌈⭐ this was perl v5.34.0, dated 2022-06-13, and it lives at Dist::...Struct(3pm) in the User Contributed Perl Documentation. mwah πŸ’…πŸŽ€ bye!! πŸ¦‹

πŸ“¦ where this page comes from