Badger...rkspace(3pm)
π Badger::Workspace π
okay bestie, welcome to the Badger::Workspace page from the User Contributed Perl Documentation, manual section 3pm β and ngl, this one is lowkey the blueprint for every project you've ever poked at. let's get into it β¨
πΈ NAME πΈ
Badger::Workspace β an object representing a project workspace. that's the whole vibe. π«Ά
β¨ DESCRIPTION β¨
so this module implements an object for representing a workspace β think of it like the directory that holds the source, the configuration, the resources and all the other little files for a web site or literally any other project. it's a subclass of Badger::Workplace, which is the one that implements the base functionality. so like, Workplace is the parent and Workspace is the main character child π
the root directory for a workspace is expected to contain a configuration directory, called config by default, and that's where the configuration files for the workspace live. this whole thing is managed by delegation to a Badger::Config::Filesystem object. no cap, that's the delegation situation.
π CLASS METHODS π
π« new(\%config)
this is the constructor method, aka how you birth a brand new Badger::Workspace object into existence. iconic behaviour honestly.
use Badger::Workspace;
my $space = Badger::Workspace->new(
directory => '/path/to/workspace',
);
π CONFIGURATION OPTIONS π
root/dir/directoryβ this parameter is mandatory, bestie, you have to give it. it's the filesystem path to the project directory. you can spell it any of these three ways:root,dirordirectory, as per Badger::Workplace. pick your fighter, they all slay the same πconfig_moduleβ the name of the delegate module for managing the files in the configuration directory. it defaults toBadger::Config::Filesystem.config_dir/config_directoryβ optional! use this to specify the name of the configuration direction under the root project directory. the default configuration directory name isconfig. so if you do nothing, it'sconfig, periodt.config_fileβ optional too! use this to specify the name of the main configuration file (without file extension) that should reside in theconfig_dirdirectory under therootproject directory. the default configuration file name isworkspace.
π¦ PUBLIC METHODS π¦
π config($item)
when you call it with no arguments at all, it hands you back a Badger::Config::Filesystem object that manages the configuration directory for the project. like, the whole config manager. here:
my $cfg = $workspace->config;
but when you call it with a named item, it returns the configuration data associated with that item. this will typically be defined in a master configuration file, or in a file of the same name as the item, with an appropriate file extension added. so:
my $name = $workspace->config('name');
cute right?? π
π inherit_config($item)
this one attempts to fetch an inherited configuration from a parent namespace. but heads up β the workspace must have a parent defined and must have the inherit option set to any true value. both. no shortcuts. β
π§ parent_config($item)
attempts to fetch the configuration for a named item from a parent workspace. obviously this requires the workspace to be attached to a parent β you can't get parent config from a workspace with no parent, that's not giving anything. note that this method is not bound by the inherit flag and will delegate to any parent regardless. she does not care about your flags, she goes straight to the parent π
π dir($name)
π dirs(\%dirmap)
π resolve_dir($name)
π file($path)
π attach($parent)
attaches the workspace to a parent workspace. family bonding time π«Ά
π detach()
detaches the workspace from any parent workspace. okay bye then π
π parent($n)
returns the parent workspace if there is one. but if a numerical argument gets passed, it indicates a number of parents to skip. e.g. if $n is 1 then it bypasses the parent and returns the grandparent instead. so passing an argument of 0 is the same as passing no argument at all β zero skips, same energy, no difference. π
π ancestors($list)
returns a list of the parent, grandparent, great-grandparent and so on, all the way up as far as it can go. the whole family tree, no cap. a target list reference can be passed as an argument if you want to collect them somewhere specific.
π heritage()
this returns the same items in the ancestors() list but in reverse order β from most senior parent to most junior. so like, the ancestry served in chronological order. it's giving genealogy β¨
π PRIVATE METHODS π
π init(\%config)
this method redefines the default initialisation method. it calls the init_workplace() method inherited from Badger::Workplace and then calls the init_workspace() method to perform any workspace-specific initialisation. teamwork makes the dream work fr fr.
π init_workspace(\%config)
this method performs workspace-specific initialisation. in this module it simply calls init_config(). subclasses may redefine it to do something different β go off, customise your heart out π
π init_config(\%config)
this initialised the Badger::Config::Filesystem object which manages the config configuration directory. yes bestie, the original says "initialised", we're keeping it exactly as written π
π init_dirs(\%config)
π init_parent(\%config)
π write_config_file($uri, $data)
delegates to the method of the same name provided by the filesystem config object β see Badger::Config::Filesystem. it's a hand-off, she's not doing it herself.
π₯ TODO π₯
- Inheritance of configuration data between parent and child workspaces.
(the original just says it like that, no extra notes, so we leave it exactly as it is β a whole todo, just vibing there π)
πΈ AUTHOR πΈ
Andy Wardley <abw@wardley.org>. king behaviour honestly π«Ά
π COPYRIGHT π
Copyright (C) 2008-2014 Andy Wardley. All Rights Reserved.
okay that's the whole page bestie, every flag, every default, every method, all accounted for. nothing skipped, nothing invented. slay π β¨
this was Badger::Workspace from perl v5.36.0, dated 2023-08-28, in the User Contributed Perl Documentation β mwah, go build something cute with it ππ¦π
π¦ where this page comes from
- debian trixie: libbadger-perl 0.16-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libbadger-perl 0.16-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libbadger-perl 0.16-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms