Subject: | allow package to include its own trust/private data |
I hate having to put, in my pod-coverage.t, the trustme and private
information. I'd rather put it in each package.
Attached is a patch that implements this feature. Test included.
--
rjbs
Subject: | trust_package.patch |
diff -Nur Pod-Coverage-0.17/lib/Pod/Coverage.pm Pod-Coverage-rjbs/lib/Pod/Coverage.pm
--- Pod-Coverage-0.17/lib/Pod/Coverage.pm 2004-11-23 09:21:56.000000000 -0500
+++ Pod-Coverage-rjbs/lib/Pod/Coverage.pm 2006-07-13 19:16:58.000000000 -0400
@@ -94,6 +94,12 @@
my %args = @_;
my $class = ref $referent || $referent;
+ if ($args{trust_package}) {
+ no strict 'refs';
+ my $pkg_config = ${"$args{package}\::POD_COVERAGE"};
+ $args{$_} = $pkg_config->{$_} for keys %$pkg_config;
+ }
+
my $private = $args{private} || [
qr/^_/,
qr/^import$/,
diff -Nur Pod-Coverage-0.17/t/09trustpkg.t Pod-Coverage-rjbs/t/09trustpkg.t
--- Pod-Coverage-0.17/t/09trustpkg.t 1969-12-31 19:00:00.000000000 -0500
+++ Pod-Coverage-rjbs/t/09trustpkg.t 2006-07-13 19:17:12.000000000 -0400
@@ -0,0 +1,17 @@
+#!/usr/bin/perl -w
+use strict;
+use Test::More tests => 6;
+use lib 't/lib';
+
+BEGIN {
+ use_ok( 'Pod::Coverage' );
+ use_ok( 'Pod::Coverage::ExportOnly' );
+}
+
+my $obj = new Pod::Coverage package => 'PkgConfig';
+isa_ok( $obj, 'Pod::Coverage' );
+is($obj->coverage, 3/7, "without private or trustme it gets it right");
+
+$obj = new Pod::Coverage package => 'PkgConfig', trust_package => 1;
+isa_ok( $obj, 'Pod::Coverage' );
+is($obj->coverage, 5/6, "with just private it gets it right");
diff -Nur Pod-Coverage-0.17/t/lib/PkgConfig.pm Pod-Coverage-rjbs/t/lib/PkgConfig.pm
--- Pod-Coverage-0.17/t/lib/PkgConfig.pm 1969-12-31 19:00:00.000000000 -0500
+++ Pod-Coverage-rjbs/t/lib/PkgConfig.pm 2006-07-13 19:15:11.000000000 -0400
@@ -0,0 +1,46 @@
+package PkgConfig;
+
+# test module - four subs, one with embedded pod item, one with a head2, one
+# with a method call, one with nowt
+# ...and package variable to provide trustme/private data
+
+our $POD_COVERAGE = {
+ private => [qr/^private$/],
+ trustme => [qr/u/]
+};
+
+sub foo {}
+sub bar {}
+sub baz {}
+sub naked {}
+sub private {}
+sub trustme {}
+sub trust_me {}
+
+
+1;
+__END__
+
+
+=head2 METHODS
+
+=over 4
+
+=item foo
+
+foo does foo to things
+
+=item bar
+
+bar does bar to things
+
+=item baz
+
+baz does baz to things
+
+=back
+
+This paragraph should be considered to be the docs for any
+method containing the letter u in its name.
+
+=cut