1package MyBuilder; 2 3use base qw( Module::Build ); 4 5sub create_build_script { 6 my ( $self, @args ) = @_; 7 $self->_auto_mm; 8 return $self->SUPER::create_build_script( @args ); 9} 10 11sub _auto_mm { 12 my $self = shift; 13 my $mm = $self->meta_merge; 14 my @meta = qw( homepage bugtracker MailingList repository ); 15 for my $meta ( @meta ) { 16 next if exists $mm->{resources}{$meta}; 17 my $auto = "_auto_$meta"; 18 next unless $self->can( $auto ); 19 my $av = $self->$auto(); 20 $mm->{resources}{$meta} = $av if defined $av; 21 } 22 $self->meta_merge( $mm ); 23} 24 25sub _auto_repository { 26 my $self = shift; 27 if ( -d '.svn' ) { 28 my $info = `svn info .`; 29 return $1 if $info =~ /^URL:\s+(.+)$/m; 30 } 31 elsif ( -d '.git' ) { 32 my $info = `git remote -v`; 33 return unless $info =~ /^origin\s+(.+)$/m; 34 my $url = $1; 35 # Special case: patch up github URLs 36 $url =~ s!^git\@github\.com:!git://github.com/!; 37 return $url; 38 } 39 return; 40} 41 42sub _auto_bugtracker { 43 'http://rt.cpan.org/NoAuth/Bugs.html?Dist=' . shift->dist_name; 44} 45 46sub ACTION_testauthor { 47 my $self = shift; 48 $self->test_files( 'xt/author' ); 49 $self->ACTION_test; 50} 51 52sub ACTION_critic { 53 exec qw( perlcritic -1 -q -profile perlcriticrc lib/ ), glob 't/*.t'; 54} 55 56sub ACTION_tags { 57 exec( 58 qw( 59 ctags -f tags --recurse --totals 60 --exclude=blib 61 --exclude=.svn 62 --exclude='*~' 63 --languages=Perl 64 t/ lib/ 65 ) 66 ); 67} 68 69sub ACTION_tidy { 70 my $self = shift; 71 72 my @extra = qw( Build.PL ); 73 74 my %found_files = map { %$_ } $self->find_pm_files, 75 $self->_find_file_by_type( 'pm', 't' ), 76 $self->_find_file_by_type( 'pm', 'inc' ), 77 $self->_find_file_by_type( 't', 't' ); 78 79 my @files = ( keys %found_files, 80 map { $self->localize_file_path( $_ ) } @extra ); 81 82 for my $file ( @files ) { 83 system 'perltidy', '-b', $file; 84 unlink "$file.bak" if $? == 0; 85 } 86} 87 881; 89