Subject: | [PATCH] Use File::ShareDir to get default template path |
Date: | Tue, 11 Jan 2011 15:19:20 +0000 |
To: | bug-DBICx-AutoDoc [...] rt.cpan.org |
From: | Dagfinn Ilmari Mannsåker <ilmari [...] ilmari.org> |
The location used by Module::Install::Share changed with Module::Install
0.76 and File::ShareDir 1.00. Just use the latter, rather than trying
to implement the logic ourselves.
---
Makefile.PL | 4 +++-
lib/DBICx/AutoDoc.pm | 12 ++++--------
2 files changed, 7 insertions(+), 9 deletions(-)
diff --git a/Makefile.PL b/Makefile.PL
index 7071b42..1413568 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -4,10 +4,12 @@ name 'DBICx-AutoDoc';
all_from 'lib/DBICx/AutoDoc.pm';
requires( $_ ) for qw(
- DBIx::Class Template Class::Inspector Carp Class::Accessor::Grouped FindBin
+ DBIx::Class Template Carp Class::Accessor::Grouped FindBin
Data::Dump File::Temp Pod::Usage Getopt::Long Tie::IxHash
);
+requires( File::ShareDir => '1.00' );
+
test_requires( $_ ) for qw(
Test::More
);
diff --git a/lib/DBICx/AutoDoc.pm b/lib/DBICx/AutoDoc.pm
index 93e4ea6..b2aa3b6 100644
--- a/lib/DBICx/AutoDoc.pm
+++ b/lib/DBICx/AutoDoc.pm
@@ -5,11 +5,12 @@ our $VERSION = '0.07';
use base qw( Class::Accessor::Grouped );
use Carp qw( croak );
use Template;
-use Class::Inspector;
use FindBin qw( );
use Data::Dump qw( dump );
use DBICx::AutoDoc::Magic;
use File::Temp qw( tempfile );
+use File::ShareDir qw( dist_dir );
+use File::Spec;
use Tie::IxHash;
__PACKAGE__->mk_group_accessors( simple => qw(
@@ -380,13 +381,8 @@ sub output_filename {
sub default_include_path {
my ( $self ) = @_;
- my $class = ref( $self ) || $self;
- my $short = Class::Inspector->filename( $class );
- my $long = Class::Inspector->loaded_filename( $class );
- substr( $short, -3, 3, '' );
- $long =~ m{^(.*)\Q$short\E\.pm\z}s or die "Failed to find base dir";
- my $dir = File::Spec->catdir( $1, 'auto', $short );
- return [ $dir, File::Spec->catdir( $FindBin::Bin, "templates" ) ];
+ (my $dist = ref( $self ) || $self) =~ s/::/-/g;
+ return [ dist_dir( $dist ), File::Spec->catdir( $FindBin::Bin, "templates" ) ];
}
sub list_templates {
--
1.7.1