Changeset 1919

Show
Ignore:
Timestamp:
08/22/06 14:23:42
Author:
miyagawa
Message:

update pmsetup to use Module::Install

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • misc/pmsetup

    r1872 r1919  
    11#!/usr/bin/perl 
    2 # 
    3 # Tatsuhiko Miyagawa <miyagawa@bulknews.net> 
    4 # 
    5  
    62use strict; 
     3use warnings; 
     4use ExtUtils::MakeMaker qw(prompt); 
    75use FileHandle; 
    86use File::Copy; 
    97use File::Path; 
     8use File::Spec; 
     9use YAML; 
    1010 
    11 #-------------------------------------------------- 
    12 # Config 
    13 my $Credit = 'Author E<lt>author@galaxyE<gt>'; 
    14 #-------------------------------------------------- 
     11my $path   = File::Spec->catfile($ENV{HOME}, "/.pmsetuprc"); 
     12my $config = eval { YAML::LoadFile($path) } || {}; 
    1513 
    16 my $modname = shift or die "Usage: $0 module\n"; 
     14my $save; 
     15while (! $config->{author}) { 
     16    $config->{author} = prompt("Your name: ", ''); 
     17    $save++; 
     18
     19 
     20my $modname = shift @ARGV or die "Usage: $0 module\n"; 
    1721my @pkg = split /::/, $modname; 
    1822 
     
    2529mk_manifest(); 
    2630prepare_make(); 
     31 
     32END { 
     33    YAML::DumpFile($path, $config) if $save; 
     34} 
    2735 
    2836sub mkdir_chdir { 
     
    3846 
    3947    # Makefile.PL 
     48    my $dist = join('-', @pkg); 
    4049    my $path = join('/', @pkg). '.pm'; 
    4150    my $mk = FileHandle->new('>Makefile.PL') or die $!; 
    4251    $mk->print(<<MK); 
    43 use ExtUtils::MakeMaker; 
    44 WriteMakefile( 
    45     'NAME'      => '$modname', 
    46     'VERSION_FROM' => 'lib/$path', # finds \$VERSION 
    47     'PREREQ_PM' => { 
    48         Test::More => 0.32, 
    49     }, 
    50 ); 
     52use inc::Module::Install; 
     53name('$dist'); 
     54all_from('lib/$path'); 
     55 
     56build_requires('Test::More'); 
     57auto_include; 
     58WriteAll; 
    5159MK 
    52     ; 
    5360} 
    5461 
     
    7279 
    7380BEGIN { use_ok '$modname' } 
     81TEST 
     82    ; 
     83 
     84    $test = FileHandle->new(">t/99_pod.t") or die $!; 
     85    $test->print(<<'TEST'); 
     86use Test::More; 
     87eval "use Test::Pod 1.00"; 
     88plan skip_all => "Test::Pod 1.00 required for testing POD" if $@; 
     89all_pod_files_ok(); 
    7490TEST 
    7591    ; 
     
    97113 
    98114use strict; 
    99 use vars qw(\$VERSION)
    100 \$VERSION = '0.01'; 
     115use 5.8.0
     116our \$VERSION = '0.01'; 
    101117 
    1021181; 
     
    117133=head1 AUTHOR 
    118134 
    119 $Credit 
     135$config->{author} 
     136 
     137=head1 LICENSE 
    120138 
    121139This library is free software; you can redistribute it and/or modify 
     
    123141 
    124142=head1 SEE ALSO 
    125  
    126 L<> 
    127143 
    128144=cut 
     
    150166 
    151167sub prepare_make { 
    152     do "Makefile.PL"
     168    !system "perl Makefile.PL" or die $?
    153169    !system 'make test' or die $?; 
    154170    !system 'make manifest' or die $?;