Catman...::Atom(3pm)

πŸ“¦
version 0.05 Β· 3 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu questing

✨ NAME ✨

Catmandu::Exporter::Atom β€” bestie, it's an Atom exporter. That's the whole thing. That's the vibe. πŸ’…

This is the Catman...::Atom(3pm) page from the User Contributed Perl Documentation, and we're gonna walk through it together, no skimming, no skipping. 🫢


πŸŽ€ SYNOPSIS πŸŽ€

Okay so first things first, you gotta use it. Obviously. ✨

use Catmandu::Exporter::Atom;

Then you set up your blog args β€” id, title, subtitle, icon, generator, rights, your links, your authors, your contributors, your namespaces, all of it. Look at this gorgeous little hash: πŸ’–

my $blog_args = {
 id => "urn:uuid:60a76c80-d399-11d9-b91C-0003939e0af6" ,
 title => "My Blog" ,
 subtitle => "testing 1.2.3" ,
 icon => "http://icons.org/test.jpg" ,
 generator => "Catmandu::Exporter::Atom" ,
 rights => "Beer license",
 link => [
            {
     'type' => 'text/html' ,
     'rel'  => 'alternate' ,
     'href' => 'http://www.example.com' ,
             }
 ],
 author => [
           {
     'name' => 'Daffy' ,
     'email' => 'duck@toons.be' ,
           }
 ] ,
 contributor => [
            {
      'name'  => 'Bugs' ,
      'email' => 'bunny@toons.be'
            }
 ],
 ns => {
     'dc' => 'http://purl.org/dc/elements/1.1/',
 },
 'dc:source' => 'test',
};

Then you make the exporter, and then you feed it things. Three ways to feed it, actually: πŸ‘‘

my $exporter = Catmandu::Exporter::Atom->new(%$blog_args);

$exporter->add_many($arrayref);
$exporter->add_many($iterator);
$exporter->add_many(sub { });

$exporter->add($hashref);

And here's a fully loaded add so you can see what a real object looks like walking in the door β€” title, subtitle, content, summary, id, author, contributor, links, categories, rights, and a dc:subject for spice. iconic πŸ’«

$exporter->add({
 'title'    => 'My Little Pony' ,
 'subtitle' => 'Data testing for you and me' ,
 'content'  => "sdsadas" ,
 'summary'  => 'Brol 123' ,
 'id'       => '1291821827128172817' ,
 'author' => {
    'name' => 'John Doe' ,
    'email' => 'john@farwaway.org' ,
 } ,
 'contributor' => {
    'name' => 'Rabbit, R' ,
    'email' => 'r.rabbit@farwaway.org' ,
    'homepage' => 'http://faraway.org/~rabbit' ,
 } ,
 'link' => [
           {
    'type' => 'text/html' ,
    'rel'  => 'alternate' ,
    'href' => 'http://www.example.com' ,
    'title' => 'Test test' ,
    'length' => '1231' ,
    'hreflang' => 'eng' ,
            } ,
           {
    'type' => 'text/html' ,
    'rel'  => 'alternate' ,
    'href' => 'http://www.example2.com' ,
            }
 ] ,
 'category' => [
            {
    'scheme' => 'http://localhost:8080/roller/adminblog' ,
    'term' => 'Music',
            }
 ] ,
 'rights' => 'Yadadada',
 'dc:subject' => 'Toyz',
});

And then, the flex β€” you count how many you exported and you print it: πŸ“Š

printf "exported %d objects\n" , $exporter->count;

🌸 Add one object 🌸

Just one. A little single object. A snack. πŸ“

use Catmandu::Exporter::Atom;
my $exporter = Catmandu::Exporter::Atom->new();

print $exporter->add($hashref);

🌸 Add many objects to exporter 🌸

Now we're doing volume, bestie. Main character energy. ✨

use Catmandu::Exporter::Atom;
my $exporter = Catmandu::Exporter::Atom->new();

print $exporter->add_many($arrayref);

🌸 Add many objects from an iterator 🌸

Same energy, but the objects come from an iterator this time. πŸ‘‘

use Catmandu::Exporter::Atom;
my $exporter = Catmandu::Exporter::Atom->new();

my $iterator = Catmandu::Importer::

print
ngl bestie, that example literally just ends there in the page. I'm not gonna invent the rest for you β€” what you see is what's on the page. 😭

🌸 Fix your data while exporting the data 🌸

You can run a fix file while the export is happening. Point it at fix.txt and let it cook: πŸ”₯

use Catmandu::Exporter::Atom;
my $exporter = Catmandu::Exporter::Atom->new(fix => 'fix.txt');

# where fix.txt looks for example:
# add_field()
# delete
# mv

print $exporter->add($data);

πŸ’œ SEE ALSO πŸ’œ

  • Catmandu::Exporter β€” go look at that one too, iykyk πŸ’…

Okay that's the whole page, you ate it, I'm so proud. πŸ₯Ή This one's from perl v5.36.0, dated 2022-12-10, and it lives on the Catman...::Atom(3pm) page. Bye bestie, go export something beautiful! πŸ’–βœ¨πŸ¦‹

πŸ“¦ where this page comes from