| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | =head1 NAME | 
| 2 |  |  |  |  |  |  |  | 
| 3 |  |  |  |  |  |  | Devel::PerlySense::Document::Api::Method - A method/sub | 
| 4 |  |  |  |  |  |  |  | 
| 5 |  |  |  |  |  |  | =head1 DESCRIPTION | 
| 6 |  |  |  |  |  |  |  | 
| 7 |  |  |  |  |  |  | An Api::Method is a sub name and a location (possibly with a defined | 
| 8 |  |  |  |  |  |  | row, etc). | 
| 9 |  |  |  |  |  |  |  | 
| 10 |  |  |  |  |  |  | The Method has a documentation string and possibly POD. | 
| 11 |  |  |  |  |  |  |  | 
| 12 |  |  |  |  |  |  | =cut | 
| 13 |  |  |  |  |  |  |  | 
| 14 |  |  |  |  |  |  |  | 
| 15 |  |  |  |  |  |  |  | 
| 16 |  |  |  |  |  |  |  | 
| 17 |  |  |  |  |  |  |  | 
| 18 | 8 |  |  | 8 |  | 31 | use strict; | 
|  | 8 |  |  |  |  | 10 |  | 
|  | 8 |  |  |  |  | 306 |  | 
| 19 | 8 |  |  | 8 |  | 27 | use warnings; | 
|  | 8 |  |  |  |  | 16 |  | 
|  | 8 |  |  |  |  | 1095 |  | 
| 20 | 8 |  |  | 8 |  | 29 | use utf8; | 
|  | 8 |  |  |  |  | 11 |  | 
|  | 8 |  |  |  |  | 55 |  | 
| 21 |  |  |  |  |  |  |  | 
| 22 |  |  |  |  |  |  | package Devel::PerlySense::Document::Api::Method; | 
| 23 |  |  |  |  |  |  |  | 
| 24 |  |  |  |  |  |  |  | 
| 25 |  |  |  |  |  |  |  | 
| 26 |  |  |  |  |  |  |  | 
| 27 |  |  |  |  |  |  |  | 
| 28 | 8 |  |  | 8 |  | 368 | use Spiffy -Base; | 
|  | 8 |  |  |  |  | 12 |  | 
|  | 8 |  |  |  |  | 36 |  | 
| 29 | 8 |  |  | 8 |  | 5650 | use Carp; | 
|  | 8 |  |  | 8 |  | 11 |  | 
|  | 8 |  |  | 8 |  | 239 |  | 
|  | 8 |  |  |  |  | 28 |  | 
|  | 8 |  |  |  |  | 10 |  | 
|  | 8 |  |  |  |  | 154 |  | 
|  | 8 |  |  |  |  | 29 |  | 
|  | 8 |  |  |  |  | 10 |  | 
|  | 8 |  |  |  |  | 417 |  | 
| 30 | 8 |  |  | 8 |  | 39 | use Data::Dumper; | 
|  | 8 |  |  |  |  | 17 |  | 
|  | 8 |  |  |  |  | 337 |  | 
| 31 | 8 |  |  | 8 |  | 30 | use List::Util qw/ first /; | 
|  | 8 |  |  |  |  | 7 |  | 
|  | 8 |  |  |  |  | 384 |  | 
| 32 |  |  |  |  |  |  |  | 
| 33 | 8 |  |  | 8 |  | 32 | use Devel::PerlySense::Document::Api; | 
|  | 8 |  |  |  |  | 10 |  | 
|  | 8 |  |  |  |  | 53 |  | 
| 34 | 8 |  |  | 8 |  | 1574 | use Devel::PerlySense::Document::Location; | 
|  | 8 |  |  |  |  | 10 |  | 
|  | 8 |  |  |  |  | 55 |  | 
| 35 |  |  |  |  |  |  |  | 
| 36 |  |  |  |  |  |  |  | 
| 37 |  |  |  |  |  |  |  | 
| 38 |  |  |  |  |  |  |  | 
| 39 |  |  |  |  |  |  |  | 
| 40 |  |  |  |  |  |  | =head1 PROPERTIES | 
| 41 |  |  |  |  |  |  |  | 
| 42 |  |  |  |  |  |  | =head2 name | 
| 43 |  |  |  |  |  |  |  | 
| 44 |  |  |  |  |  |  | The method name | 
| 45 |  |  |  |  |  |  |  | 
| 46 |  |  |  |  |  |  | Default: "". | 
| 47 |  |  |  |  |  |  |  | 
| 48 |  |  |  |  |  |  | =cut | 
| 49 |  |  |  |  |  |  | field "name" => ""; | 
| 50 |  |  |  |  |  |  |  | 
| 51 |  |  |  |  |  |  |  | 
| 52 |  |  |  |  |  |  |  | 
| 53 |  |  |  |  |  |  |  | 
| 54 |  |  |  |  |  |  |  | 
| 55 |  |  |  |  |  |  | =head2 oLocationDocumented | 
| 56 |  |  |  |  |  |  |  | 
| 57 |  |  |  |  |  |  | A Document::Location object specifying where the method is documented, | 
| 58 |  |  |  |  |  |  | or undef if that is unknown. | 
| 59 |  |  |  |  |  |  |  | 
| 60 |  |  |  |  |  |  | Default: undef. | 
| 61 |  |  |  |  |  |  |  | 
| 62 |  |  |  |  |  |  | =cut | 
| 63 |  |  |  |  |  |  | field "oLocationDocumented" => undef; | 
| 64 |  |  |  |  |  |  |  | 
| 65 |  |  |  |  |  |  |  | 
| 66 |  |  |  |  |  |  |  | 
| 67 |  |  |  |  |  |  |  | 
| 68 |  |  |  |  |  |  |  | 
| 69 |  |  |  |  |  |  | =head2 oDocument | 
| 70 |  |  |  |  |  |  |  | 
| 71 |  |  |  |  |  |  | A PerlySense::Document object specifying in which the method belongs | 
| 72 |  |  |  |  |  |  | to. This does not have to be the Document where it's declared. | 
| 73 |  |  |  |  |  |  |  | 
| 74 |  |  |  |  |  |  | Default: undef. | 
| 75 |  |  |  |  |  |  |  | 
| 76 |  |  |  |  |  |  | =cut | 
| 77 |  |  |  |  |  |  | field "oDocument" => undef; | 
| 78 |  |  |  |  |  |  |  | 
| 79 |  |  |  |  |  |  |  | 
| 80 |  |  |  |  |  |  |  | 
| 81 |  |  |  |  |  |  |  | 
| 82 |  |  |  |  |  |  |  | 
| 83 |  |  |  |  |  |  | =head2 signature | 
| 84 |  |  |  |  |  |  |  | 
| 85 |  |  |  |  |  |  | Return doc string with the signature of the method, according to found | 
| 86 |  |  |  |  |  |  | documentation, usage, etc. | 
| 87 |  |  |  |  |  |  |  | 
| 88 |  |  |  |  |  |  | Readonly. | 
| 89 |  |  |  |  |  |  |  | 
| 90 |  |  |  |  |  |  | =cut | 
| 91 | 75 |  |  | 75 | 1 | 96 | sub signature { | 
| 92 |  |  |  |  |  |  |  | 
| 93 | 75 |  |  |  |  | 4995 | my $signature = $self->name; | 
| 94 | 75 |  |  |  |  | 2043 | my $nameMethod = $self->name; | 
| 95 | 75 | 100 |  |  |  | 2763 | if(my $oLocation = $self->oLocationDocumented) { | 
| 96 | 71 |  |  |  |  | 1962 | my @aTextPod = split(/\n/, $oLocation->rhProperty->{text}); | 
| 97 |  |  |  |  |  |  | $signature = | 
| 98 | 457 |  |  | 457 |  | 3141 | first( sub { /->\s*\b$nameMethod\b/ }, @aTextPod ) | 
| 99 | 71 |  | 33 | 134 |  | 1131 | || first( sub { /\b$nameMethod\b/      }, @aTextPod ) | 
|  | 134 |  |  |  |  | 1214 |  | 
| 100 |  |  |  |  |  |  | || $signature; | 
| 101 |  |  |  |  |  |  | } | 
| 102 |  |  |  |  |  |  |  | 
| 103 | 75 |  |  |  |  | 1733 | $signature =~ s/ .* (\b$nameMethod\b) /$1/x; | 
| 104 | 75 |  |  |  |  | 499 | $signature =~ s/^ \s+ | \s* ; \s* $//gx; | 
| 105 |  |  |  |  |  |  |  | 
| 106 |  |  |  |  |  |  |  | 
| 107 | 75 |  |  |  |  | 280 | return $signature; | 
| 108 |  |  |  |  |  |  | } | 
| 109 |  |  |  |  |  |  |  | 
| 110 |  |  |  |  |  |  |  | 
| 111 |  |  |  |  |  |  |  | 
| 112 |  |  |  |  |  |  |  | 
| 113 |  |  |  |  |  |  |  | 
| 114 |  |  |  |  |  |  | =head1 API METHODS | 
| 115 |  |  |  |  |  |  |  | 
| 116 |  |  |  |  |  |  | =head2 new(oDocument, name) | 
| 117 |  |  |  |  |  |  |  | 
| 118 |  |  |  |  |  |  | Create new Method with $name belonging to $oDocument. | 
| 119 |  |  |  |  |  |  |  | 
| 120 |  |  |  |  |  |  | Set oLocationDocumented according to the found documentation. | 
| 121 |  |  |  |  |  |  |  | 
| 122 |  |  |  |  |  |  | =cut | 
| 123 |  |  |  |  |  |  | sub new(@) { | 
| 124 | 76 |  |  | 76 | 1 | 89 | my $pkg = shift; | 
| 125 | 76 |  |  |  |  | 205 | my (%p) = @_; | 
| 126 |  |  |  |  |  |  |  | 
| 127 | 76 |  |  |  |  | 173 | my $self = bless {}, $pkg; | 
| 128 | 76 | 50 |  |  |  | 1866 | $self->name($p{name}) or croak("Missing parameter name\n"); | 
| 129 | 76 | 50 |  |  |  | 2345 | $self->oDocument($p{oDocument}) or croak("Missing parameter oDocument\n"); | 
| 130 | 76 |  |  |  |  | 2082 | $self->oLocationDocumented( | 
| 131 |  |  |  |  |  |  | $self->oDocument->oPerlySense->oLocationMethodDocFromDocument( | 
| 132 |  |  |  |  |  |  | $self->oDocument, | 
| 133 |  |  |  |  |  |  | $self->name, | 
| 134 |  |  |  |  |  |  | ) | 
| 135 |  |  |  |  |  |  | ); | 
| 136 |  |  |  |  |  |  |  | 
| 137 | 76 |  |  |  |  | 872 | return($self); | 
| 138 |  |  |  |  |  |  | } | 
| 139 |  |  |  |  |  |  |  | 
| 140 |  |  |  |  |  |  |  | 
| 141 |  |  |  |  |  |  |  | 
| 142 |  |  |  |  |  |  |  | 
| 143 |  |  |  |  |  |  |  | 
| 144 |  |  |  |  |  |  | =head2 signatureCall($oLocationDeclaration) | 
| 145 |  |  |  |  |  |  |  | 
| 146 |  |  |  |  |  |  | Return doc string with the call signature of the method, according to | 
| 147 |  |  |  |  |  |  | the $oLocationDeclaration, etc. | 
| 148 |  |  |  |  |  |  |  | 
| 149 |  |  |  |  |  |  | The call signature is the signature with a call arrow, either -> or \> | 
| 150 |  |  |  |  |  |  | . | 
| 151 |  |  |  |  |  |  |  | 
| 152 |  |  |  |  |  |  | =cut | 
| 153 | 71 |  |  | 71 | 1 | 96 | sub signatureCall { | 
| 154 | 71 |  |  |  |  | 97 | my ($oLocationDeclaration) = @_; | 
| 155 | 71 |  |  |  |  | 211 | my $signature = $self->signature; | 
| 156 |  |  |  |  |  |  |  | 
| 157 | 71 | 100 |  |  |  | 1838 | my $prefixCall = $self->oDocument->file eq $oLocationDeclaration->file ? '->' : '\>'; | 
| 158 |  |  |  |  |  |  |  | 
| 159 | 71 |  |  |  |  | 5595 | return "$prefixCall$signature"; | 
| 160 |  |  |  |  |  |  | } | 
| 161 |  |  |  |  |  |  |  | 
| 162 |  |  |  |  |  |  |  | 
| 163 |  |  |  |  |  |  |  | 
| 164 |  |  |  |  |  |  |  | 
| 165 |  |  |  |  |  |  |  | 
| 166 |  |  |  |  |  |  | 1; | 
| 167 |  |  |  |  |  |  |  | 
| 168 |  |  |  |  |  |  |  | 
| 169 |  |  |  |  |  |  |  | 
| 170 |  |  |  |  |  |  |  | 
| 171 |  |  |  |  |  |  |  | 
| 172 |  |  |  |  |  |  | __END__ | 
| 173 |  |  |  |  |  |  |  | 
| 174 |  |  |  |  |  |  | =encoding utf8 | 
| 175 |  |  |  |  |  |  |  | 
| 176 |  |  |  |  |  |  | =head1 AUTHOR | 
| 177 |  |  |  |  |  |  |  | 
| 178 |  |  |  |  |  |  | Johan Lindström, C<< <johanl[ÄT]DarSerMan.com> >> | 
| 179 |  |  |  |  |  |  |  | 
| 180 |  |  |  |  |  |  | =head1 BUGS | 
| 181 |  |  |  |  |  |  |  | 
| 182 |  |  |  |  |  |  | Please report any bugs or feature requests to | 
| 183 |  |  |  |  |  |  | C<bug-devel-perlysense@rt.cpan.org>, or through the web interface at | 
| 184 |  |  |  |  |  |  | L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Devel-PerlySense>. | 
| 185 |  |  |  |  |  |  | I will be notified, and then you'll automatically be notified of progress on | 
| 186 |  |  |  |  |  |  | your bug as I make changes. | 
| 187 |  |  |  |  |  |  |  | 
| 188 |  |  |  |  |  |  | =head1 ACKNOWLEDGEMENTS | 
| 189 |  |  |  |  |  |  |  | 
| 190 |  |  |  |  |  |  | =head1 COPYRIGHT & LICENSE | 
| 191 |  |  |  |  |  |  |  | 
| 192 |  |  |  |  |  |  | Copyright 2005 Johan Lindström, All Rights Reserved. | 
| 193 |  |  |  |  |  |  |  | 
| 194 |  |  |  |  |  |  | This program is free software; you can redistribute it and/or modify it | 
| 195 |  |  |  |  |  |  | under the same terms as Perl itself. | 
| 196 |  |  |  |  |  |  |  | 
| 197 |  |  |  |  |  |  | =cut |