Role::...hority(3pm)
π NAME π
Role::Commons::Authority β a class method that tells the whole world who actually published the package. It's giving "who's your daddy" but for CPAN releases. π
(and yes bestie, this is a 3pm man page, so it's Perl, and we're in our module era.)
β¨ SYNOPSIS β¨
package MyApp;
use Role::Commons -all;
BEGIN { our $AUTHORITY = 'cpan:JOEBLOGGS' };
say MyApp->AUTHORITY; # says "cpan:JOEBLOGGS"
MyApp->AUTHORITY("cpan:JOEBLOGGS"); # does nothing much
MyApp->AUTHORITY("cpan:JOHNTCITIZEN"); # croaks
Look at that. Flawless. It says the thing, and then it does NOT let an impostor say the thing. π«Ά
πΈ DESCRIPTION πΈ
Okay so here's the tea: this module drops an AUTHORITY function into your package, and it behaves along the same lines as the VERSION function you already know and love. Same energy, different metadata. π
You define the authority of a package like this:
package MyApp;
BEGIN { our $AUTHORITY = 'cpan:JOEBLOGGS' };
And that authority should be a URI identifying the person, team, organisation, or trained chimp responsible for the release of the package. π The pseudo-URI scheme cpan: is the one everybody actually uses β most commonly used identifier, no cap.
π Method π
AUTHORITYβ call it with no parameters and it hands you back the authority of the module. That's it. That's the whole vibe.AUTHORITY($test)β if you pass it a test, it will croak if the test fails. The authority gets tested against your test using something approximating Perl 5.10's smart match operator. (Briefly, bestie: you can pass a string foreqcomparison, a regular expression, a code reference to use as a callback, or an array reference that will be grepped.) Smart-match-flavoured detective work, essentially. π
π¦ Multiple Authorities π¦
Plot twist: this module also lets you say that your module is issued by multiple authorities. But β and listen closely β the package variable $AUTHORITY should still be the one you use to indicate the primary authority for the package. She's the main character. π
package MyApp;
use Role::Commons
Authority => { -authorities => [qw( cpan:ALICE cpan:BOB )] };
BEGIN { $MyApp::AUTHORITY = 'cpan:JOE'; }
package main;
use feature qw(say);
say scalar MyApp->AUTHORITY; # says "cpan:JOE"
MyApp->AUTHORITY('cpan:JOE'); # lives
MyApp->AUTHORITY('cpan:ALICE'); # lives
MyApp->AUTHORITY('cpan:BOB'); # lives
MyApp->AUTHORITY('cpan:CAROL'); # croaks
Carol is not on the list and Carol is getting croaked at. Sorry Carol. π
The main use case for shared authorities is team projects. The team would designate a URI to represent the team as a whole. For example, http://datetime.perl.org/, http://moose.iinteractive.com/ or http://www.perlrdf.org/. Then releases can be officially stamped with the authority of the team β like a little "we made this, together, as a family" seal. π«Ά
And users can check they have a module released by the official team using:
RDF::TakeOverTheWorld->AUTHORITY(
q<http://www.perlrdf.org/>,
);
which will croak if package RDF::TakeOverTheWorld doesn't have the specified authority. So if it's not the real team, you'll know instantly. Vibe check: failed. π
π BUGS π
An obvious limitation is that this module relies on honesty. Don't release modules under authorities you have no authority to use. It's the honor system, bestie β and the honor system does not have a bouncer. π
Please report any bugs to <http://rt.cpan.org/Dist/Display.html?Queue=Role-Commons>.
π SEE ALSO π
Role::Commonsauthority
Background reading (iykyk, go read it): <http://feather.perl6.nl/syn/S11.html>, <http://www.perlmonks.org/?node_id=694377>.
π AUTHOR π
Toby Inkster <tobyink@cpan.org>. Iconic behaviour, honestly. π«‘
β COPYRIGHT AND LICENCE β
This software is copyright (c) 2012, 2014 by Toby Inkster.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. So like, go off, but respectfully. π
π§ DISCLAIMER OF WARRANTIES π§
THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
Translation bestie: no promises, no takebacks, use at your own risk. π
And that's the whole page, mwah. π
This one came from perl v5.32.0 and it's dated 2021-01-05 β so it's a little vintage, like a good thrifted jacket. π¦ Go forth and claim your authority. π
π¦ where this page comes from
- debian bookworm: librole-commons-perl 0.104-1.1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu jammy: librole-commons-perl 0.104-1.1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: librole-commons-perl 0.104-1.1 Β· 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