| 1 | package Dist::Zilla::Plugin::DROLSKY::BundleAuthordep; | ||
| 2 | |||
| 3 | use v5.10; | ||
| 4 | |||
| 5 | use strict; | ||
| 6 | use warnings; | ||
| 7 | use autodie; | ||
| 8 | use namespace::autoclean; | ||
| 9 | |||
| 10 | our $VERSION = '1.25'; | ||
| 11 | |||
| 12 | use Path::Tiny qw( path ); | ||
| 13 | |||
| 14 | use Moose; | ||
| 15 | |||
| 16 | with 'Dist::Zilla::Role::BeforeBuild'; | ||
| 17 | |||
| 18 | # These files need to actually exist on disk for the Pod::Weaver plugin to see | ||
| 19 | # them, so we can't simply add them as InMemory files via file injection. | ||
| 20 | sub before_build { | ||
| 21 | my $self = shift; | ||
| 22 | |||
| 23 | my $dist_ini = path('dist.ini'); | ||
| 24 | my $content = $dist_ini->slurp_utf8; | ||
| 25 | my ($v) | ||
| 26 | = $content | ||
| 27 | =~ /; authordep Dist::Zilla::PluginBundle::DROLSKY = ([0-9]+\.[0-9]+)/; | ||
| 28 | |||
| 29 | return if $v && $v == $VERSION; | ||
| 30 | |||
| 31 | if ($v) { | ||
| 32 | $content | ||
| 33 | =~ s/(; authordep Dist::Zilla::PluginBundle::DROLSKY = )\Q$v\E/$1$VERSION/; | ||
| 34 | } | ||
| 35 | else { | ||
| 36 | $content | ||
| 37 | =~ s/(\[\@DROLSKY\])/; authordep Dist::Zilla::PluginBundle::DROLSKY = $VERSION\n$1/; | ||
| 38 | } | ||
| 39 | |||
| 40 | $dist_ini->spew_utf8($content); | ||
| 41 | |||
| 42 | return; | ||
| 43 | } | ||
| 44 | |||
| 45 | __PACKAGE__->meta->make_immutable; | ||
| 46 | |||
| 47 | 1; | ||
| 48 | |||
| 49 | # ABSTRACT: Sets an authordep on this bundle in the dist.ini | ||
| 50 | |||
| 51 | __END__ |