#!/usr/bin/env perl use strict; use warnings; die "usage: $0 [module-name]" unless @ARGV == 1; chdir "$ENV{HOME}/devel/cpan" or die "Unable to chdir $ENV{HOME}/devel/cpan"; my $name = shift; my ($colons, $hyphens); if ($name =~ /::/) { $colons = $name; ($hyphens = $name) =~ s/::/-/g; } else { $hyphens = $name; ($colons = $name) =~ s/-/::/g; } my @parts = split '-', $hyphens; my $dir = "lib/" . join('/', @parts[0..$#parts-1]); system("mkdir $hyphens") and die "Unable to mkdir $hyphens: $!"; chdir $hyphens; system("mkdir -p $dir") and die "Unable to mkdir $dir: $!"; system("mkdir t") and die "Unable to mkdir t: $!"; open my $handle, '>', "$dir/$parts[-1].pm" or die "Unable to open $dir/$parts[-1].pm for writing: $!"; print {$handle} module_contents(); close $handle; open $handle, '>', "t/000-load.t" or die "Unable to open t/000-load.t for writing: $!"; print {$handle} load_contents(); close $handle; open $handle, '>', "Makefile.PL" or die "Unable to open Makefile.PL for writing: $!"; print {$handle} makefile_contents(); close $handle; open $handle, '>', "Changes" or die "Unable to open Changes for writing: $!"; print {$handle} changes_contents(); close $handle; # get inc/ but not Makefile and META.yml system('perl Makefile.PL && rm -r Makefile META.yml inc/.author'); system('darcs init && darcs add $(darcs whatsnew -ls | perl -ple "s/^a //") && darcs record -a -m"Initial import of '.$colons.'"'); system('mkdir inc/.author'); system("darcs put sartak.org:www/code/cpan/$hyphens") if $ENV{PWD} =~ /cpan/i; open $handle, '>>', "_darcs/prefs/boring" or die "Unable to open _darcs/prefs/boring for writing: $!"; print {$handle} boring_contents(); close $handle; sub changes_contents { my $time = localtime; return << "CHANGES"; Revision history for $hyphens 0.01 $time First version, released on an unsuspecting world. CHANGES } sub boring_contents { return << 'BORING'; (^|/)blib($|/) (^|/)log/. (^|/)inc/.author($|/) (^|/)etc/site_config\.yml$ (^|/)Makefile$ (^|/)Makefile\.old$ (^|/)META\.yml$ (^|/)pm_to_blib$ BORING } sub makefile_contents { return << "MAKEFILE"; use inc::Module::Install; name '$hyphens'; all_from '$dir/$parts[-1].pm'; build_requires 'Test::More'; WriteAll; MAKEFILE } sub load_contents { return << "TEST"; #!/usr/bin/env perl use strict; use warnings; use Test::More tests => 1; use_ok '$colons'; TEST } sub module_contents { my $year = (localtime)[5] + 1900; return << "MODULE"; package $colons; use strict; use warnings; our \$VERSION = '0.01'; 1; __END__ =head1 NAME $colons - ??? =head1 SYNOPSIS use $colons; =head1 DESCRIPTION =head1 AUTHOR Shawn M Moore, C<< >> =head1 BUGS No known bugs. Please report any bugs through RT: email C, or browse L. =head1 COPYRIGHT AND LICENSE Copyright $year Shawn M Moore. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut MODULE }