| 1 | package Dist::Zilla::Plugin::ATOOMIC::Contributors; | ||
| 2 | |||
| 3 | use v5.10; | ||
| 4 | |||
| 5 | use strict; | ||
| 6 | use warnings; | ||
| 7 | use autodie; | ||
| 8 | use namespace::autoclean; | ||
| 9 | |||
| 10 | our $VERSION = '1.00'; | ||
| 11 | |||
| 12 | use Moose; | ||
| 13 | |||
| 14 | with 'Dist::Zilla::Role::BeforeBuild'; | ||
| 15 | |||
| 16 | my $mailmap = <<'EOF'; | ||
| 17 | Nicolas R <atoomic@cpan.org> <devnull@localhost> | ||
| 18 | EOF | ||
| 19 | |||
| 20 | my %files = ( | ||
| 21 | '.mailmap' => $mailmap, | ||
| 22 | ); | ||
| 23 | |||
| 24 | # These files need to actually exist on disk for the Pod::Weaver plugin to see | ||
| 25 | # them, so we can't simply add them as InMemory files via file injection. | ||
| 26 | sub before_build { | ||
| 27 | my $self = shift; | ||
| 28 | |||
| 29 | for my $file ( keys %files ) { | ||
| 30 | next if -e $file; | ||
| 31 | |||
| 32 | open my $fh, '>:encoding(UTF-8)', $file; | ||
| 33 | print {$fh} $files{$file} | ||
| 34 | or die "Cannot write to $files{$file}: $!"; | ||
| 35 | close $fh; | ||
| 36 | } | ||
| 37 | |||
| 38 | return; | ||
| 39 | } | ||
| 40 | |||
| 41 | __PACKAGE__->meta->make_immutable; | ||
| 42 | |||
| 43 | 1; | ||
| 44 | |||
| 45 | # ABSTRACT: Creates a .mailmap to populate Contributors in docs | ||
| 46 | |||
| 47 | __END__ |