| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Pod::Coverage::Moose; # git description: v0.06-2-g7fc3173 | 
| 2 |  |  |  |  |  |  | # ABSTRACT: Pod::Coverage extension for Moose | 
| 3 |  |  |  |  |  |  | # KEYWORDS: pod coverage verification validity tests documentation completeness moose methods inheritance | 
| 4 |  |  |  |  |  |  | # vim: set ts=8 sts=4 sw=4 tw=115 et : | 
| 5 |  |  |  |  |  |  |  | 
| 6 |  |  |  |  |  |  | our $VERSION = '0.07'; | 
| 7 |  |  |  |  |  |  |  | 
| 8 | 4 |  |  | 4 |  | 445430 | use Moose; | 
|  | 4 |  |  |  |  | 833087 |  | 
|  | 4 |  |  |  |  | 25 |  | 
| 9 |  |  |  |  |  |  |  | 
| 10 | 4 |  |  | 4 |  | 24601 | use Pod::Coverage; | 
|  | 4 |  |  |  |  | 11 |  | 
|  | 4 |  |  |  |  | 126 |  | 
| 11 | 4 |  |  | 4 |  | 20 | use Carp            qw( croak ); | 
|  | 4 |  |  |  |  | 8 |  | 
|  | 4 |  |  |  |  | 264 |  | 
| 12 | 4 |  |  | 4 |  | 24 | use Class::Load qw( load_class ); | 
|  | 4 |  |  |  |  | 10 |  | 
|  | 4 |  |  |  |  | 167 |  | 
| 13 |  |  |  |  |  |  |  | 
| 14 | 4 |  |  | 4 |  | 1104 | use namespace::autoclean; | 
|  | 4 |  |  |  |  | 18249 |  | 
|  | 4 |  |  |  |  | 20 |  | 
| 15 |  |  |  |  |  |  |  | 
| 16 |  |  |  |  |  |  |  | 
| 17 |  |  |  |  |  |  | #pod =head1 SYNOPSIS | 
| 18 |  |  |  |  |  |  | #pod | 
| 19 |  |  |  |  |  |  | #pod   use Pod::Coverage::Moose; | 
| 20 |  |  |  |  |  |  | #pod | 
| 21 |  |  |  |  |  |  | #pod   my $pcm = Pod::Coverage::Moose->new(package => 'MoosePackage'); | 
| 22 |  |  |  |  |  |  | #pod   print 'Coverage: ', $pcm->coverage, "\n"; | 
| 23 |  |  |  |  |  |  | #pod | 
| 24 |  |  |  |  |  |  | #pod =head1 DESCRIPTION | 
| 25 |  |  |  |  |  |  | #pod | 
| 26 |  |  |  |  |  |  | #pod When using L<Pod::Coverage> in combination with L<Moose>, it will | 
| 27 |  |  |  |  |  |  | #pod report any method imported from a Role. This is especially bad when | 
| 28 |  |  |  |  |  |  | #pod used in combination with L<Test::Pod::Coverage>, since it takes away | 
| 29 |  |  |  |  |  |  | #pod its ease of use. | 
| 30 |  |  |  |  |  |  | #pod | 
| 31 |  |  |  |  |  |  | #pod To use this module in combination with L<Test::Pod::Coverage>, use | 
| 32 |  |  |  |  |  |  | #pod something like this: | 
| 33 |  |  |  |  |  |  | #pod | 
| 34 |  |  |  |  |  |  | #pod   use Test::Pod::Coverage; | 
| 35 |  |  |  |  |  |  | #pod   all_pod_coverage_ok({ coverage_class => 'Pod::Coverage::Moose'}); | 
| 36 |  |  |  |  |  |  | #pod | 
| 37 |  |  |  |  |  |  | #pod =head1 ATTRIBUTES | 
| 38 |  |  |  |  |  |  | #pod | 
| 39 |  |  |  |  |  |  | #pod =head2 package | 
| 40 |  |  |  |  |  |  | #pod | 
| 41 |  |  |  |  |  |  | #pod This is the package used for inspection. | 
| 42 |  |  |  |  |  |  | #pod | 
| 43 |  |  |  |  |  |  | #pod =cut | 
| 44 |  |  |  |  |  |  |  | 
| 45 |  |  |  |  |  |  | has package => ( | 
| 46 |  |  |  |  |  |  | is          => 'rw', | 
| 47 |  |  |  |  |  |  | isa         => 'Str', | 
| 48 |  |  |  |  |  |  | required    => 1, | 
| 49 |  |  |  |  |  |  | ); | 
| 50 |  |  |  |  |  |  |  | 
| 51 |  |  |  |  |  |  | #pod =head2 cover_requires | 
| 52 |  |  |  |  |  |  | #pod | 
| 53 |  |  |  |  |  |  | #pod Boolean flag to indicate that C<requires $method> declarations in a Role should be trusted. | 
| 54 |  |  |  |  |  |  | #pod | 
| 55 |  |  |  |  |  |  | #pod =cut | 
| 56 |  |  |  |  |  |  |  | 
| 57 |  |  |  |  |  |  | has cover_requires => ( | 
| 58 |  |  |  |  |  |  | is          => 'ro', | 
| 59 |  |  |  |  |  |  | isa         => 'Bool', | 
| 60 |  |  |  |  |  |  | default => 0, | 
| 61 |  |  |  |  |  |  | ); | 
| 62 |  |  |  |  |  |  |  | 
| 63 |  |  |  |  |  |  | # | 
| 64 |  |  |  |  |  |  | #   original pod_coverage object | 
| 65 |  |  |  |  |  |  | # | 
| 66 |  |  |  |  |  |  |  | 
| 67 |  |  |  |  |  |  | has _pod_coverage => ( | 
| 68 |  |  |  |  |  |  | is          => 'rw', | 
| 69 |  |  |  |  |  |  | isa         => 'Pod::Coverage', | 
| 70 |  |  |  |  |  |  | handles     => [qw( coverage why_unrated naked uncovered covered )], | 
| 71 |  |  |  |  |  |  | ); | 
| 72 |  |  |  |  |  |  |  | 
| 73 |  |  |  |  |  |  | #pod =head1 METHODS | 
| 74 |  |  |  |  |  |  | #pod | 
| 75 |  |  |  |  |  |  | #pod =head2 meta | 
| 76 |  |  |  |  |  |  | #pod | 
| 77 |  |  |  |  |  |  | #pod L<Moose> meta object. | 
| 78 |  |  |  |  |  |  | #pod | 
| 79 |  |  |  |  |  |  | #pod =head2 BUILD | 
| 80 |  |  |  |  |  |  | #pod | 
| 81 |  |  |  |  |  |  | #pod =for stopwords initialises | 
| 82 |  |  |  |  |  |  | #pod | 
| 83 |  |  |  |  |  |  | #pod Initialises the internal L<Pod::Coverage> object. It uses the meta object | 
| 84 |  |  |  |  |  |  | #pod to find all methods and attribute methods imported via roles. | 
| 85 |  |  |  |  |  |  | #pod | 
| 86 |  |  |  |  |  |  | #pod =cut | 
| 87 |  |  |  |  |  |  |  | 
| 88 |  |  |  |  |  |  | my %is = map { $_ => 1 } qw( rw ro wo ); | 
| 89 |  |  |  |  |  |  | sub BUILD { | 
| 90 | 3 |  |  | 3 | 1 | 4624 | my ($self, $args) = @_; | 
| 91 |  |  |  |  |  |  |  | 
| 92 | 3 |  |  |  |  | 150 | my $meta    = $self->package->meta; | 
| 93 | 3 | 50 |  |  |  | 66 | my @trustme = @{ $args->{trustme} || [] }; | 
|  | 3 |  |  |  |  | 26 |  | 
| 94 |  |  |  |  |  |  |  | 
| 95 | 3 |  |  |  |  | 38 | push @trustme, qr/^meta$/; | 
| 96 |  |  |  |  |  |  | push @trustme,                                          # MooseX-AttributeHelpers hack | 
| 97 | 0 |  |  |  |  | 0 | map  { qr/^$_$/ } | 
| 98 | 0 |  |  |  |  | 0 | map  { $_->name } | 
| 99 | 3 | 50 |  |  |  | 60 | grep { $_->isa('MooseX::AttributeHelpers::Meta::Method::Provided') } | 
|  | 50 |  |  |  |  | 4194 |  | 
| 100 |  |  |  |  |  |  | $meta->get_all_methods | 
| 101 |  |  |  |  |  |  | unless $meta->isa('Moose::Meta::Role'); | 
| 102 |  |  |  |  |  |  | push @trustme, | 
| 103 | 13 |  |  |  |  | 218 | map { qr/^\Q$_\E$/ }                                # turn value into a regex | 
| 104 |  |  |  |  |  |  | map {                                               # iterate over all roles of the class | 
| 105 | 3 |  |  |  |  | 22 | my $role = $_; | 
|  | 3 |  |  |  |  | 299 |  | 
| 106 |  |  |  |  |  |  | $role->get_method_list, | 
| 107 |  |  |  |  |  |  | ($self->cover_requires ? ($role->get_required_method_list) : ()), | 
| 108 |  |  |  |  |  |  | map {                                           # iterate over attributes | 
| 109 | 3 | 100 |  |  |  | 24 | my $attr = $role->get_attribute($_); | 
|  | 2 |  |  |  |  | 11 |  | 
| 110 |  |  |  |  |  |  | ($attr->{is} && $is{$attr->{is}} ? $_ : ()),  # accessors | 
| 111 | 2 | 100 | 66 |  |  | 20 | grep defined, map { $attr->{ $_ } }                             # other attribute methods | 
|  | 10 |  |  |  |  | 19 |  | 
| 112 |  |  |  |  |  |  | qw( clearer predicate reader writer accessor ); | 
| 113 |  |  |  |  |  |  | } $role->get_attribute_list, | 
| 114 |  |  |  |  |  |  | } | 
| 115 |  |  |  |  |  |  | $meta->calculate_all_roles; | 
| 116 |  |  |  |  |  |  |  | 
| 117 | 3 |  |  |  |  | 59 | $args->{trustme} = \@trustme; | 
| 118 |  |  |  |  |  |  |  | 
| 119 | 3 |  |  |  |  | 207 | $self->_pod_coverage(Pod::Coverage->new(%$args)); | 
| 120 |  |  |  |  |  |  | } | 
| 121 |  |  |  |  |  |  |  | 
| 122 |  |  |  |  |  |  | #pod =head1 DELEGATED METHODS | 
| 123 |  |  |  |  |  |  | #pod | 
| 124 |  |  |  |  |  |  | #pod Delegated to the traditional L<Pod::Coverage> object are: | 
| 125 |  |  |  |  |  |  | #pod | 
| 126 |  |  |  |  |  |  | #pod =head2 coverage | 
| 127 |  |  |  |  |  |  | #pod | 
| 128 |  |  |  |  |  |  | #pod =head2 covered | 
| 129 |  |  |  |  |  |  | #pod | 
| 130 |  |  |  |  |  |  | #pod =head2 naked | 
| 131 |  |  |  |  |  |  | #pod | 
| 132 |  |  |  |  |  |  | #pod =head2 uncovered | 
| 133 |  |  |  |  |  |  | #pod | 
| 134 |  |  |  |  |  |  | #pod =head2 why_unrated | 
| 135 |  |  |  |  |  |  | #pod | 
| 136 |  |  |  |  |  |  | #pod =head1 EXTENDED METHODS | 
| 137 |  |  |  |  |  |  | #pod | 
| 138 |  |  |  |  |  |  | #pod =head2 new | 
| 139 |  |  |  |  |  |  | #pod | 
| 140 |  |  |  |  |  |  | #pod The constructor will only return a C<Pod::Coverage::Moose> object if it | 
| 141 |  |  |  |  |  |  | #pod is invoked on a class that C<can> a C<meta> method. Otherwise, a | 
| 142 |  |  |  |  |  |  | #pod traditional L<Pod::Coverage> object will be returned. This is done so you | 
| 143 |  |  |  |  |  |  | #pod don't get in trouble for mixing L<Moose> with non Moose classes in your | 
| 144 |  |  |  |  |  |  | #pod project. | 
| 145 |  |  |  |  |  |  | #pod | 
| 146 |  |  |  |  |  |  | #pod =cut | 
| 147 |  |  |  |  |  |  |  | 
| 148 |  |  |  |  |  |  | around new => sub { | 
| 149 |  |  |  |  |  |  | my $next = shift; | 
| 150 |  |  |  |  |  |  | my ($self, @args) = @_; | 
| 151 |  |  |  |  |  |  |  | 
| 152 |  |  |  |  |  |  | my %args  = (@args == 1 && ref $args[0] eq 'HASH' ? %{ $args[0] } : @args); | 
| 153 |  |  |  |  |  |  | my $class = $args{package} | 
| 154 |  |  |  |  |  |  | or croak 'You need to specify a package in the constructor arguments'; | 
| 155 |  |  |  |  |  |  |  | 
| 156 |  |  |  |  |  |  | load_class($class); | 
| 157 |  |  |  |  |  |  | return Pod::Coverage->new(%args) unless $class->can('meta'); | 
| 158 |  |  |  |  |  |  |  | 
| 159 |  |  |  |  |  |  | return $self->$next(@args); | 
| 160 |  |  |  |  |  |  | }; | 
| 161 |  |  |  |  |  |  |  | 
| 162 |  |  |  |  |  |  | 1; | 
| 163 |  |  |  |  |  |  |  | 
| 164 |  |  |  |  |  |  | __END__ | 
| 165 |  |  |  |  |  |  |  | 
| 166 |  |  |  |  |  |  | =pod | 
| 167 |  |  |  |  |  |  |  | 
| 168 |  |  |  |  |  |  | =encoding UTF-8 | 
| 169 |  |  |  |  |  |  |  | 
| 170 |  |  |  |  |  |  | =head1 NAME | 
| 171 |  |  |  |  |  |  |  | 
| 172 |  |  |  |  |  |  | Pod::Coverage::Moose - Pod::Coverage extension for Moose | 
| 173 |  |  |  |  |  |  |  | 
| 174 |  |  |  |  |  |  | =head1 VERSION | 
| 175 |  |  |  |  |  |  |  | 
| 176 |  |  |  |  |  |  | version 0.07 | 
| 177 |  |  |  |  |  |  |  | 
| 178 |  |  |  |  |  |  | =head1 SYNOPSIS | 
| 179 |  |  |  |  |  |  |  | 
| 180 |  |  |  |  |  |  | use Pod::Coverage::Moose; | 
| 181 |  |  |  |  |  |  |  | 
| 182 |  |  |  |  |  |  | my $pcm = Pod::Coverage::Moose->new(package => 'MoosePackage'); | 
| 183 |  |  |  |  |  |  | print 'Coverage: ', $pcm->coverage, "\n"; | 
| 184 |  |  |  |  |  |  |  | 
| 185 |  |  |  |  |  |  | =head1 DESCRIPTION | 
| 186 |  |  |  |  |  |  |  | 
| 187 |  |  |  |  |  |  | When using L<Pod::Coverage> in combination with L<Moose>, it will | 
| 188 |  |  |  |  |  |  | report any method imported from a Role. This is especially bad when | 
| 189 |  |  |  |  |  |  | used in combination with L<Test::Pod::Coverage>, since it takes away | 
| 190 |  |  |  |  |  |  | its ease of use. | 
| 191 |  |  |  |  |  |  |  | 
| 192 |  |  |  |  |  |  | To use this module in combination with L<Test::Pod::Coverage>, use | 
| 193 |  |  |  |  |  |  | something like this: | 
| 194 |  |  |  |  |  |  |  | 
| 195 |  |  |  |  |  |  | use Test::Pod::Coverage; | 
| 196 |  |  |  |  |  |  | all_pod_coverage_ok({ coverage_class => 'Pod::Coverage::Moose'}); | 
| 197 |  |  |  |  |  |  |  | 
| 198 |  |  |  |  |  |  | =head1 ATTRIBUTES | 
| 199 |  |  |  |  |  |  |  | 
| 200 |  |  |  |  |  |  | =head2 package | 
| 201 |  |  |  |  |  |  |  | 
| 202 |  |  |  |  |  |  | This is the package used for inspection. | 
| 203 |  |  |  |  |  |  |  | 
| 204 |  |  |  |  |  |  | =head2 cover_requires | 
| 205 |  |  |  |  |  |  |  | 
| 206 |  |  |  |  |  |  | Boolean flag to indicate that C<requires $method> declarations in a Role should be trusted. | 
| 207 |  |  |  |  |  |  |  | 
| 208 |  |  |  |  |  |  | =head1 METHODS | 
| 209 |  |  |  |  |  |  |  | 
| 210 |  |  |  |  |  |  | =head2 meta | 
| 211 |  |  |  |  |  |  |  | 
| 212 |  |  |  |  |  |  | L<Moose> meta object. | 
| 213 |  |  |  |  |  |  |  | 
| 214 |  |  |  |  |  |  | =head2 BUILD | 
| 215 |  |  |  |  |  |  |  | 
| 216 |  |  |  |  |  |  | =for stopwords initialises | 
| 217 |  |  |  |  |  |  |  | 
| 218 |  |  |  |  |  |  | Initialises the internal L<Pod::Coverage> object. It uses the meta object | 
| 219 |  |  |  |  |  |  | to find all methods and attribute methods imported via roles. | 
| 220 |  |  |  |  |  |  |  | 
| 221 |  |  |  |  |  |  | =head1 DELEGATED METHODS | 
| 222 |  |  |  |  |  |  |  | 
| 223 |  |  |  |  |  |  | Delegated to the traditional L<Pod::Coverage> object are: | 
| 224 |  |  |  |  |  |  |  | 
| 225 |  |  |  |  |  |  | =head2 coverage | 
| 226 |  |  |  |  |  |  |  | 
| 227 |  |  |  |  |  |  | =head2 covered | 
| 228 |  |  |  |  |  |  |  | 
| 229 |  |  |  |  |  |  | =head2 naked | 
| 230 |  |  |  |  |  |  |  | 
| 231 |  |  |  |  |  |  | =head2 uncovered | 
| 232 |  |  |  |  |  |  |  | 
| 233 |  |  |  |  |  |  | =head2 why_unrated | 
| 234 |  |  |  |  |  |  |  | 
| 235 |  |  |  |  |  |  | =head1 EXTENDED METHODS | 
| 236 |  |  |  |  |  |  |  | 
| 237 |  |  |  |  |  |  | =head2 new | 
| 238 |  |  |  |  |  |  |  | 
| 239 |  |  |  |  |  |  | The constructor will only return a C<Pod::Coverage::Moose> object if it | 
| 240 |  |  |  |  |  |  | is invoked on a class that C<can> a C<meta> method. Otherwise, a | 
| 241 |  |  |  |  |  |  | traditional L<Pod::Coverage> object will be returned. This is done so you | 
| 242 |  |  |  |  |  |  | don't get in trouble for mixing L<Moose> with non Moose classes in your | 
| 243 |  |  |  |  |  |  | project. | 
| 244 |  |  |  |  |  |  |  | 
| 245 |  |  |  |  |  |  | =head1 SEE ALSO | 
| 246 |  |  |  |  |  |  |  | 
| 247 |  |  |  |  |  |  | =over 4 | 
| 248 |  |  |  |  |  |  |  | 
| 249 |  |  |  |  |  |  | =item * | 
| 250 |  |  |  |  |  |  |  | 
| 251 |  |  |  |  |  |  | L<Moose> | 
| 252 |  |  |  |  |  |  |  | 
| 253 |  |  |  |  |  |  | =item * | 
| 254 |  |  |  |  |  |  |  | 
| 255 |  |  |  |  |  |  | L<Pod::Coverage>, | 
| 256 |  |  |  |  |  |  |  | 
| 257 |  |  |  |  |  |  | =item * | 
| 258 |  |  |  |  |  |  |  | 
| 259 |  |  |  |  |  |  | L<Test::Pod::Coverage> | 
| 260 |  |  |  |  |  |  |  | 
| 261 |  |  |  |  |  |  | =back | 
| 262 |  |  |  |  |  |  |  | 
| 263 |  |  |  |  |  |  | =head1 SUPPORT | 
| 264 |  |  |  |  |  |  |  | 
| 265 |  |  |  |  |  |  | Bugs may be submitted through L<the RT bug tracker|https://rt.cpan.org/Public/Dist/Display.html?Name=Pod-Coverage-Moose> | 
| 266 |  |  |  |  |  |  | (or L<bug-Pod-Coverage-Moose@rt.cpan.org|mailto:bug-Pod-Coverage-Moose@rt.cpan.org>). | 
| 267 |  |  |  |  |  |  |  | 
| 268 |  |  |  |  |  |  | There is also a mailing list available for users of this distribution, at | 
| 269 |  |  |  |  |  |  | http://lists.perl.org/list/moose.html. | 
| 270 |  |  |  |  |  |  |  | 
| 271 |  |  |  |  |  |  | There is also an irc channel available for users of this distribution, at | 
| 272 |  |  |  |  |  |  | irc://irc.perl.org/#moose. | 
| 273 |  |  |  |  |  |  |  | 
| 274 |  |  |  |  |  |  | =head1 AUTHOR | 
| 275 |  |  |  |  |  |  |  | 
| 276 |  |  |  |  |  |  | Robert 'phaylon' Sedlacek <rs@474.at> | 
| 277 |  |  |  |  |  |  |  | 
| 278 |  |  |  |  |  |  | =head1 CONTRIBUTORS | 
| 279 |  |  |  |  |  |  |  | 
| 280 |  |  |  |  |  |  | =for stopwords Karen Etheridge Vyacheslav Matyukhin Dave Rolsky | 
| 281 |  |  |  |  |  |  |  | 
| 282 |  |  |  |  |  |  | =over 4 | 
| 283 |  |  |  |  |  |  |  | 
| 284 |  |  |  |  |  |  | =item * | 
| 285 |  |  |  |  |  |  |  | 
| 286 |  |  |  |  |  |  | Karen Etheridge <ether@cpan.org> | 
| 287 |  |  |  |  |  |  |  | 
| 288 |  |  |  |  |  |  | =item * | 
| 289 |  |  |  |  |  |  |  | 
| 290 |  |  |  |  |  |  | Vyacheslav Matyukhin <me@berekuk.ru> | 
| 291 |  |  |  |  |  |  |  | 
| 292 |  |  |  |  |  |  | =item * | 
| 293 |  |  |  |  |  |  |  | 
| 294 |  |  |  |  |  |  | Dave Rolsky <autarch@urth.org> | 
| 295 |  |  |  |  |  |  |  | 
| 296 |  |  |  |  |  |  | =back | 
| 297 |  |  |  |  |  |  |  | 
| 298 |  |  |  |  |  |  | =head1 COPYRIGHT AND LICENSE | 
| 299 |  |  |  |  |  |  |  | 
| 300 |  |  |  |  |  |  | This software is copyright (c) 2007 by Robert 'phaylon' Sedlacek. | 
| 301 |  |  |  |  |  |  |  | 
| 302 |  |  |  |  |  |  | This is free software; you can redistribute it and/or modify it under | 
| 303 |  |  |  |  |  |  | the same terms as the Perl 5 programming language system itself. | 
| 304 |  |  |  |  |  |  |  | 
| 305 |  |  |  |  |  |  | =cut |