Subject: | [PATCH] Add support for 'resources' |
Hi, I saw that search.cpan.org has support for some more metadata,
http://perlbuzz.com/2007/12/updated-distribution-metainformation-available-at.html
So I wrote the attached patch.
Subject: | 0001-Add-support-for-the-resources-META.yml-key.patch |
From e581c70c41fc9f6c93affbe94e7a22f16debcb8e Mon Sep 17 00:00:00 2001
From: Sam Vilain <sam@vilain.net>
Date: Wed, 26 Dec 2007 23:24:34 +1300
Subject: [PATCH] Add support for the 'resources' META.yml key
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="------------1.5.3.7.2095.gb2448-dirty"
This is a multi-part message in MIME format.
--------------1.5.3.7.2095.gb2448-dirty
Content-Type: text/plain; charset=UTF-8; format=fixed
Content-Transfer-Encoding: 8bit
The "resources" key was added in the META.yml specification at version
1.2 or earlier. Add support and documentation for this, including a
section to the main manual page entry.
---
lib/Module/Install.pod | 42 +++++++++++++++++++++++++++++++++-
lib/Module/Install/Admin/Metadata.pm | 4 +++
lib/Module/Install/Metadata.pm | 16 +++++++++++++
3 files changed, 61 insertions(+), 1 deletions(-)
--------------1.5.3.7.2095.gb2448-dirty
Content-Type: text/x-patch; name="e581c70c41fc9f6c93affbe94e7a22f16debcb8e.diff"
Content-Transfer-Encoding: 8bit
Content-Disposition: attachment; filename="e581c70c41fc9f6c93affbe94e7a22f16debcb8e.diff"
diff --git a/lib/Module/Install.pod b/lib/Module/Install.pod
index 3fdfc60..5b46307 100644
--- a/lib/Module/Install.pod
+++ b/lib/Module/Install.pod
@@ -20,7 +20,13 @@ In your F<Makefile.PL>: (Recommended Usage)
requires 'File::Spec' => '0.80';
build_requires 'Test::More' => '0.42';
recommends 'Your::OtherModule' => '0.01';
-
+ resources
+ license => "http://dev.perl.org/licenses",
+ homepage => "http://yourproject.host.org",
+ bugtracker => "http://rt.cpan.org/NoAuth/Bugs.html?Dist=Foo-Bar",
+ repository => "http://yourhost.com/myscm",
+ MailingList => "http://yourhost.com/listinfo/foo-bar";
+
no_index 'directory' => 'demos';
install_script 'bin/myscript';
@@ -383,6 +389,40 @@ you and do not require a command.
To summarise, if you can see it on L<http://search.cpan.org/> and you
shouldn't be able to, you need a C<no_index> entry.
+=head2 resources
+
+ resources
+ license => "http://dev.perl.org/licenses",
+ homepage => "http://yourproject.host.org",
+ bugtracker => "http://rt.cpan.org/NoAuth/Bugs.html?Dist=Foo-Bar",
+ repository => "http://yourhost.com/myscm",
+ MailingList => "http://yourhost.com/listinfo/foo-bar",
+ SVN => "http://svn.foo.com/repos/Foo-bar",
+ ViewVC => "http://foo-bar.svn.sourceforge.net/viewvc/foo-bar",
+ Git => "http://git.foo.com/Foo-bar.git",
+ GitWeb => "http://git.foo.com/gitweb.cgi?p=Foo-bar.git",
+ Mercurial => "http://hg.foo.com/repo/Foo-bar",
+ Bzr => "http://foo-bar.launchpad.net/~foobar/foo-bar/trunk",
+ Darcs => "http://darcs.foo.com/Foo-bar",
+
+ LaunchPad => "https://code.launchpad.net/foobar";
+
+The C<resources> section is for URLs that are related to the release
+in some way.
+
+The specification for META.yml requires that all non-standard resource
+definitions be spelt with some uppercase letters (LikeThis). This
+module warns if any unknown, reserved resource names are given. In
+lieu of further standards settling, this author recommends use of the
+above keys, where they fit.
+
+Note the key C<repository> is shown in the example of version 1.3 of
+the specification (see
+L<http://module-build.sourceforge.net/META-spec-v1.3.html#resources>).
+So, Module::Install permits it. A good idea to put in here is the URL
+of the source repository that is used for active development of the
+module.
+
=head2 WriteAll
The C<WriteAll> command is generally the last command; it writes out
diff --git a/lib/Module/Install/Admin/Metadata.pm b/lib/Module/Install/Admin/Metadata.pm
index 5ca6e4c..cb864b1 100644
--- a/lib/Module/Install/Admin/Metadata.pm
+++ b/lib/Module/Install/Admin/Metadata.pm
@@ -109,6 +109,10 @@ sub dump_meta {
$dump{no_index} = $no_index;
$dump{generated_by} = "$package version $version";
+ if ( $values{resources} ) {
+ $dump{resources} = $values{resources};
+ }
+
# Add mention of the META spec
$dump{"meta-spec"} = {
version => 1.3,
diff --git a/lib/Module/Install/Metadata.pm b/lib/Module/Install/Metadata.pm
index 6dab4ce..35597cb 100644
--- a/lib/Module/Install/Metadata.pm
+++ b/lib/Module/Install/Metadata.pm
@@ -332,4 +332,20 @@ sub license_from {
return 'unknown';
}
+my $valid_resources = qr{^(homepage|license|bugtracker|repository)$};
+
+sub resources {
+ my $self = shift;
+ my %args = (@_ == 1 ? %{$_[0]} : @_);
+
+ $DB::single = 1;
+ my $resources = $self->Meta->{"values"}{resources} ||= {};
+ while ( my ($arg, $val) = each %args ) {
+ if ( lc $arg eq $arg and $arg !~ m{$valid_resources} ) {
+ warn "resource type '$arg' is reserved by the META-spec\n";
+ }
+ $resources->{$arg} = $val;
+ }
+}
+
1;
--------------1.5.3.7.2095.gb2448-dirty--