Tree::...actory(3pm)

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

πŸ’– Tree::Simple::VisitorFactory πŸ’–

okay bestie, so this is a page from the User Contributed Perl Documentation β€” it's Tree::Simple::VisitorFactory(3pm), and it's literally the little vending machine that hands you Visitor objects so you don't have to type out their giant class names. slay. let's get into it 🫢


✨ NAME ✨

Tree::Simple::VisitorFactory β€” a factory object for dispensing Visitor objects πŸŽ€


🌸 SYNOPSIS 🌸

use Tree::Simple::VisitorFactory;

my $tf = Tree::Simple::VisitorFactory->new();

my $visitor = $tf->get("PathToRoot");

# or call it as a class method
my $visitor = Tree::Simple::VisitorFactory->getVisitor("PathToRoot");

πŸ’… DESCRIPTION πŸ’…

So, this object is literally just a factory for dispensing Tree::Simple::Visitor::* objects. that's the whole vibe. and ngl, you are not required to use this package to use all the Visitors β€” it's just a kinda convenient way to avoid typing out their long class names. it's giving "I'm doing this for your own good" energy πŸ’–

The author considered making this a Singleton, but did not, because some people might not want that. and fr fr, the author knows they're very picky about using Singletons, especially in multiprocess environments like mod_perl. so instead they implemented the smallest instance they knew how to, and made sure all the other methods could be called as class methods too. iconic, honestly. πŸ‘‘


πŸ¦‹ METHODS πŸ¦‹

  • new β€” Returns a minimal instance of this object, basically just a reference back to the package (literally, see the source if you care πŸ™ˆ).
  • get ($visitor_type) β€” Attempts to load the $visitor_type and returns an instance of it if successful. If no $visitor_type is specified, an exception is thrown; if $visitor_type fails to load, an exception is thrown. so like, you will be told, no silent suffering here πŸ’€
  • getVisitor ($visitor_type) β€” This is an alias of "get". same thing, different name, both ate.

🌈 AVAILABLE VISITORS 🌈

This distribution provides a number of Visitor objects which can be loaded just by giving their name. Below is a description of the available Visitors and a sort description of what they do. The author attempted to classify the Visitors into groups which are related to their use. πŸŽ€

This factory will load any module contained inside the Tree::Simple::Visitor::* namespace. Given a name, it will attempt to "require" the module Tree::Simple::Visitor::<Name>.pm. This means other people can create Visitors which can be accessed with this factory without needing to include them in this distribution. bestie-friendly design, we love to see it 🫢

  • PathToRoot β€” Given a Tree::Simple object, this Visitor will find the path back to the tree's root node. like a lil "take me home" button 🏠
  • FindByPath β€” Given a path and Tree::Simple hierarchy, this Visitor will attempt to find the node specified by the path.
  • FindByUID β€” Given a UID and Tree::Simple hierarchy, this Visitor will attempt to find the node with the same UID.
  • FindByNodeValue β€” Given a node value and Tree::Simple hierarchy, this Visitor will attempt to find the node with the same node value.

🚢 Traversal Visitors 🚢

  • BreadthFirstTraversal β€” This implements a breadth-first traversal of a Tree::Simple hierarchy.
  • PostOrderTraversal β€” Post-order traversal is a variation of the depth-first traversal in which the sub-tree's are processed before the parent.
  • PreOrderTraversal β€” Pre-order traversal is a depth-first traversal method in which the sub-tree's are processed after the parent.

πŸ—‚οΈ FileSystem Visitors πŸ—‚οΈ

  • LoadDirectoryTree β€” This visitor can be used to load a directory tree into a Tree::Simple hierarchy.
  • CreateDirectoryTree β€” This visitor can be used to create a set of directories and files from a Tree::Simple object hierarchy.

πŸ”„ Conversion Visitors πŸ”„

  • FromNestedArray β€” Given a tree constructed from nested arrays, this Visitor will create the equivalent Tree::Simple hierarchy.
  • ToNestedArray β€” Given a Tree::Simple hierarchy, this Visitor will create the equivalent tree constructed from nested arrays.
  • FromNestedHash β€” Given a tree constructed from nested hashs, this Visitor will create the equivalent Tree::Simple hierarchy.
  • ToNestedHash β€” Given a Tree::Simple hierarchy, this Visitor will create the equivalent tree constructed from nested hashes.

πŸͺž Reflective Visitors πŸͺž

  • LoadClassHierarchy β€” Given a class name or instance, this Visitor will create a Tree::Simple hierarchy which models the classes inheritance hierarchy. it's giving mirror, mirror πŸͺžβœ¨

