UNIVERSAL-moniker-0.08/0000755000175000017500000000000010077502171014765 5ustar martymarty00000000000000UNIVERSAL-moniker-0.08/t/0000755000175000017500000000000010077502171015230 5ustar martymarty00000000000000UNIVERSAL-moniker-0.08/t/moniker.t0000644000175000017500000000051107726144760017073 0ustar martymarty00000000000000#!/usr/bin/perl use Test::More tests => 4; require_ok 'UNIVERSAL::moniker'; is Bpm::User->moniker, "user"; is +(bless {}, "Bpm::Customer")->moniker, "customer"; SKIP: { skip "You don't seem to have Lingua::EN::Inflect installed", 1 unless eval {require Lingua::EN::Inflect}; is Bpm::Octopus->plural_moniker, "octopuses"; } UNIVERSAL-moniker-0.08/README0000644000175000017500000000406710016712573015656 0ustar martymarty00000000000000In object oriented abstractions you often model real things as Perl classes. Unfortunately, the Perl classes have uglier names than the real things do. For example, I might model a customer using a Foo::Customer class. It would be useful if the Foo::Customer class knew what I would call its associated real thing. UNIVERSAL::moniker enables classes to make a good guess at what they would be called in the real world. Foo::User->moniker eq "user"; my $a = Big::Scary::Animal->new; $c->moniker eq "animal"; my $o = Cephalopod::Octopus->new; $o->plural_moniker eq "octopuses"; ============================================================================== NAME UNIVERSAL::moniker SYNOPSIS use UNIVERSAL::moniker; DESCRIPTION Class names in Perl often don't sound great when spoken, or look good when written in prose. For this reason, we tend to say things like "customer" or "basket" when we are referring to "My::Site::User::Customer" or "My::Site::Shop::Basket". We thought it would be nice if our classes knew what we would prefer to call them. This module will add a "moniker" (and "plural_moniker") method to "UNIVERSAL", and so to every class or module. moniker $ob->moniker; Returns the moniker for $ob. So, if $ob->isa("Big::Scary::Animal"), "moniker" will return "animal". plural_moniker $ob->plural_moniker; Returns the plural moniker for $ob. So, if $ob->isa("Cephalopod::Octopus"), "plural_moniker" will return "octopuses". (You need to install Lingua::EN::Inflect for this to work.) AUTHORS Marty Pauley , Tony Bowden , Elizabeth Mattijsen (Yes, 3 authors for such a small module!) COPYRIGHT Copyright (C) 2004 Kasei This program is free software; you can redistribute it under the same terms as Perl. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. UNIVERSAL-moniker-0.08/Changes0000644000175000017500000000131710077501737016271 0ustar martymarty000000000000000.08 Wed Jul 21 15:54:27 BST 2004 * qualified 'require' as 'CORE::require' to prevent warnings when using UNIVERSAL::require 0.07 Tue Feb 24 18:07:50 GMT 2004 * added this Changes file; I never would have guessed that I needed one for such a small module. * Included a performance improvement from Elizabeth Mattijsen. Thanks. 0.06 Fri Sep 05 sometime 2003 * make the tests pass if Lingua::EN::Inflect isn't installed. 0.05 Thu Sep 04 sometime 2003 * removed Lingua::EN::Inflect from the prerequisite list; if you want plurals, you must install it yourself. 0.04 ??? * removed the "use warnings" so it will work with older Perl versions; Thanks to Schwern and Miyagawa. UNIVERSAL-moniker-0.08/moniker.pm0000644000175000017500000000322610077502054016772 0ustar martymarty00000000000000package UNIVERSAL::moniker; $UNIVERSAL::moniker::VERSION = '0.08'; =head1 NAME UNIVERSAL::moniker =head1 SYNOPSIS use UNIVERSAL::moniker; =head1 DESCRIPTION Class names in Perl often don't sound great when spoken, or look good when written in prose. For this reason, we tend to say things like "customer" or "basket" when we are referring to C or C. We thought it would be nice if our classes knew what we would prefer to call them. This module will add a C (and C) method to C, and so to every class or module. =head2 moniker $ob->moniker; Returns the moniker for $ob. So, if $ob->isa("Big::Scary::Animal"), C will return "animal". =head2 plural_moniker $ob->plural_moniker; Returns the plural moniker for $ob. So, if $ob->isa("Cephalopod::Octopus"), C will return "octopuses". (You need to install Lingua::EN::Inflect for this to work.) =cut package UNIVERSAL; sub moniker { (ref( $_[0] ) || $_[0]) =~ /([^:]+)$/; return lc $1; } sub plural_moniker { CORE::require Lingua::EN::Inflect; return Lingua::EN::Inflect::PL($_[0]->moniker); } =head1 AUTHORS Marty Pauley , Tony Bowden , Elizabeth Mattijsen (Yes, 3 authors for such a small module!) =head1 COPYRIGHT Copyright (C) 2004 Kasei This program is free software; you can redistribute it under the same terms as Perl. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. =cut 1; UNIVERSAL-moniker-0.08/Makefile.PL0000644000175000017500000000040107725673576016762 0ustar martymarty00000000000000#!/usr/bin/perl -w use ExtUtils::MakeMaker; warn <<"EOT"; Hello! We no longer depend on Lingua::EN::Inflect. If you care about plurals, you should install it. EOT WriteMakefile( 'NAME' => 'UNIVERSAL::moniker', 'VERSION_FROM' => 'moniker.pm', ); UNIVERSAL-moniker-0.08/META.yml0000644000175000017500000000046010077502170016235 0ustar martymarty00000000000000# http://module-build.sourceforge.net/META-spec.html #XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX# name: UNIVERSAL-moniker version: 0.08 version_from: moniker.pm installdirs: site requires: distribution_type: module generated_by: ExtUtils::MakeMaker version 6.17 UNIVERSAL-moniker-0.08/MANIFEST0000644000175000017500000000021210016712641016107 0ustar martymarty00000000000000Changes Makefile.PL MANIFEST moniker.pm README t/moniker.t META.yml Module meta-data (added by MakeMaker)