diff --git a/bin/module-starter b/bin/module-starter index 1020e02..f9202e0 100755 --- a/bin/module-starter +++ b/bin/module-starter @@ -29,7 +29,10 @@ Options: --mi Same as --builder=Module::Install --author=name Author's name (taken from getpwuid if not provided) - --email=email Author's email (taken from EMAIL if not provided) + and Email address ( taken from $ENV{EMAIL} if Author's name is not provided ) + Format: Author Name + This option can be supplied multiple times for projects + that have multiple authors. --ignores=type Ignore type files to include (repeatable) --license=type License under which the module will be distributed @@ -61,6 +64,10 @@ Example: module-starter --module=Foo::Bar,Foo::Bat \ --author="Andy Lester" --email=andy@petdance.com + module-starter --module=Foo::Bar,Foo::Bat \ + --author="Andy Lester \ + --author="Sawyer X + =head1 DESCRIPTION C is a command-line interface to L, which it @@ -97,5 +104,8 @@ configuration file entry. A sample configuration file might read: This format may become more elaborate in the future, but a file of this type should remain valid. +Please note, as of right now the configuration file does *not* have support +for multiple authors. + =cut diff --git a/lib/Module/Starter/App.pm b/lib/Module/Starter/App.pm index a334c55..a3b127d 100644 --- a/lib/Module/Starter/App.pm +++ b/lib/Module/Starter/App.pm @@ -78,8 +78,7 @@ sub _process_command_line { mb => sub { push @{$config{builder}}, 'Module::Build' }, mi => sub { push @{$config{builder}}, 'Module::Install' }, - 'author=s' => \$config{author}, - 'email=s' => \$config{email}, + 'author=s@' => \@{ $config{author} }, 'license=s' => \$config{license}, 'minperl=s' => \$config{minperl}, 'fatalize' => \$config{fatalize}, diff --git a/lib/Module/Starter/Simple.pm b/lib/Module/Starter/Simple.pm index ad89b9e..2e9724f 100644 --- a/lib/Module/Starter/Simple.pm +++ b/lib/Module/Starter/Simple.pm @@ -95,16 +95,21 @@ sub create_distro { if ( ( not $self->{author} ) && ( $^O ne 'MSWin32' ) ) { ( $self->{author} ) = split /,/, ( getpwuid $> )[6]; + $self->{author} = [ + exists $ENV{EMAIL} + ? "$self->{author} <$ENV{EMAIL}>" + : $self->{author} + ]; } - if ( not $self->{email} and exists $ENV{EMAIL} ) { - $self->{email} = $ENV{EMAIL}; - } - - croak "Must specify an author\n" unless $self->{author}; - croak "Must specify an email address\n" unless $self->{email}; - ($self->{email_obfuscated} = $self->{email}) =~ s/@/ at /; + croak "Must specify one or more authors\n" + unless $self->{author} + && ref($self->{author}) eq 'ARRAY' + && @{$self->{author}} > 0; + croak "author strings must be in the format: 'Author Name '" + if grep { $_ !~ m/^.*?\s*\<.*?\>\s*$/ } @{$self->{author}}; + $self->{license} ||= 'artistic2'; $self->{minperl} ||= 5.006; $self->{ignores_type} ||= ['generic']; @@ -610,7 +615,7 @@ sub _license_blurb { This program is released under the following license: $self->{license} EOT - $license_blurb =~ s/___AUTHOR___/$self->{author}/ge; + $license_blurb =~ s/___AUTHOR___/join(',', @{$self->{author}})/ge; chomp $license_blurb; return $license_blurb; } @@ -749,8 +754,10 @@ sub Makefile_PL_guts { my $main_module = shift; my $main_pm_file = shift; - (my $author = "$self->{author} <$self->{email}>") =~ s/'/\'/g; - + my $author = '[' . + join(',', map { s/'/\'/g; "'$_'"; } @{ $self->{author} }) + . ']'; + my $slname = $self->{license_record} ? $self->{license_record}->{slname} : $self->{license}; my $warnings = sprintf 'warnings%s;', ($self->{fatalize} ? " FATAL => 'all" : ''); @@ -763,7 +770,7 @@ use ExtUtils::MakeMaker; WriteMakefile( NAME => '$main_module', - AUTHOR => q{$author}, + AUTHOR => $author, VERSION_FROM => '$main_pm_file', ABSTRACT_FROM => '$main_pm_file', LICENSE => '$slname', @@ -799,9 +806,13 @@ sub MI_Makefile_PL_guts { my $main_module = shift; my $main_pm_file = shift; - my $author = "$self->{author} <$self->{email}>"; + my $author = join ',', @{$self->{author}}; $author =~ s/'/\'/g; - + + # if there is more than one author, select the first one as + # the repository owner + my ($repo_author) = (split /\s*\{author}->[0])[0]; + my $license_url = $self->{license_record} ? $self->{license_record}->{url} : ''; my $warnings = sprintf 'warnings%s;', ($self->{fatalize} ? " FATAL => 'all" : ''); @@ -825,8 +836,8 @@ resources ( #homepage => 'http://yourwebsitehere.com', #IRC => 'irc://irc.perl.org/#$self->{distro}', license => '$license_url', - #repository => 'git://github.com/$self->{author}/$self->{distro}.git', - #repository => 'https://bitbucket.org/$self->{author}/$self->{distro}', + #repository => 'git://github.com/$repo_author/$self->{distro}.git', + #repository => 'https://bitbucket.org/$repo_author/$self->{distro}', bugtracker => 'http://rt.cpan.org/NoAuth/Bugs.html?Dist=$self->{distro}', ); @@ -891,8 +902,9 @@ sub Build_PL_guts { my $main_module = shift; my $main_pm_file = shift; - (my $author = "$self->{author} <$self->{email}>") =~ s/'/\'/g; - + my $author = '[' . + join(',', map { s/'/\'/g; "'$_'"; } @{$self->{author}}) + . ']'; my $slname = $self->{license_record} ? $self->{license_record}->{slname} : $self->{license}; my $warnings = sprintf 'warnings%s;', ($self->{fatalize} ? " FATAL => 'all" : ''); @@ -906,7 +918,7 @@ use Module::Build; my \$builder = Module::Build->new( module_name => '$main_module', license => '$slname', - dist_author => q{$author}, + dist_author => $author, dist_version_from => '$main_pm_file', release_status => 'stable', configure_requires => { @@ -1029,11 +1041,11 @@ sub _README_license { my $year = $self->_thisyear(); my $license_blurb = $self->_license_blurb(); - + my $author_string = join ',', @{$self->{author}}; return <<"HERE"; LICENSE AND COPYRIGHT -Copyright (C) $year $self->{author} +Copyright (C) $year $author_string $license_blurb HERE @@ -1757,11 +1769,11 @@ sub _module_license { my $license_blurb = $self->_license_blurb(); my $year = $self->_thisyear(); - + my $author_string = join ',', @{$self->{author}}; my $content = qq[ \=head1 LICENSE AND COPYRIGHT -Copyright $year $self->{author}. +Copyright $year $author_string. $license_blurb ]; @@ -1775,11 +1787,12 @@ sub module_guts { my $rtname = shift; # Sub-templates - my $header = $self->_module_header($module, $rtname); - my $bugs = $self->_module_bugs($module, $rtname); - my $support = $self->_module_support($module, $rtname); - my $license = $self->_module_license($module, $rtname); - + my $header = $self->_module_header($module, $rtname); + my $bugs = $self->_module_bugs($module, $rtname); + my $support = $self->_module_support($module, $rtname); + my $license = $self->_module_license($module, $rtname); + my $author_string = join ',', @{$self->{author}}; + my $content = <<"HERE"; $header @@ -1817,7 +1830,7 @@ sub function2 { \=head1 AUTHOR -$self->{author}, C<< <$self->{email_obfuscated}> >> +$author_string $bugs diff --git a/t/test-dist.t b/t/test-dist.t index 38ab5f3..d72af21 100644 --- a/t/test-dist.t +++ b/t/test-dist.t @@ -506,7 +506,6 @@ sub parse_paras { local $Test::Builder::Level = $Test::Builder::Level + 1; my ($self, $paras, $msg) = @_; - # Construct a large regex. my $regex = join '', @@ -545,8 +544,7 @@ sub parse_file_start { my $slname = $LICENSES->{ $self->{license} }->{slname}; my $license_url = $LICENSES->{ $self->{license} }->{url}; - - (my $authoremail = "$self->{author} <$self->{email}>") =~ s/'/\'/g; + (my $libmod = "lib/$mainmod".'.pm') =~ s|::|/|g; my $install_pl = $self->{builder} eq 'Module::Build' ? 'Build.PL' : 'Makefile.PL'; @@ -594,6 +592,9 @@ sub parse_file_start { } elsif ($basefn eq 'Build.PL' && $self->{builder} eq 'Module::Build') { plan tests => 11; + my $authoremail = join ',', map { "'$_'" } @{$self->{author}}; + $authoremail =~ s/'/\'/g; + $self->parse($mswb_re, "Min/Strict/Warning/Builder" ); @@ -606,7 +607,7 @@ sub parse_file_start { "license", ); - $self->parse(qr{\A\s*dist_author *=> *\Qq{$authoremail},\E\n}ms, + $self->parse(qr{\A\s*dist_author *=> *\Q[$authoremail],\E\n}ms, "dist_author", ); @@ -645,6 +646,9 @@ sub parse_file_start { } elsif ($basefn eq 'Makefile.PL' && $self->{builder} eq 'ExtUtils::MakeMaker') { plan tests => 11; + my $authoremail = join ',', map { "'$_'" } @{$self->{author}}; + $authoremail =~ s/'/\'/g; + $self->parse($mswb_re, "Min/Strict/Warning/Builder" ); @@ -653,7 +657,7 @@ sub parse_file_start { "NAME", ); - $self->parse(qr{\A\s*AUTHOR *=> *\Qq{$authoremail},\E\n}ms, + $self->parse(qr{\A\s*AUTHOR *=> *\Q[$authoremail],\E\n}ms, "AUTHOR", ); @@ -693,7 +697,12 @@ sub parse_file_start { ); } elsif ($basefn eq 'Makefile.PL' && $self->{builder} eq 'Module::Install') { - plan tests => 13; + plan tests => 13; + # do not quote authoremail combinations for Module::Install since + # author is a string not an arrayref + my $authoremail = join ',', @{$self->{author}}; + $authoremail =~ s/'/\'/g; + $self->parse($mswb_re, "Min/Strict/Warning/Builder" ); @@ -722,13 +731,15 @@ sub parse_file_start { "tests_recursive", ); + my $repo_author = $self->{author}->[0]; + ($repo_author) = (split /\s*\consume(<<"EOT", 'resources'); resources ( #homepage => 'http://yourwebsitehere.com', #IRC => 'irc://irc.perl.org/#$distro', license => '$license_url', - #repository => 'git://github.com/$self->{author}/$distro.git', - #repository => 'https://bitbucket.org/$self->{author}/$self->{distro}', + #repository => 'git://github.com/$repo_author/$distro.git', + #repository => 'https://bitbucket.org/$repo_author/$self->{distro}', bugtracker => 'http://rt.cpan.org/NoAuth/Bugs.html?Dist=$distro', ); @@ -1046,7 +1057,7 @@ sub parse_module_start { my $perl_name = $self->{module}; my $dist_name = $self->{distro}; - my $author_name = $self->{author}; + my $author_name = join ',', @{$self->{author}}; my $lc_dist_name = lc($dist_name); my $minperl = $self->{minperl} || 5.006; @@ -1121,7 +1132,7 @@ sub parse_module_start { $self->parse_paras( [ "=head1 AUTHOR", - { re => quotemeta($author_name) . q{[^\n]+} }, + { re => quotemeta($author_name) }, ], "AUTHOR", ); @@ -1239,6 +1250,7 @@ srand($random_seed); sub run_settest { my ($base_dir, $distro_var) = @_; + my $module_base_dir = File::Spec->catdir(qw(t data), ref $base_dir ? @$base_dir : $base_dir); $distro_var->{dir} = $module_base_dir; @@ -1345,8 +1357,10 @@ run_settest('MyModule-Test', { modules => ['MyModule::Test', 'MyModule::Test::App'], builder => 'Module::Build', license => 'artistic2', - author => 'Baruch Spinoza', - email => 'spinoza@philosophers.tld', + author => [ + 'Baruch Spinoza ', + 'Sandra OConnor ' + ], verbose => 0, force => $DONT_DEL, }); @@ -1361,8 +1375,7 @@ run_settest('Book-Park-Mansfield', { ], builder => 'Module::Build', license => 'artistic2', - author => 'Jane Austen', - email => 'jane.austen@writers.tld', + author => [ 'Jane Austen ' ], verbose => 0, force => $DONT_DEL, }); @@ -1409,7 +1422,8 @@ subtest "builder = $builder" => sub { my $distro = join('-', rstr_array); my $author = rstr.' '.rstr; my $email = join('.', rstr_array).'@'.join('.', rstr_array).'.tld'; - + $author .= ' <$email>'; + my @modules; my $len = int(rand(20)) + 1; push(@modules, rstr_module ) for (1 .. $len); @@ -1430,8 +1444,7 @@ subtest "builder = $builder" => sub { modules => \@modules, builder => $builder, license => $license, - author => $author, - email => $email, + author => [ $author ], minperl => $minperl, verbose => 0, force => $force,