🎲 Misc. Visitors 🎲

  • GetAllDescendents β€” Given a Tree::Simple instance this Visitor will return all the descendents recursively on down the hierarchy.
  • Sort β€” This implements a multi-level sort of a Tree::Simple hierarchy.
  • VariableDepthClone β€” A Visitor for cloning parts of Tree::Simple hierarchy.

πŸ’€ BUGS πŸ’€

None that the author is aware of. Of course, if you find a bug, let them know, and they will be sure to fix it. so like, speak up bestie, they're listening 🫢


πŸ“Š CODE COVERAGE πŸ“Š

The author uses Devel::Cover to test the code coverage of the tests, and below is the Devel::Cover report on this module test suite. look at those numbers, not a single 100.0-less total in sight for stmt/pod πŸ”₯

-------------------------------------------- ------ ------ ------ ------ ------ ------ ------
File                                           stmt branch   cond    sub    pod   time  total
-------------------------------------------- ------ ------ ------ ------ ------ ------ ------
Tree/Simple/VisitorFactory.pm                 100.0  100.0    n/a  100.0  100.0    0.4  100.0
Tree/Simple/Visitor/BreadthFirstTraversal.pm  100.0  100.0   66.7  100.0  100.0    2.5   96.3
Tree/Simple/Visitor/PostOrderTraversal.pm     100.0  100.0   77.8  100.0  100.0    1.7   96.3
Tree/Simple/Visitor/PreOrderTraversal.pm      100.0    n/a   33.3  100.0  100.0    0.7   90.5
Tree/Simple/Visitor/CreateDirectoryTree.pm    100.0   85.7   86.7  100.0  100.0    3.4   95.8
Tree/Simple/Visitor/LoadClassHierarchy.pm     100.0   73.1   33.3  100.0  100.0    4.9   89.2
Tree/Simple/Visitor/LoadDirectoryTree.pm      100.0   89.3   85.2  100.0  100.0   26.1   94.7
Tree/Simple/Visitor/FindByNodeValue.pm        100.0  100.0   86.7  100.0  100.0    3.1   98.3
Tree/Simple/Visitor/FindByPath.pm             100.0  100.0   66.7  100.0  100.0    1.2   97.9
Tree/Simple/Visitor/FindByUID.pm              100.0  100.0   86.7  100.0  100.0    2.9   98.3
Tree/Simple/Visitor/GetAllDescendents.pm      100.0  100.0   77.8  100.0  100.0    2.3   97.1
Tree/Simple/Visitor/PathToRoot.pm             100.0   87.5   75.0  100.0  100.0    0.8   95.1
Tree/Simple/Visitor/Sort.pm                   100.0  100.0   77.8  100.0  100.0    8.8   98.1
Tree/Simple/Visitor/ToNestedArray.pm          100.0  100.0   66.7  100.0  100.0    1.5   96.5
Tree/Simple/Visitor/ToNestedHash.pm           100.0  100.0   66.7  100.0  100.0    1.4   96.5
Tree/Simple/Visitor/FromNestedArray.pm        100.0   94.4   81.8  100.0  100.0    8.1   96.6
Tree/Simple/Visitor/FromNestedHash.pm         100.0   91.7   77.8  100.0  100.0    4.8   95.9
Tree/Simple/Visitor/VariableDepthClone.pm     100.0  100.0   66.7  100.0  100.0   25.5   97.3
-------------------------------------------- ------ ------ ------ ------ ------ ------ ------
Total                                         100.0   93.8   76.3  100.0  100.0  100.0   96.1
-------------------------------------------- ------ ------ ------ ------ ------ ------ ------

πŸ‘€ SEE ALSO πŸ‘€

These Visitor classes are meant to work with Tree::Simple hierarchies, so you should refer to that module for more information. go read it, it's the main character of this whole situation πŸ’œ

πŸ™ Repository

<https://github.com/ronsavage/Tree-Simple-VisitorFactory>


πŸ†˜ SUPPORT πŸ†˜

Bugs should be reported via the CPAN bug tracker at

<https://github.com/ronsavage/Tree-Simple-VisitorFactory/issues>


πŸ‘‘ AUTHOR πŸ‘‘

stevan little, <stevan@iinteractive.com>

Ron Savage <ron@savage.net.au> has taken over maintenance as of V 0.11.


Copyright 2004, 2005 by Infinity Interactive, Inc.

<http://www.iinteractive.com>

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


and that's the whole page bestie πŸ’– this was documented for perl v5.36.0 and the date on it is 2022-11-19 β€” go forth and dispense some Visitors, you absolute icon πŸŽ€βœ¨πŸ’…πŸ¦‹πŸŒΈ

πŸ“¦ where this page comes from