Permalink
Browse files

Merge pull request #4 from autarch/master

This makes this plugin a fair bit faster, especially when dealing with many module files
  • Loading branch information...
2 parents cfa23ed + 82ac3f6 commit 90e45eb8a3103dcf54e7871d994978106feb6e38 @apocalypse committed Jan 3, 2012
Showing with 10 additions and 11 deletions.
  1. +2 −0 Changes
  2. +8 −11 lib/Dist/Zilla/Plugin/Authority.pm
View
@@ -2,6 +2,8 @@ Revision history for Dist::Zilla::Plugin::Authority
{{$NEXT}}
+ Use the new PPI role in Dist::Zilla 4.300001 to make this plugin faster ( thanks DROLSKY )
+
1.005
Released: 2011-04-14 17:05:17 UTC
@@ -6,6 +6,7 @@ use Moose 1.03;
use PPI 1.206;
use File::Spec;
use File::HomeDir;
+use Dist::Zilla::Util;
with(
'Dist::Zilla::Role::MetaProvider' => { -version => '4.102345' },
@@ -14,6 +15,7 @@ with(
-version => '4.102345',
default_finders => [ ':InstallModules', ':ExecFiles' ],
},
+ 'Dist::Zilla::Role::PPI' => { -version => '4.300001' },
);
=attr authority
@@ -147,17 +149,12 @@ sub _munge_file {
sub _munge_perl {
my( $self, $file ) = @_;
- my $content = $file->content;
- my $document = PPI::Document->new( \$content ) or Carp::croak( PPI::Document->errstr );
+ my $document = $self->ppi_document_for_file($file);
- {
- my $code_only = $document->clone;
- $code_only->prune( "PPI::Token::$_" ) for qw( Comment Pod Quote Regexp );
- if ( $code_only->serialize =~ /\$AUTHORITY\s*=/sm ) {
- $self->log( [ 'skipping %s: assigns to $AUTHORITY', $file->name ] );
- return;
- }
- }
+ if ( $self->document_assigns_to_variable( $document, '$AUTHORITY' ) ) {
+ $self->log( [ 'skipping %s: assigns to $AUTHORITY', $file->name ] );
+ return;
+ }
# Should we use the comment to insert the $AUTHORITY or the pkg declaration?
if ( $self->locate_comment ) {
@@ -213,7 +210,7 @@ sub _munge_perl {
}
}
- $file->content( $document->serialize );
+ $self->save_ppi_document_to_file( $document, $file );
}
no Moose;

0 comments on commit 90e45eb

Please sign in to comment.