Perlan...LConfig(3pm)

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

✨ Perlanet::Trait::YAMLConfig ✨

okay bestie, gather round, because this one is genuinely such a vibe. this is Perlanet::Trait::YAMLConfig, straight out of the User Contributed Perl Documentation (you know, the 3pm section, the perl module corner of the library 🌸). it's a trait, it's a whole personality, and it's here to let your planet config live in its own little YAML home instead of being all up in your code. obsessed. πŸ’…


πŸŽ€ NAME πŸŽ€

Perlanet::Trait::YAMLConfig β€” configure Perlanet through a YAML configuration file πŸ¦‹


🌈 SYNOPSIS 🌈

like, here's the whole move, copy it exactly, no cap:

package MyPerlanet;
extends 'Perlanet';
with 'Perlanet::Traits::YAMLConfig';

my $perlanet = MyPerlanet->new_with_config(
  configfile => 'whatever.yml'
);

$perlanet->run;

that's it. that's the whole ritual. new_with_config with a configfile, then run, and you're a main character. πŸ‘‘


πŸ’– DESCRIPTION πŸ’–

so the whole point of this trait is that it lets you move the configuration of Perlanet out into an external YAML configuration file. your perl code stays cute and clean, and all the planet details go chill in their own .yml where they belong. it's giving separation of concerns, honestly. 🫢

πŸ“ Example Configuration File πŸ“

here's what a config file actually looks like, literally verbatim, don't @ me:

title: planet test
description: A Test Planet
url: http://planet.example.com/
author:
  name: Dave Cross
  email: dave@dave.org.uk
entries: 20
opml: opml.xml
page:
  file: index.html
  template: index.tt
feed:
  file: atom.xml
  format: Atom
cache_dir: /tmp/feeds
feeds:
  - url: http://blog.dave.org.uk/atom.xml
    title: Dave's Blog
    web: http://blog.dave.org.uk/
  - url: http://use.perl.org/~davorg/journal/rss
    title: Dave's use.perl Journal
    web: http://use.perl.org/~davorg/journal/
  - url: http://www.oreillynet.com/pub/feed/31?au=2607
    title: Dave on O'Reillynet
    web: http://www.oreillynet.com/pub/au/2607

look at those nested feeds entries. a whole little list of blogs. the web keys, the author block, the page and feed subsections β€” it's structured, it's tidy, it ate and left no crumbs. 🧚


πŸ’… METHODS πŸ’…

two methods, short and sweet, both iconic in their own way:

🌟 get_config_from_file

Extracts the configuration from a YAML file. it's the one doing the pulling-out-the-details part, iykyk. ✨

🌟 read_config

Actually reads the YAML. yeah, that's the whole description. it reads it. it does the reading. respect. 😭


🌸 AUTHOR 🌸

Oliver Charles, <oliver.g.charles@googlemail.com> β€” shoutout to the author, an absolute legend for real fr fr 🫢


Copyright (c) 2010 by Magnum Solutions Ltd.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.0 or, at your option, any later version of Perl 5 you may have available.

so yeah β€” free software, same terms as Perl itself, pick 5.10.0 or literally any later Perl 5 you've got lying around. do whatever, it's yours. πŸ’œ

and that's the page, bestie!! 🌈⭐ this one's from perl v5.36.0, dated 2023-02-21, and it's still serving looks. go forth and YAML-config your planet. mwah. πŸ’–πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from