From: phaylon Date: Fri, 3 Aug 2007 13:38:07 +0000 (+0000) Subject: Moved to MooseX-Types X-Git-Tag: 0.06~17 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=52d358e2cf004a8b632b655832f7e9101db3c4dc;hp=57dad71eda1d16e561b364e216ff6f868c366236;p=gitmo%2FMooseX-Types.git Moved to MooseX-Types --- diff --git a/Makefile.PL b/Makefile.PL index 4dfa6ce..9c0f4d5 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -4,10 +4,10 @@ use strict; use inc::Module::Install; -name q{MooseX-TypeLibrary}; +name q{MooseX-Types}; license q{perl}; author q{Robert 'phaylon' Sedlacek }; -all_from q{lib/MooseX/TypeLibrary.pm}; +all_from q{lib/MooseX/Types.pm}; build_requires q{Test::More}, '0.62'; build_requires q{FindBin}, 0; diff --git a/lib/MooseX/TypeLibrary.pm b/lib/MooseX/Types.pm similarity index 87% rename from lib/MooseX/TypeLibrary.pm rename to lib/MooseX/Types.pm index 4b9da56..853b035 100644 --- a/lib/MooseX/TypeLibrary.pm +++ b/lib/MooseX/Types.pm @@ -1,8 +1,8 @@ -package MooseX::TypeLibrary; +package MooseX::Types; =head1 NAME -MooseX::TypeLibrary - Organise your Moose types in libraries +MooseX::Types - Organise your Moose types in libraries =cut @@ -11,9 +11,9 @@ MooseX::TypeLibrary - Organise your Moose types in libraries use Sub::Uplevel; use Moose::Util::TypeConstraints; -use MooseX::TypeLibrary::Base (); -use MooseX::TypeLibrary::Util qw( filter_tags ); -use MooseX::TypeLibrary::UndefinedType; +use MooseX::Types::Base (); +use MooseX::Types::Util qw( filter_tags ); +use MooseX::Types::UndefinedType; use Sub::Install qw( install_sub ); use Moose; use namespace::clean; @@ -31,11 +31,11 @@ my $UndefMsg = q{Action for type '%s' not yet defined in library '%s'}; use strict; # predeclare our own types - use MooseX::TypeLibrary + use MooseX::Types -declare => [qw( PositiveInt NegativeInt )]; # import builtin types - use MooseX::TypeLibrary::Moose 'Int'; + use MooseX::Types::Moose 'Int'; # type definition subtype PositiveInt, @@ -120,13 +120,13 @@ cannot hasn't defined any coercions will lead to a compile-time error. =head1 LIBRARY DEFINITION -A MooseX::TypeLibrary is just a normal Perl module. Unlike Moose +A MooseX::Types is just a normal Perl module. Unlike Moose itself, it does not install C and C in your class by default, so this is up to you. The only thing a library is required to do is - use MooseX::TypeLibrary -declare => \@types; + use MooseX::Types -declare => \@types; with C<@types> being a list of types you wish to define in this library. This line will install a proper base class in your package as well as the @@ -138,9 +138,9 @@ types. If you want to use Moose' built-in types (e.g. for subtyping) you will want to - use MooseX::TypeLibrary::Moose @types; + use MooseX::Types::Moose @types; -to import the helpers from the shipped L +to import the helpers from the shipped L library which can export all types that come with Moose. You will have to define coercions for your types or your library won't @@ -155,8 +155,8 @@ you want all of them, use the C<:all> tag. For example: use MyLibrary ':all'; use MyOtherLibrary qw( TypeA TypeB ); -MooseX::TypeLibrary comes with a library of Moose' built-in types called -L. +MooseX::Types comes with a library of Moose' built-in types called +L. =head1 WRAPPING A LIBRARY @@ -166,7 +166,7 @@ of a set of library exports. Here is an example: package MyWrapper; use strict; use Class::C3; - use base 'MooseX::TypeLibrary::Wrapper'; + use base 'MooseX::Types::Wrapper'; sub coercion_export_generator { my $class = shift; @@ -194,7 +194,7 @@ with this: 1; The C library name is a special shortcut for -L. +L. =head2 Generator methods you can overload @@ -238,7 +238,7 @@ type does not yet exist. =head2 import -Installs the L class into the caller and +Installs the L class into the caller and exports types according to the specification described in L. This will continue to L' C method to export helper @@ -252,7 +252,7 @@ sub import { # inject base class into new library { no strict 'refs'; - unshift @{ $callee . '::ISA' }, 'MooseX::TypeLibrary::Base'; + unshift @{ $callee . '::ISA' }, 'MooseX::Types::Base'; } # generate predeclared type helpers @@ -277,7 +277,7 @@ sub import { Generate a type export, e.g. C. This will return either a L object, or alternatively a -L object if the type was not +L object if the type was not yet defined. =cut @@ -286,7 +286,7 @@ sub type_export_generator { my ($class, $type, $full) = @_; return sub { return find_type_constraint($full) - || MooseX::TypeLibrary::UndefinedType->new($full); + || MooseX::Types::UndefinedType->new($full); }; } @@ -334,12 +334,12 @@ sub check_export_generator { A library makes the types quasi-unique by prefixing their names with (by default) the library package name. If you're only using the type handler -functions provided by MooseX::TypeLibrary, you shouldn't ever have to use +functions provided by MooseX::Types, you shouldn't ever have to use a type's actual full name. =head1 SEE ALSO -L, L, L +L, L, L =head1 AUTHOR AND COPYRIGHT diff --git a/lib/MooseX/TypeLibrary/Base.pm b/lib/MooseX/Types/Base.pm similarity index 91% rename from lib/MooseX/TypeLibrary/Base.pm rename to lib/MooseX/Types/Base.pm index d6dda02..0bd4ee0 100644 --- a/lib/MooseX/TypeLibrary/Base.pm +++ b/lib/MooseX/Types/Base.pm @@ -1,8 +1,8 @@ -package MooseX::TypeLibrary::Base; +package MooseX::Types::Base; =head1 NAME -MooseX::TypeLibrary::Base - Type library base class +MooseX::Types::Base - Type library base class =cut @@ -11,7 +11,7 @@ MooseX::TypeLibrary::Base - Type library base class use Sub::Install qw( install_sub ); use Carp qw( croak ); -use MooseX::TypeLibrary::Util qw( filter_tags ); +use MooseX::Types::Util qw( filter_tags ); use Moose::Util::TypeConstraints; use Moose; use namespace::clean; @@ -20,7 +20,7 @@ use namespace::clean; You normally won't need to interact with this class by yourself. It is merely a collection of functionality that type libraries need to -interact with moose and the rest of the L module. +interact with moose and the rest of the L module. =cut @@ -33,7 +33,7 @@ my $UndefMsg = q{Unable to find type '%s' in library '%s'}; =head2 import Provides the import mechanism for your library. See -L for syntax details on this. +L for syntax details on this. =cut @@ -78,7 +78,7 @@ sub export_type_into { my $tobj = find_type_constraint($full); # a possible wrapper around library functionality - my $wrap = $args{ -wrapper } || 'MooseX::TypeLibrary'; + my $wrap = $args{ -wrapper } || 'MooseX::Types'; # install Type name constant install_sub({ @@ -185,7 +185,7 @@ sub type_storage { =head1 SEE ALSO -L +L =head1 AUTHOR AND COPYRIGHT diff --git a/lib/MooseX/TypeLibrary/Moose.pm b/lib/MooseX/Types/Moose.pm similarity index 78% rename from lib/MooseX/TypeLibrary/Moose.pm rename to lib/MooseX/Types/Moose.pm index 3b5755a..f2bca5b 100644 --- a/lib/MooseX/TypeLibrary/Moose.pm +++ b/lib/MooseX/Types/Moose.pm @@ -1,15 +1,15 @@ -package MooseX::TypeLibrary::Moose; +package MooseX::Types::Moose; =head1 NAME -MooseX::TypeLibrary::Moose - Types shipped with L +MooseX::Types::Moose - Types shipped with L =cut use warnings; use strict; -use MooseX::TypeLibrary; +use MooseX::Types; use Moose::Util::TypeConstraints (); use namespace::clean; @@ -17,7 +17,7 @@ use namespace::clean; package Foo; use Moose; - use MooseX::TypeLibrary::Moose qw( Int Str ); + use MooseX::Types::Moose qw( Int Str ); use Carp qw( croak ); has 'name', @@ -39,8 +39,8 @@ use namespace::clean; =head1 DESCRIPTION -This package contains a virtual library for L that -is able to export all types known to L. See L +This package contains a virtual library for L that +is able to export all types known to L. See L for general usage information. =cut @@ -54,7 +54,7 @@ my %BuiltIn_Storage =head2 type_storage -Overrides L' C to provide a hash +Overrides L' C to provide a hash reference containing all built-in L types. =cut @@ -64,7 +64,7 @@ sub type_storage { \%BuiltIn_Storage } =head1 SEE ALSO -L, +L, L, L diff --git a/lib/MooseX/TypeLibrary/UndefinedType.pm b/lib/MooseX/Types/UndefinedType.pm similarity index 87% rename from lib/MooseX/TypeLibrary/UndefinedType.pm rename to lib/MooseX/Types/UndefinedType.pm index 3bb4ca6..b35d340 100644 --- a/lib/MooseX/TypeLibrary/UndefinedType.pm +++ b/lib/MooseX/Types/UndefinedType.pm @@ -1,8 +1,8 @@ -package MooseX::TypeLibrary::UndefinedType; +package MooseX::Types::UndefinedType; =head1 NAME -MooseX::TypeLibrary::UndefinedType - Represents a not yet defined type +MooseX::Types::UndefinedType - Represents a not yet defined type =cut @@ -40,7 +40,7 @@ sub name { $_[0]->{name} } =head1 SEE ALSO -L, +L, L, L diff --git a/lib/MooseX/TypeLibrary/Util.pm b/lib/MooseX/Types/Util.pm similarity index 84% rename from lib/MooseX/TypeLibrary/Util.pm rename to lib/MooseX/Types/Util.pm index 85e780f..5bd5bcf 100644 --- a/lib/MooseX/TypeLibrary/Util.pm +++ b/lib/MooseX/Types/Util.pm @@ -1,8 +1,8 @@ -package MooseX::TypeLibrary::Util; +package MooseX::Types::Util; =head1 NAME -MooseX::TypeLibrary::Util - Common utility functions for the module +MooseX::Types::Util - Common utility functions for the module =cut @@ -14,7 +14,7 @@ use base 'Exporter'; =head1 DESCRIPTION This package the exportable functions that many parts in -L might need. +L might need. =cut @@ -45,7 +45,7 @@ sub filter_tags { =head1 SEE ALSO -L, L +L, L =head1 AUTHOR AND COPYRIGHT diff --git a/lib/MooseX/TypeLibrary/Wrapper.pm b/lib/MooseX/Types/Wrapper.pm similarity index 80% rename from lib/MooseX/TypeLibrary/Wrapper.pm rename to lib/MooseX/Types/Wrapper.pm index ca75c16..8a55845 100644 --- a/lib/MooseX/TypeLibrary/Wrapper.pm +++ b/lib/MooseX/Types/Wrapper.pm @@ -1,14 +1,14 @@ -package MooseX::TypeLibrary::Wrapper; +package MooseX::Types::Wrapper; #use warnings; #use strict; -#use base 'MooseX::TypeLibrary'; +#use base 'MooseX::Types'; use Carp qw( croak ); use Class::Inspector; use Moose; use namespace::clean; -extends 'MooseX::TypeLibrary'; +extends 'MooseX::Types'; sub import { my ($class, @args) = @_; @@ -20,7 +20,7 @@ sub import { unless ref $libraries{ $l } eq 'ARRAY'; my $library_class - = ($l eq 'Moose' ? 'MooseX::TypeLibrary::Moose' : $l ); + = ($l eq 'Moose' ? 'MooseX::Types::Moose' : $l ); require Class::Inspector->filename($library_class) unless Class::Inspector->loaded($library_class); diff --git a/t/10_moose-types.t b/t/10_moose-types.t index c7713b8..9ba7721 100644 --- a/t/10_moose-types.t +++ b/t/10_moose-types.t @@ -5,9 +5,9 @@ use strict; use Test::More; use FindBin; use lib "$FindBin::Bin/lib"; -use MooseX::TypeLibrary::Moose ':all'; +use MooseX::Types::Moose ':all'; -my @types = MooseX::TypeLibrary::Moose->type_names; +my @types = MooseX::Types::Moose->type_names; plan tests => @types * 3; diff --git a/t/lib/TestLibrary.pm b/t/lib/TestLibrary.pm index 53b01de..2eb20dd 100644 --- a/t/lib/TestLibrary.pm +++ b/t/lib/TestLibrary.pm @@ -2,8 +2,8 @@ package TestLibrary; use warnings; use strict; -use MooseX::TypeLibrary::Moose qw( Str ArrayRef Int ); -use MooseX::TypeLibrary +use MooseX::Types::Moose qw( Str ArrayRef Int ); +use MooseX::Types -declare => [qw( NonEmptyStr IntArrayRef TwentyThree )]; subtype NonEmptyStr, diff --git a/t/lib/TestWrapper.pm b/t/lib/TestWrapper.pm index 417da25..e8e5528 100644 --- a/t/lib/TestWrapper.pm +++ b/t/lib/TestWrapper.pm @@ -1,9 +1,9 @@ package TestWrapper; use Moose; -extends 'MooseX::TypeLibrary::Wrapper'; +extends 'MooseX::Types::Wrapper'; #use Class::C3; -#use base 'MooseX::TypeLibrary::Wrapper'; +#use base 'MooseX::Types::Wrapper'; override type_export_generator => sub { my $code = super();