From 1559000f0e222990210c6dabae6c6c859b2a93d8 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Sun, 12 Feb 2012 15:26:15 -0600 Subject: use a much more sane way of providing meta resources --- dist.ini | 2 +- lib/Dist/Zilla/PluginBundle/DOY.pm | 115 ++++++++++++++++++++++++++++++++----- 2 files changed, 103 insertions(+), 14 deletions(-) diff --git a/dist.ini b/dist.ini index a8ff915..12b0f22 100644 --- a/dist.ini +++ b/dist.ini @@ -5,6 +5,7 @@ copyright_holder = Jesse Luehrs [@DOY] dist = Dist-Zilla-PluginBundle-DOY +repository = github [Prereqs] Dist::Zilla::Plugin::CheckChangesHasContent = 0 @@ -15,4 +16,3 @@ Dist::Zilla::Plugin::MakeMaker::Awesome = 0 Dist::Zilla::Plugin::Metadata = 0 Dist::Zilla::Plugin::NoTabsTests = 0 Dist::Zilla::Plugin::PodWeaver = 0 -Dist::Zilla::Plugin::Repository = 0.16 diff --git a/lib/Dist/Zilla/PluginBundle/DOY.pm b/lib/Dist/Zilla/PluginBundle/DOY.pm index 82ffa9c..494d30d 100644 --- a/lib/Dist/Zilla/PluginBundle/DOY.pm +++ b/lib/Dist/Zilla/PluginBundle/DOY.pm @@ -62,6 +62,95 @@ has authority => ( default => 'cpan:DOY', ); +has github_user => ( + is => 'ro', + isa => 'Str', + default => 'doy', +); + +has github_name => ( + is => 'ro', + isa => 'Str', + lazy => 1, + default => sub { lc shift->dist }, +); + +has repository => ( + is => 'ro', + isa => 'Str', +); + +for my $attr (qw(repository_type repository_url repository_web)) { + has $attr => ( + is => 'ro', + isa => 'Maybe[Str]', + lazy => 1, + default => sub { + my $self = shift; + my $data = $self->_repository_data; + return unless $data; + return $data->{$attr}; + }, + ); +} + +sub _repository_data { + my $self = shift; + + my $host = $self->repository; + return unless defined $host; + + die "Unknown repository host $host" + unless exists $self->_repository_host_map->{$host}; + + return $self->_repository_host_map->{$host}; +} + +has _repository_host_map => ( + is => 'ro', + isa => 'HashRef[HashRef[Str]]', + lazy => 1, + default => sub { + my $self = shift; + return { + 'github' => { + repository_type => 'git', + repository_url => sprintf('git://github.com/%s/%s.git', $self->github_user, $self->github_name), + repository_web => sprintf('https://github.com/%s/%s', $self->github_user, $self->github_name), + }, + 'gitmo' => { + repository_type => 'git', + repository_url => sprintf('git://git.moose.perl.org/%s.git', $self->dist), + repository_web => sprintf('http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo/%s.git;a=summary', $self->dist), + }, + } + }, +); + +has bugtracker_web => ( + is => 'ro', + isa => 'Str', + lazy => 1, + default => sub { + sprintf('http://rt.cpan.org/Public/Dist/Display.html?Name=%s', + shift->dist); + }, +); + +has bugtracker_mailto => ( + is => 'ro', + isa => 'Str', + lazy => 1, + default => sub { sprintf('bug-%s@rt.cpan.org', lc shift->dist); }, +); + +has homepage => ( + is => 'ro', + isa => 'Str', + lazy => 1, + default => sub { sprintf('http://metacpan.org/release/%s', shift->dist) }, +); + has awesome => ( is => 'ro', isa => 'Str', @@ -93,15 +182,6 @@ has is_test_dist => ( has git_remote => ( is => 'ro', isa => 'Str', - lazy => 1, - default => sub { - my $self = shift; - return '' unless -d '.git'; - my @remotes = `git remote`; - chomp @remotes; - return 'github' if any { $_ eq 'github' } @remotes; - return 'origin'; - }, ); has _plugins => ( @@ -138,8 +218,8 @@ has _plugins => ( NoTabsTests EOLTests Test::Compile - Repository Metadata + MetaResources Git::Check Git::Commit Git::Tag @@ -160,9 +240,6 @@ has plugin_options => ( my $self = shift; my %opts = ( 'NextRelease' => { format => '%-5v %{yyyy-MM-dd}d' }, - 'Repository' => { - git_remote => $self->git_remote, - }, 'Authority' => { authority => $self->authority }, 'Git::Check' => { allow_dirty => '' }, 'Git::Tag' => { tag_format => '%v', tag_message => '' }, @@ -179,6 +256,18 @@ has plugin_options => ( dynamic_config => 1, } if $self->dynamic_config; + for my $metaresource (qw(repository.type repository.url repository.web bugtracker.web bugtracker.mailto homepage)) { + (my $method = $metaresource) =~ s/\./_/g; + my $value = $self->$method; + if (!$value) { + warn "*** resources.$metaresource is not configured! This needs to be fixed! ***"; + next; + } + $opts{MetaResources}{$metaresource} = $value; + } + delete $opts{MetaResources}{'repository.type'} + unless exists $opts{MetaResources}{'repository.url'}; + for my $option (keys %{ $self->payload }) { next unless $option =~ /^([A-Z][^_]*)_(.+)$/; my ($plugin, $plugin_option) = ($1, $2); -- cgit v1.2.3-54-g00ecf