From: gfx Date: Wed, 7 Oct 2009 04:52:04 +0000 (+0900) Subject: Switch to Mouse::Exporter X-Git-Tag: 0.37_03~24 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=bc69ee88207ce5c53f5c02dbd44cfabfbe6bae70;p=gitmo%2FMouse.git Switch to Mouse::Exporter --- diff --git a/author/generate-mouse-tiny.pl b/author/generate-mouse-tiny.pl index 0484cdb..4799507 100755 --- a/author/generate-mouse-tiny.pl +++ b/author/generate-mouse-tiny.pl @@ -64,6 +64,8 @@ print { $handle } << 'EOF'; package Mouse::Tiny; use base 'Mouse'; +Mouse::Exporter->setup_import_methods(also => 'Mouse'); + EOF print { $handle } "1;\n\n"; diff --git a/lib/Mouse.pm b/lib/Mouse.pm index 0e12516..81bce55 100644 --- a/lib/Mouse.pm +++ b/lib/Mouse.pm @@ -1,8 +1,7 @@ package Mouse; use 5.006_002; -use strict; -use warnings; +use Mouse::Exporter; # enables strict and warnings our $VERSION = '0.37_02'; @@ -17,7 +16,6 @@ use Mouse::Meta::Role; use Mouse::Meta::Attribute; use Mouse::Object; use Mouse::Util::TypeConstraints (); -use Mouse::Exporter; Mouse::Exporter->setup_import_methods( as_is => [qw( diff --git a/lib/Mouse/Meta/Attribute.pm b/lib/Mouse/Meta/Attribute.pm index 9ffac52..49840b3 100644 --- a/lib/Mouse/Meta/Attribute.pm +++ b/lib/Mouse/Meta/Attribute.pm @@ -1,11 +1,8 @@ package Mouse::Meta::Attribute; -use strict; -use warnings; +use Mouse::Util qw(:meta); # enables strict and warnings use Carp (); -use Mouse::Util qw(:meta); - use Mouse::Meta::TypeConstraint; use Mouse::Meta::Method::Accessor; diff --git a/lib/Mouse/Meta/Class.pm b/lib/Mouse/Meta/Class.pm index ece4323..1220d29 100644 --- a/lib/Mouse/Meta/Class.pm +++ b/lib/Mouse/Meta/Class.pm @@ -1,11 +1,8 @@ package Mouse::Meta::Class; -use strict; -use warnings; +use Mouse::Util qw/:meta get_linear_isa not_supported/; # enables strict and warnings use Scalar::Util qw/blessed weaken/; -use Mouse::Util qw/:meta get_linear_isa not_supported/; - use Mouse::Meta::Method::Constructor; use Mouse::Meta::Method::Destructor; use Mouse::Meta::Module; diff --git a/lib/Mouse/Meta/Method.pm b/lib/Mouse/Meta/Method.pm index a018662..9567a28 100755 --- a/lib/Mouse/Meta/Method.pm +++ b/lib/Mouse/Meta/Method.pm @@ -1,8 +1,5 @@ package Mouse::Meta::Method; -use strict; -use warnings; - -use Mouse::Util qw(:meta); +use Mouse::Util qw(:meta); # enables strict and warnings use overload '&{}' => 'body', diff --git a/lib/Mouse/Meta/Method/Accessor.pm b/lib/Mouse/Meta/Method/Accessor.pm index 7be4ec9..6e1055c 100755 --- a/lib/Mouse/Meta/Method/Accessor.pm +++ b/lib/Mouse/Meta/Method/Accessor.pm @@ -1,6 +1,5 @@ package Mouse::Meta::Method::Accessor; -use strict; -use warnings; +use Mouse::Util; # enables strict and warnings use Scalar::Util qw(blessed); sub _generate_accessor{ diff --git a/lib/Mouse/Meta/Method/Constructor.pm b/lib/Mouse/Meta/Method/Constructor.pm index 1211e61..d68e958 100644 --- a/lib/Mouse/Meta/Method/Constructor.pm +++ b/lib/Mouse/Meta/Method/Constructor.pm @@ -1,6 +1,5 @@ package Mouse::Meta::Method::Constructor; -use strict; -use warnings; +use Mouse::Util; # enables strict and warnings sub _generate_constructor_method { my ($class, $metaclass, $args) = @_; diff --git a/lib/Mouse/Meta/Method/Destructor.pm b/lib/Mouse/Meta/Method/Destructor.pm index 681cfaa..783e6d3 100644 --- a/lib/Mouse/Meta/Method/Destructor.pm +++ b/lib/Mouse/Meta/Method/Destructor.pm @@ -1,6 +1,5 @@ package Mouse::Meta::Method::Destructor; -use strict; -use warnings; +use Mouse::Util; # enables strict and warnings sub _empty_destroy{ } diff --git a/lib/Mouse/Meta/Module.pm b/lib/Mouse/Meta/Module.pm index 9fefa10..f0a6711 100755 --- a/lib/Mouse/Meta/Module.pm +++ b/lib/Mouse/Meta/Module.pm @@ -1,13 +1,9 @@ package Mouse::Meta::Module; -use strict; -use warnings; +use Mouse::Util qw/:meta get_code_package load_class not_supported/; # enables strict and warnings use Carp (); use Scalar::Util qw/blessed weaken/; -use Mouse::Util qw/:meta get_code_package not_supported load_class/; - - my %METAS; sub _metaclass_cache { # DEPRECATED diff --git a/lib/Mouse/Meta/Role.pm b/lib/Mouse/Meta/Role.pm index 5d1c57f..317adbc 100644 --- a/lib/Mouse/Meta/Role.pm +++ b/lib/Mouse/Meta/Role.pm @@ -1,8 +1,6 @@ package Mouse::Meta::Role; -use strict; -use warnings; +use Mouse::Util qw(:meta not_supported english_list); # enables strict and warnings -use Mouse::Util qw(:meta not_supported english_list get_code_info); use Mouse::Meta::Module; our @ISA = qw(Mouse::Meta::Module); diff --git a/lib/Mouse/Meta/Role/Method.pm b/lib/Mouse/Meta/Role/Method.pm index 79b55d4..caa1a3b 100755 --- a/lib/Mouse/Meta/Role/Method.pm +++ b/lib/Mouse/Meta/Role/Method.pm @@ -1,12 +1,10 @@ package Mouse::Meta::Role::Method; -use strict; -use warnings; +use Mouse::Util; # enables strict and warnings use Mouse::Meta::Method; our @ISA = qw(Mouse::Meta::Method); 1; - __END__ =head1 NAME diff --git a/lib/Mouse/Meta/TypeConstraint.pm b/lib/Mouse/Meta/TypeConstraint.pm index b5cd0b6..9ba41fe 100644 --- a/lib/Mouse/Meta/TypeConstraint.pm +++ b/lib/Mouse/Meta/TypeConstraint.pm @@ -1,6 +1,5 @@ package Mouse::Meta::TypeConstraint; -use strict; -use warnings; +use Mouse::Util qw(:meta); # enables strict and warnings use overload '""' => sub { shift->{name} }, # stringify to tc name @@ -9,8 +8,6 @@ use overload use Carp qw(confess); use Scalar::Util qw(blessed reftype); -use Mouse::Util qw(:meta); - my $null_check = sub { 1 }; sub new { diff --git a/lib/Mouse/Object.pm b/lib/Mouse/Object.pm index ae36dd8..127a575 100644 --- a/lib/Mouse/Object.pm +++ b/lib/Mouse/Object.pm @@ -1,8 +1,5 @@ package Mouse::Object; -use strict; -use warnings; - -use Mouse::Util qw(does dump); +use Mouse::Util qw(does dump); # enables strict and warnings sub new { my $class = shift; diff --git a/lib/Mouse/Role.pm b/lib/Mouse/Role.pm index 91118cd..33350cc 100644 --- a/lib/Mouse/Role.pm +++ b/lib/Mouse/Role.pm @@ -1,13 +1,10 @@ package Mouse::Role; -use strict; -use warnings; +use Mouse::Util qw(not_supported); # enables strict and warnings use Carp (); use Scalar::Util (); -use Mouse::Util qw(not_supported); use Mouse (); - use Mouse::Exporter; Mouse::Exporter->setup_import_methods( diff --git a/lib/Mouse/Util.pm b/lib/Mouse/Util.pm index 2a03160..c31e115 100644 --- a/lib/Mouse/Util.pm +++ b/lib/Mouse/Util.pm @@ -1,42 +1,40 @@ package Mouse::Util; -use strict; -use warnings; - -use Exporter; +use Mouse::Exporter; # enables strict and warnings use Carp qw(confess); use B (); use constant _MOUSE_VERBOSE => !!$ENV{MOUSE_VERBOSE}; -our @ISA = qw(Exporter); -our @EXPORT_OK = qw( - find_meta - does_role - resolve_metaclass_alias - apply_all_roles - english_list +Mouse::Exporter->setup_import_methods( + as_is => [qw( + find_meta + does_role + resolve_metaclass_alias + apply_all_roles + english_list - load_class - is_class_loaded + load_class + is_class_loaded - get_linear_isa - get_code_info + get_linear_isa + get_code_info - get_code_package + get_code_package - not_supported + not_supported - does meta dump - _MOUSE_VERBOSE -); -our %EXPORT_TAGS = ( - all => \@EXPORT_OK, - meta => [qw(does meta dump _MOUSE_VERBOSE)], + does meta dump + _MOUSE_VERBOSE + )], + groups => { + default => [], # export no functions by default + meta => [qw(does meta dump _MOUSE_VERBOSE)], + }, + _export_to_main => 1, ); # aliases as public APIs - # it must be 'require', not 'use', because Mouse::Meta::Module depends on Mouse::Util require Mouse::Meta::Module; # for the entities of metaclass cache utilities diff --git a/lib/Mouse/Util/TypeConstraints.pm b/lib/Mouse/Util/TypeConstraints.pm index 9582efd..85b5698 100644 --- a/lib/Mouse/Util/TypeConstraints.pm +++ b/lib/Mouse/Util/TypeConstraints.pm @@ -1,19 +1,20 @@ package Mouse::Util::TypeConstraints; -use strict; -use warnings; - -use Exporter; +use Mouse::Util qw(does_role not_supported); # enables strict and warnings use Carp qw(confess); use Scalar::Util qw/blessed looks_like_number openhandle/; -use Mouse::Util qw(does_role not_supported); use Mouse::Meta::TypeConstraint; +use Mouse::Exporter; + +Mouse::Exporter->setup_import_methods( + as_is => [qw( + as where message from via + type subtype coerce class_type role_type enum + find_type_constraint + )], -our @ISA = qw(Exporter); -our @EXPORT = qw( - as where message from via type subtype coerce class_type role_type enum - find_type_constraint + _export_to_main => 1, ); my %TYPE;