[libdist-zilla-plugin-githubmeta-perl] 01/02: Initial commit
Axel Beckert
abe at deuxchevaux.org
Sun Apr 26 22:25:33 UTC 2015
This is an automated email from the git hooks/post-receive script.
abe pushed a commit to annotated tag 0.02
in repository libdist-zilla-plugin-githubmeta-perl.
commit 60d0509598d3248ff4fac5b4f3021f08ee44d39e
Author: Chris 'BinGOs' Williams <chris at bingosnet.co.uk>
Date: Thu Jun 10 10:23:13 2010 +0100
Initial commit
---
dist.ini | 23 +++++++
lib/Dist/Zilla/Plugin/GithubMeta.pm | 132 ++++++++++++++++++++++++++++++++++++
t/00_compile.t | 4 ++
3 files changed, 159 insertions(+)
diff --git a/dist.ini b/dist.ini
new file mode 100644
index 0000000..370e0ac
--- /dev/null
+++ b/dist.ini
@@ -0,0 +1,23 @@
+name = Dist-Zilla-Plugin-GithubMeta
+version = 0.02
+author = Chris Williams <chris at bingosnet.co.uk>
+license = Perl_5
+copyright_holder = Chris Williams and Tatsuhiko Miyagawa
+
+[@Basic]
+
+[MetaJSON]
+[PodSyntaxTests]
+[PodCoverageTests]
+
+[GithubMeta]
+
+[ChangelogFromGit]
+file_name = Changes
+
+[Prereq]
+Dist::Zilla = 4.101582
+Dist::Zilla::Role::MetaProvider = 4.101582
+IPC::Cmd = 0.58
+Moose = 1.07
+MooseX::Types::URI = 0.02
diff --git a/lib/Dist/Zilla/Plugin/GithubMeta.pm b/lib/Dist/Zilla/Plugin/GithubMeta.pm
new file mode 100644
index 0000000..36e7b7e
--- /dev/null
+++ b/lib/Dist/Zilla/Plugin/GithubMeta.pm
@@ -0,0 +1,132 @@
+package Dist::Zilla::Plugin::GithubMeta;
+
+BEGIN {
+ $Dist::Zilla::Plugin::GithubMeta::VERSION = '0.02';
+}
+
+# ABSTRACT: Automatically include GitHub meta information in META.yml
+
+use Moose;
+with 'Dist::Zilla::Role::MetaProvider';
+
+use MooseX::Types::URI qw[Uri];
+use Cwd;
+use IPC::Cmd qw[can_run];
+
+has 'homepage' => (
+ is => 'ro',
+ isa => Uri,
+ coerce => 1,
+);
+
+sub metadata {
+ my $self = shift;
+ return unless _under_git();
+ return unless can_run('git');
+ return unless my ($git_url) = `git remote show -n origin` =~ /URL: (.*)$/m;
+ return unless $git_url =~ /github\.com/; # Not a Github repository
+ my $homepage;
+ if ( $self->homepage ) {
+ $homepage = $self->homepage->as_string;
+ }
+ else {
+ $homepage = $git_url;
+ $homepage =~ s![\w\-]+\@([^:]+):!http://$1/!;
+ $homepage =~ s!\.git$!/tree!;
+ }
+ $git_url =~ s![\w\-]+\@([^:]+):!git://$1/!;
+ return { resources => { repository => { url => $git_url }, homepage => $homepage } };
+}
+
+
+sub _under_git {
+ return 1 if -e '.git';
+ my $cwd = getcwd;
+ my $last = $cwd;
+ my $found = 0;
+ while (1) {
+ chdir '..' or last;
+ my $current = getcwd;
+ last if $last eq $current;
+ $last = $current;
+ if ( -e '.git' ) {
+ $found = 1;
+ last;
+ }
+ }
+ chdir $cwd;
+ return $found;
+}
+
+__PACKAGE__->meta->make_immutable;
+no Moose;
+
+qq[1 is the loneliest number]
+
+__END__
+
+=head1 NAME
+
+Dist::Zilla::Plugin::GithubMeta - Automatically include GitHub meta information in META.yml
+
+=head1 SYNOPSIS
+
+ # in dist.ini
+
+ [GithubMeta]
+
+ # to override the homepage
+
+ [GithubMeta]
+ homepage = http://some.sort.of.url/project/
+
+=head1 DESCRIPTION
+
+Dist::Zilla::Plugin::GithubMeta is a L<Dist::Zilla> plugin to include GitHub L<http://github.com> meta
+information in C<META.yml>.
+
+It automatically detects if the distribution directory is under C<git> version control and whether the
+C<origin> is a GitHub repository and will set the C<repository> and C<homepage> meta in C<META.yml> to the
+appropriate URLs for GitHub.
+
+=head2 ATTRIBUTES
+
+=over
+
+=item C<homepage>
+
+You may override the C<homepage> setting by specifying this attribute. This should be a valid URL as
+understood by L<MooseX::Types::URI>.
+
+=back
+
+=head2 METHODS
+
+=over
+
+=item C<metadata>
+
+Required by L<Dist::Zilla::Role::MetaProvider>
+
+=back
+
+=head1 AUTHOR
+
+Chris C<BinGOs> Williams
+
+Based on L<Module::Install::GithubMeta> which was based on
+L<Module::Install::Repository> by Tatsuhiko Miyagawa
+
+=head1 LICENSE
+
+Copyright E<copy> Chris Williams and Tatsuhiko Miyagawa
+
+This module may be used, modified, and distributed under the same terms as Perl itself. Please see the license that came with your Perl distribution for details.
+
+=head1 SEE ALSO
+
+L<Dist::Zilla>
+
+L<MooseX::Types::URI>
+
+=cut
diff --git a/t/00_compile.t b/t/00_compile.t
new file mode 100644
index 0000000..4832d8e
--- /dev/null
+++ b/t/00_compile.t
@@ -0,0 +1,4 @@
+use strict;
+use warnings;
+use Test::More qw[no_plan];
+use_ok('Dist::Zilla::Plugin::GithubMeta');
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libdist-zilla-plugin-githubmeta-perl.git
More information about the Pkg-perl-cvs-commits
mailing list