Remove crap from Makefile.PL by using MI::AuthorRequires
t0m [Wed, 19 Aug 2009 19:51:34 +0000 (20:51 +0100)]
Makefile.PL

index 456dbc0..c6ae2a2 100644 (file)
@@ -1,6 +1,14 @@
 use inc::Module::Install 0.91;
+use strict;
+use warnings;
 use 5.008006;
 
+BEGIN {
+    if ($Module::Install::AUTHOR) {
+        require Module::Install::AuthorRequires;
+    }
+}
+
 license  'perl';
 
 name     'Catalyst-Engine-Stomp';
@@ -19,38 +27,23 @@ requires 'namespace::autoclean' => '0.05';
 test_requires 'Alien::ActiveMQ' => '0.00003';
 test_requires 'Catalyst::Plugin::ConfigLoader' => undef;
 
-my @force_build_requires_if_author = qw(
-  Test::NoTabs
-  Test::Pod
-  Test::Pod::Coverage
-  Pod::Coverage
-);
+author_requires 'Test::NoTabs';
+author_requires 'Test::Pod';
+author_requires 'Test::Pod::Coverage';
+author_requires 'Pod::Coverage';
 
 if ($Module::Install::AUTHOR) {
-    foreach my $module (@force_build_requires_if_author) {
-        build_requires $module;
-    }
     darwin_check_no_resource_forks();
 }
 
+resources
+    'repository' => 'git://github.com/chrisa/catalyst-engine-stomp.git',
+    'license' => 'http://dev.perl.org/licenses/';
+
 install_script glob('script/*.pl');
 auto_install;
 WriteAll;
 
-if ($Module::Install::AUTHOR) {
-
-  # Strip out the author only build_requires from META.yml
-  # Need to do this _after_ WriteAll else it looses track of them
-  strip_author_only_build_requires(@force_build_requires_if_author);
-
-  Meta->{values}{resources} = [
-    [ 'license',    => 'http://dev.perl.org/licenses/' ],
-    [ 'repository', => 'git://github.com/chrisa/catalyst-engine-stomp.git' ],
-  ];
-
-  Meta->write;
-}
-
 sub darwin_check_no_resource_forks {
     if ($^O eq 'darwin') {
         my $osx_ver = `/usr/bin/sw_vers -productVersion`;
@@ -66,17 +59,3 @@ sub darwin_check_no_resource_forks {
         }
 }
 
-sub strip_author_only_build_requires {
-    my @build_requires_to_strip = @_;
-    Meta->{values}{build_requires} = [ grep {
-      my $ok = 1;
-      foreach my $module (@build_requires_to_strip) {
-        if ($_->[0] =~ /$module/) {
-          $ok = 0;
-          last;
-        }
-      }
-      $ok;
-    } @{Meta->{values}{build_requires}} ];
-}
-