From 6fad5906e1d1f27d2eca0bd9fe77931282616ea8 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Tue, 15 Jun 2010 10:35:41 -0500 Subject: allow passing in sub-options --- lib/Dist/Zilla/PluginBundle/DOY.pm | 77 ++++++++++++++++++++++++++++++-------- 1 file changed, 61 insertions(+), 16 deletions(-) (limited to 'lib') diff --git a/lib/Dist/Zilla/PluginBundle/DOY.pm b/lib/Dist/Zilla/PluginBundle/DOY.pm index 779bcf7..005d3be 100644 --- a/lib/Dist/Zilla/PluginBundle/DOY.pm +++ b/lib/Dist/Zilla/PluginBundle/DOY.pm @@ -81,6 +81,65 @@ has github_url => ( }, ); +has extra_plugins => ( + is => 'ro', + isa => 'ArrayRef[Str]', + init_arg => undef, + lazy => 1, + default => sub { + my $self = shift; + [ + 'MetaConfig', + 'MetaJSON', + 'NextRelease', + 'CheckChangesHasContent', + 'PkgVersion', + 'PodCoverageTests', + 'PodSyntaxTests', + 'NoTabsTests', + 'EOLTests', + 'CompileTests', + 'Repository', + 'Git::Check', + 'Git::Tag', + 'BumpVersionFromGit', + $self->is_task ? 'TaskWeaver' : 'PodWeaver', + ] + }, +); + +has plugin_options => ( + is => 'ro', + isa => 'HashRef[HashRef[Str]]', + init_arg => undef, + lazy => 1, + default => sub { + my $self = shift; + my %opts = ( + 'NextRelease' => { format => '%-5v %{yyyy-MM-dd}d' }, + 'Repository' => { + git_remote => $self->github_url, + github_http => 0 + }, + 'Git::Check' => { allow_dirty => '' }, + 'Git::Tag' => { tag_format => '%v', tag_message => '' }, + 'BumpVersionFromGit' => { + version_regexp => '^(\d+\.\d+)$', + first_version => '0.01' + }, + ); + + for my $option (keys %{ $self->payload }) { + next unless $option =~ /^([A-Z][^_]*)_(.+)$/; + my ($plugin, $plugin_option) = ($1, $2); + $opts{$plugin} ||= {}; + $opts{$plugin}->{$plugin_option} = $self->payload->{$option}; + } + + return \%opts; + }, +); + around BUILDARGS => sub { my $orig = shift; my $class = shift; @@ -102,23 +161,9 @@ sub configure { } $self->add_plugins( - 'MetaConfig', - 'MetaJSON', - ['NextRelease' => { format => '%-5v %{yyyy-MM-dd}d' }], - 'CheckChangesHasContent', - 'PkgVersion', - 'PodCoverageTests', - 'PodSyntaxTests', - 'NoTabsTests', - 'EOLTests', - 'CompileTests', - ['Repository' => { git_remote => $self->github_url, github_http => 0 }], - ['Git::Check' => { allow_dirty => '' }], - ['Git::Tag' => { tag_format => '%v', tag_message => '' }], - ['BumpVersionFromGit' => { version_regexp => '^(\d+\.\d+)$', first_version => '0.01'}], + map { [ $_ => ($self->plugin_options->{$_} || {}) ] } + @{ $self->extra_plugins }, ); - - $self->add_plugins($self->is_task ? 'TaskWeaver' : 'PodWeaver'); } =head1 SEE ALSO -- cgit v1.2.3-54-g00ecf