Skip Menu |

This queue is for tickets about the Pod-Coverage-Moose CPAN distribution.

Report information
The Basics
Id: 71577
Status: resolved
Priority: 0/
Queue: Pod-Coverage-Moose

People
Owner: Nobody in particular
Requestors: mmcleric [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: (no value)
Fixed in: (no value)



Subject: [PATCH] cover_requires feature
Attached patch implements 'cover_requires' option, which allows the user to omit POD for a method which is required by a role. Option is off by default. If you prefer github, I put the code there too: https://github.com/berekuk/Pod-Coverage-Moose/commit/269718ab68108aa8808e6e4c57bf7a532c0b112e
Subject: cover_requires.patch
commit 269718ab68108aa8808e6e4c57bf7a532c0b112e Author: Vyacheslav Matyukhin <mmcleric@yandex-team.ru> Date: Mon Oct 10 20:42:58 2011 +0400 cover_requires feature diff --git a/lib/Pod/Coverage/Moose.pm b/lib/Pod/Coverage/Moose.pm index 13f13c6..ede224d 100644 --- a/lib/Pod/Coverage/Moose.pm +++ b/lib/Pod/Coverage/Moose.pm @@ -50,6 +50,18 @@ has package => ( required => 1, ); +=head2 cover_requires + +Boolean flag to indicate that C<requires $method> declarations in a Role should be trusted. + +=cut + +has cover_requires => ( + is => 'ro', + isa => 'Bool', + default => 0, +); + # # original pod_coverage object # @@ -91,6 +103,7 @@ sub BUILD { map { # iterate over all roles of the class my $role = $_; $role->get_method_list, + ($self->cover_requires ? ($role->get_required_method_list) : ()), map { # iterate over attributes my $attr = $role->get_attribute($_); ($attr->{is} && $attr->{is} eq any(qw( rw ro wo )) ? $_ : ()), # accessors diff --git a/t/20_cover_requires.t b/t/20_cover_requires.t new file mode 100644 index 0000000..67728f1 --- /dev/null +++ b/t/20_cover_requires.t @@ -0,0 +1,18 @@ +#!/usr/bin/perl +use warnings; +use strict; + +use FindBin; +use lib "$FindBin::Bin/lib"; +use Test::More 'no_plan'; + +use_ok 'TestCoverRequires_Consumer', 'consumer test class loaded ok'; +use_ok 'Pod::Coverage::Moose', 'pcm loaded ok'; + +my $pcm = Pod::Coverage::Moose->new(package => 'TestCoverRequires_Consumer', cover_requires => 1); +isa_ok $pcm, 'Pod::Coverage::Moose', + 'Moose package coverage object'; + +is_deeply [sort $pcm->covered], [qw( bar foo )], 'methods from role are covered'; +is_deeply [sort $pcm->uncovered], [qw( baz )], 'new method is not covered'; + diff --git a/t/lib/TestCoverRequires.pm b/t/lib/TestCoverRequires.pm new file mode 100644 index 0000000..a1ab90d --- /dev/null +++ b/t/lib/TestCoverRequires.pm @@ -0,0 +1,10 @@ +package TestCoverRequires; + +use Moose::Role; +use namespace::clean -except => 'meta'; + +sub foo { } + +requires 'bar'; + +1; diff --git a/t/lib/TestCoverRequires_Consumer.pm b/t/lib/TestCoverRequires_Consumer.pm new file mode 100644 index 0000000..0e153ee --- /dev/null +++ b/t/lib/TestCoverRequires_Consumer.pm @@ -0,0 +1,20 @@ +package TestCoverRequires_Consumer; + +=head1 NAME + +TestCoverRequires_Consumer - consume role with some methods, override some and define some more + +=cut + +use Moose; +use namespace::clean -except => 'meta'; + +with 'TestCoverRequires'; + +sub foo { } + +sub bar { } + +sub baz { } + +1;
Merged and released in 0.03.