use inc::Module::Install;
-name q{MooseX-TypeLibrary};
+name q{MooseX-Types};
license q{perl};
author q{Robert 'phaylon' Sedlacek <rs@474.at>};
-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;
-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
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;
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,
=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<use strict> and C<use warnings> 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
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<MooseX::TypeLibrary::Moose>
+to import the helpers from the shipped L<MooseX::Types::Moose>
library which can export all types that come with Moose.
You will have to define coercions for your types or your library won't
use MyLibrary ':all';
use MyOtherLibrary qw( TypeA TypeB );
-MooseX::TypeLibrary comes with a library of Moose' built-in types called
-L<MooseX::TypeLibrary::Moose>.
+MooseX::Types comes with a library of Moose' built-in types called
+L<MooseX::Types::Moose>.
=head1 WRAPPING A LIBRARY
package MyWrapper;
use strict;
use Class::C3;
- use base 'MooseX::TypeLibrary::Wrapper';
+ use base 'MooseX::Types::Wrapper';
sub coercion_export_generator {
my $class = shift;
1;
The C<Moose> library name is a special shortcut for
-L<MooseX::TypeLibrary::Moose>.
+L<MooseX::Types::Moose>.
=head2 Generator methods you can overload
=head2 import
-Installs the L<MooseX::TypeLibrary::Base> class into the caller and
+Installs the L<MooseX::Types::Base> class into the caller and
exports types according to the specification described in
L</"LIBRARY DEFINITION">. This will continue to
L<Moose::Util::TypeConstraints>' C<import> method to export helper
# 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
Generate a type export, e.g. C<Int()>. This will return either a
L<Moose::Meta::TypeConstraint> object, or alternatively a
-L<MooseX::TypeLibrary::UndefinedType> object if the type was not
+L<MooseX::Types::UndefinedType> object if the type was not
yet defined.
=cut
my ($class, $type, $full) = @_;
return sub {
return find_type_constraint($full)
- || MooseX::TypeLibrary::UndefinedType->new($full);
+ || MooseX::Types::UndefinedType->new($full);
};
}
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<Moose>, L<Moose::Util::TypeConstraints>, L<MooseX::TypeLibrary::Moose>
+L<Moose>, L<Moose::Util::TypeConstraints>, L<MooseX::Types::Moose>
=head1 AUTHOR AND COPYRIGHT
-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
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;
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<MooseX::TypeLibrary> module.
+interact with moose and the rest of the L<MooseX::Types> module.
=cut
=head2 import
Provides the import mechanism for your library. See
-L<MooseX::TypeLibrary/"LIBRARY USAGE"> for syntax details on this.
+L<MooseX::Types/"LIBRARY USAGE"> for syntax details on this.
=cut
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({
=head1 SEE ALSO
-L<MooseX::TypeLibrary::Moose>
+L<MooseX::Types::Moose>
=head1 AUTHOR AND COPYRIGHT
-package MooseX::TypeLibrary::Moose;
+package MooseX::Types::Moose;
=head1 NAME
-MooseX::TypeLibrary::Moose - Types shipped with L<Moose>
+MooseX::Types::Moose - Types shipped with L<Moose>
=cut
use warnings;
use strict;
-use MooseX::TypeLibrary;
+use MooseX::Types;
use Moose::Util::TypeConstraints ();
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',
=head1 DESCRIPTION
-This package contains a virtual library for L<MooseX::TypeLibrary> that
-is able to export all types known to L<Moose>. See L<MooseX::TypeLibrary>
+This package contains a virtual library for L<MooseX::Types> that
+is able to export all types known to L<Moose>. See L<MooseX::Types>
for general usage information.
=cut
=head2 type_storage
-Overrides L<MooseX::TypeLibrary::Base>' C<type_storage> to provide a hash
+Overrides L<MooseX::Types::Base>' C<type_storage> to provide a hash
reference containing all built-in L<Moose> types.
=cut
=head1 SEE ALSO
-L<MooseX::TypeLibrary::Moose>,
+L<MooseX::Types::Moose>,
L<Moose>,
L<Moose::Util::TypeConstraints>
-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
=head1 SEE ALSO
-L<MooseX::TypeLibrary::Moose>,
+L<MooseX::Types::Moose>,
L<Moose::Util::TypeConstraints>,
L<Moose::Meta::TypeConstraint>
-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
=head1 DESCRIPTION
This package the exportable functions that many parts in
-L<MooseX::TypeLibrary> might need.
+L<MooseX::Types> might need.
=cut
=head1 SEE ALSO
-L<MooseX::TypeLibrary::Moose>, L<Exporter>
+L<MooseX::Types::Moose>, L<Exporter>
=head1 AUTHOR AND COPYRIGHT
-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) = @_;
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);
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;
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,
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();