Remove Module::Install::ProvidesClass, setup provides manually ourselves.
Tomas Doran [Sat, 19 Dec 2009 10:21:20 +0000 (10:21 +0000)]
Module::Install::ProvidesClass just doesn't work for us - it still doesn't
know about roles, doesn't find all of our classes (not even all the MXD ones)
that PAUSE won't find itself, and also won't currently install cleanly from
CPAN.

The alternate solution here is _totally totally mental_, but appears more
reliable than PPI and all that jazz. It's also significantly faster:
Just loading the entire of Gitalist is waaay quicker than parsing it
all with PPI.

Changes
Makefile.PL

diff --git a/Changes b/Changes
index df66d6a..c9b74c2 100644 (file)
--- a/Changes
+++ b/Changes
@@ -10,6 +10,8 @@ This file documents the revision history for Perl extension Gitalist.
       chooses which type to build based on the config).
     - Remove all tabs and fix no tabs test (Dagfinn Ilmari MannsÃ¥ker)
     - Decode getpwuid values correctly (Dagfinn Ilmari MannsÃ¥ker)
+    - Generate correct provides information in META.yml so that search.cpan
+      indexes the classes contained in Gitalist correctly.
 
 0.000003 2009-12-09
     - Officially switch repository to Shadowcat
index 59c0a39..bbf3ee0 100644 (file)
@@ -7,7 +7,6 @@ use inc::Module::Install 0.91;
 use Module::Install::AuthorRequires;
 use Module::Install::AuthorTests;
 use Module::Install::ReadmeFromPod;
-use Module::Install::ProvidesClass;
 
 name 'Gitalist';
 all_from 'lib/Gitalist.pm';
@@ -71,8 +70,47 @@ resources repository => 'git://git.shadowcat.co.uk/catagits/Gitalist.git';
 
 catalyst;
 
-auto_provides_class;
 author_tests 't/author';
 install_script glob('script/*.pl');
 auto_install;
+
+# This is totally gross :)
+# However, it is also much more effective than Module::Install::ProvidesClass
+# which a) just does not work very well for us, b) totally won't install from
+# cpan right now..
+author_requires 'Module::Find';
+author_requires 'B::Hooks::OP::Check::StashChange';
+author_requires 'B::Compiling';
+if ($Module::Install::AUTHOR) {
+    require Module::Find;
+    require B::Hooks::OP::Check::StashChange;
+    require B::Compiling;
+    require FindBin;
+    require lib;
+
+    my $libdir = "$FindBin::Bin/lib";
+    lib->import($libdir);
+
+    my %packages;
+
+    our $id = B::Hooks::OP::Check::StashChange::register(sub {
+        my ($new, $old) = @_;
+        my $file = B::Compiling::PL_compiling()->file;
+        return unless $file =~ s/^$libdir/lib/;
+        $packages{$new} ||= $file
+            if $new =~ /^Gitalist/;
+    });
+
+    require Gitalist;
+    Module::Find::useall(qw/Gitalist/);
+    undef $id;
+
+    no strict 'refs';
+    provides($_ => {
+        file => $packages{$_},
+        ${$_.'::VERSION'} ? ( version => $_->VERSION() ) : ()
+    }) for keys %packages;
+}
+
 WriteAll;
+