MooseX-Role-Strict-0.05000755000765000024 011552260442 15317 5ustar00curtispoestaff000000000000MooseX-Role-Strict-0.05/Build.PL000444000765000024 124111552260442 16746 0ustar00curtispoestaff000000000000use strict; use warnings; use Module::Build; my $builder = Module::Build->new( module_name => 'MooseX::Role::Strict', license => 'perl', dist_author => 'Curtis "Ovid" Poe ', dist_version_from => 'lib/MooseX/Role/Strict.pm', build_requires => { 'Test::More' => 0.96, }, requires => { 'Moose' => 0.89, # for --metaclass, -excludes }, meta_merge => { resources => { repository => 'http://github.com/Ovid/MooseX--Role--Strict' } }, add_to_cleanup => ['MooseX-Role-Strict-*'], create_makefile_pl => 'traditional', ); $builder->create_build_script(); MooseX-Role-Strict-0.05/Changes000444000765000024 120311552260442 16743 0ustar00curtispoestaff000000000000Revision history for MooseX-Role-Strict 0.05 04-16-2011 - Drop Test::Most dependency (we didn't actually need it). Thanks to Larry Gilbert (https://github.com/L2G) for this. 0.04 01-09-2010 - Fix warnings with new Moose versions about "excludes" during role application (Karen Etheridge) 0.03 19-11-2009 - Ignore the 'meta' method. This is now implicitly added to your class. 0.02 30-04-2009 - Make the Meta class a bit more future-proof (Sartak). 0.01 30-04-2009 - Push to github and CPAN. - Don't allow classes to silently override methods. MooseX-Role-Strict-0.05/Makefile.PL000444000765000024 61111552260442 17404 0ustar00curtispoestaff000000000000# Note: this file was auto-generated by Module::Build::Compat version 0.3607 use ExtUtils::MakeMaker; WriteMakefile ( 'PL_FILES' => {}, 'INSTALLDIRS' => 'site', 'NAME' => 'MooseX::Role::Strict', 'EXE_FILES' => [], 'VERSION_FROM' => 'lib/MooseX/Role/Strict.pm', 'PREREQ_PM' => { 'Test::More' => '0.96', 'Moose' => '0.89' } ) ; MooseX-Role-Strict-0.05/MANIFEST000444000765000024 22611552260442 16565 0ustar00curtispoestaff000000000000Build.PL Changes MANIFEST README TODO lib/MooseX/Role/Strict.pm lib/MooseX/Meta/Role/Strict.pm t/00-load.t t/override.t xt/pod.t Makefile.PL META.yml MooseX-Role-Strict-0.05/META.yml000444000765000024 122411552260442 16724 0ustar00curtispoestaff000000000000--- abstract: "use strict 'roles'" author: - "Curtis \"Ovid\" Poe " build_requires: Test::More: 0.96 configure_requires: Module::Build: 0.36 generated_by: 'Module::Build version 0.3607' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 name: MooseX-Role-Strict provides: MooseX::Meta::Role::Strict: file: lib/MooseX/Meta/Role/Strict.pm version: 0.05 MooseX::Role::Strict: file: lib/MooseX/Role/Strict.pm version: 0.05 requires: Moose: 0.89 resources: license: http://dev.perl.org/licenses/ repository: http://github.com/Ovid/MooseX--Role--Strict version: 0.05 MooseX-Role-Strict-0.05/README000444000765000024 151711552260442 16340 0ustar00curtispoestaff000000000000MooseX-Role-Strict INSTALLATION To install this module, run the following commands: perl Build.PL ./Build ./Build test ./Build install SUPPORT AND DOCUMENTATION After installing, you can find documentation for this module with the perldoc command. perldoc MooseX::Role::Strict You can also look for information at: RT, CPAN's request tracker http://rt.cpan.org/NoAuth/Bugs.html?Dist=MooseX-Role-Strict AnnoCPAN, Annotated CPAN documentation http://annocpan.org/dist/MooseX-Role-Strict CPAN Ratings http://cpanratings.perl.org/d/MooseX-Role-Strict Search CPAN http://search.cpan.org/dist/MooseX-Role-Strict/ COPYRIGHT AND LICENCE Copyright (C) 2009 Curtis "Ovid" Poe This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. MooseX-Role-Strict-0.05/TODO000444000765000024 11211552260442 16116 0ustar00curtispoestaff000000000000* Excludes must add to 'requires' * Includes * Die on composition failure MooseX-Role-Strict-0.05/lib000755000765000024 011552260442 16065 5ustar00curtispoestaff000000000000MooseX-Role-Strict-0.05/lib/MooseX000755000765000024 011552260442 17277 5ustar00curtispoestaff000000000000MooseX-Role-Strict-0.05/lib/MooseX/Meta000755000765000024 011552260442 20165 5ustar00curtispoestaff000000000000MooseX-Role-Strict-0.05/lib/MooseX/Meta/Role000755000765000024 011552260442 21066 5ustar00curtispoestaff000000000000MooseX-Role-Strict-0.05/lib/MooseX/Meta/Role/Strict.pm000444000765000024 327411552260442 23037 0ustar00curtispoestaff000000000000package MooseX::Meta::Role::Strict; use Moose; extends 'Moose::Meta::Role'; our $VERSION = 0.05; override apply => sub { my ( $self, $other, @args ) = @_; if ( blessed($other) && $other->isa('Moose::Meta::Class') ) { # already loaded return MooseX::Meta::Role::Application::ToClass::Strict->new(@args) ->apply( $self, $other ); } super; }; 1; __END__ =head1 NAME MooseX::Meta::Role::Strict - Ensure we use strict role application. =head1 VERSION Version 0.05 =head1 DESCRIPTION This is the metaclass for C. For internal use only. =head1 AUTHOR Curtis "Ovid" Poe, C<< >> =head1 BUGS Please report any bugs or feature requests to C, or through the web interface at L. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. =head1 SUPPORT You can find documentation for this module with the perldoc command. perldoc MooseX::Role::Strict You can also look for information at: =over 4 =item * RT: CPAN's request tracker L =item * AnnoCPAN: Annotated CPAN documentation L =item * CPAN Ratings L =item * Search CPAN L =back =head1 ACKNOWLEDGEMENTS =head1 COPYRIGHT & LICENSE Copyright 2009 Curtis "Ovid" Poe, all rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut MooseX-Role-Strict-0.05/lib/MooseX/Role000755000765000024 011552260442 20200 5ustar00curtispoestaff000000000000MooseX-Role-Strict-0.05/lib/MooseX/Role/Strict.pm000444000765000024 1260011552260442 22162 0ustar00curtispoestaff000000000000package MooseX::Role::Strict; use warnings; use strict; our $VERSION = 0.05; use MooseX::Meta::Role::Strict; use Moose::Role; use Moose::Exporter; Moose::Exporter->setup_import_methods( also => 'Moose::Role' ); sub init_meta { my ( $class, %opt ) = @_; return Moose::Role->init_meta( ## %opt, ## metaclass => 'MooseX::Meta::Role::Strict' ); } package # Hide from PAUSE MooseX::Meta::Role::Application::ToClass::Strict; use Moose; extends 'Moose::Meta::Role::Application::ToClass'; sub apply_methods { my ( $self, $role, $class ) = @_; my @implicitly_overridden; foreach my $method_name ( $role->get_method_list ) { next if 'meta' eq $method_name; # Moose auto-exports this unless ( $self->is_method_excluded($method_name) ) { # it if it has one already if ( $class->has_method($method_name) && # and if they are not the same thing ... $class->get_method($method_name)->body != $role->get_method($method_name)->body ) { push @implicitly_overridden => $method_name; next; } else { # add it, although it could be overridden $class->add_method( $method_name, $role->get_method($method_name) ); } } if ( $self->is_method_aliased($method_name) ) { my $aliased_method_name = $self->get_method_aliases->{$method_name}; # it if it has one already if ( $class->has_method($aliased_method_name) && # and if they are not the same thing ... $class->get_method($aliased_method_name)->body != $role->get_method($method_name)->body ) { $class->throw_error("Cannot create a method alias if a local method of the same name exists"); } $class->add_method( $aliased_method_name, $role->get_method($method_name) ); } } if (@implicitly_overridden) { my $s = @implicitly_overridden > 1 ? "s" : ""; my $class_name = $class->name; my $role_name = $role->name; my $methods = join ', ' => @implicitly_overridden; # we use \n because we have no hope of guessing the right stack frame, # it's almost certainly never going to be the one above us $class->throw_error(<<" END_ERROR"); The class $class_name has implicitly overridden the method$s ($methods) from role $role_name. If this is intentional, please exclude the method$s from composition to silence this warning (see Moose::Cookbook::Roles::Recipe2) END_ERROR } # we must reset the cache here since # we are just aliasing methods, otherwise # the modifiers go wonky. $class->reset_package_cache_flag; } 1; __END__ =head1 NAME MooseX::Role::Strict - use strict 'roles' =head1 VERSION Version 0.05 =head1 SYNOPSIS This code will fail at composition time: { package My::Role; use MooseX::Role::Strict; sub conflict {} } { package My::Class; use Moose; with 'My::Role'; sub conflict {} } With an error message similar to the following: The class My::Class has implicitly overridden the method (conflict) from role My::Role ... To resolve this, explictly exclude the 'conflict' method: { package My::Class; use Moose; with 'My::Role' => { -excludes => 'conflict' }; sub conflict {} } =head1 DESCRIPTION B: this is ALPHA code. More features to be added later. When using L, a class which provides a method a role provides will silently override that method. This can cause strange, hard-to-debug errors when the role's methods are not called. Simple use C instead of C and overriding a role's method becomes a composition-time failure. See the synopsis for a resolution. =head1 AUTHOR Curtis "Ovid" Poe, C<< >> =head1 BUGS Please report any bugs or feature requests to C, or through the web interface at L. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. =head1 SUPPORT You can find documentation for this module with the perldoc command. perldoc MooseX::Role::Strict You can also look for information at: =over 4 =item * RT: CPAN's request tracker L =item * AnnoCPAN: Annotated CPAN documentation L =item * CPAN Ratings L =item * Search CPAN L =back =head1 ACKNOWLEDGEMENTS =head1 TODO Add C<-includes> to make things easier: with 'Some::Role' => { -includes => 'bar' }; That reverses the sense of '-excludes' in case you're more interested in the interface than the implementation. I'm unsure of the syntax for auto-converting a role to a pure interface. =head1 COPYRIGHT & LICENSE Copyright 2009 Curtis "Ovid" Poe, all rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut MooseX-Role-Strict-0.05/t000755000765000024 011552260442 15562 5ustar00curtispoestaff000000000000MooseX-Role-Strict-0.05/t/00-load.t000444000765000024 25211552260442 17217 0ustar00curtispoestaff000000000000#!perl -T use Test::More tests => 1; BEGIN { use_ok( 'MooseX::Role::Strict' ); } diag( "Testing MooseX::Role::Strict $MooseX::Role::Strict::VERSION, Perl $], $^X" ); MooseX-Role-Strict-0.05/t/override.t000444000765000024 162211552260442 17724 0ustar00curtispoestaff000000000000#!/usr/bin/env perl use strict; use warnings; use Test::More tests => 4; use lib 'lib'; { use MooseX::Role::Strict (); package My::Role::Example; use MooseX::Meta::Role::Strict; use Moose::Role -metaclass => 'MooseX::Meta::Role::Strict'; sub munge { 'munge role' } } isa_ok +My::Role::Example->meta, 'MooseX::Meta::Role::Strict'; eval <<'END_EVAL'; package Foo; use Moose; with 'My::Role::Example'; sub munge { 'munge foo' } END_EVAL my $error = $@; like $error, qr/\QThe class Foo has implicitly overridden the method (munge)/, 'Implicitly overridding methods should be fatal'; eval <<'END_EVAL'; package Bar; use Moose; with 'My::Role::Example' => { -excludes => ['munge'] }; sub munge { 'munge bar' } END_EVAL $error = $@; ok !$error, '... but explicitly exluding the conflicting errors should be fine'; is Bar->munge, 'munge bar', '... and the correct method should be available'; MooseX-Role-Strict-0.05/xt000755000765000024 011552260442 15752 5ustar00curtispoestaff000000000000MooseX-Role-Strict-0.05/xt/pod.t000444000765000024 35011552260442 17034 0ustar00curtispoestaff000000000000#!perl -T use strict; use warnings; use Test::More; # Ensure a recent version of Test::Pod my $min_tp = 1.22; eval "use Test::Pod $min_tp"; plan skip_all => "Test::Pod $min_tp required for testing POD" if $@; all_pod_files_ok();