| 1 | package CPAN::Search::Tester; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use MooseX::Params::Validate; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use Moose::Util::TypeConstraints; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use namespace::clean; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 2 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 2 | ▶ | use Readonly; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 2 | ▶ | use WWW::Mechanize; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | =head1 NAME | ||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | CPAN::Search::Tester - Interface to search CPAN module tester. | ||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | =head1 VERSION | ||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | Version 0.03 | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | =cut | ||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | 2 | our $VERSION = '0.03'; | |||||||||||||||||||||||||||
| 25 | 2 | Readonly my $URL => 'http://stats.cpantesters.org/cpanmail.html'; | |||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | This module is a very thin wrapper for "Find A Tester" feature provided by cpantesters.org. | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | =cut | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | subtype 'IDORGUID' | ||||||||||||||||||||||||||||
| 34 | => as 'Str' | ||||||||||||||||||||||||||||
| 35 | 3 | ▶ | => where { (/^\d+$/) || (/^[a-z0-9]+\-[a-z0-9]+\-[a-z0-9]+\-[a-z0-9]+\-[a-z0-9]+$/) }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.2
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | coerce 'IDORGUID' | ||||||||||||||||||||||||||||
| 38 | => from 'Num' | ||||||||||||||||||||||||||||
| 39 | 0 | ▶ | => via { [ $_ ] } | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 40 | => from 'Str' | ||||||||||||||||||||||||||||
| 41 | 3 | ▶ | => via { [ $_ ] }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | 1 | ▶ | has 'browser' => (is => 'ro', isa => 'WWW::Mechanize', default => sub { return new WWW::Mechanize(autocheck => 1); }); | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | =head1 METHODS | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | =head2 search() | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | Search a CPAN Tester for the given ID or GUID. Please use with care and do *NOT* generate spam | ||||||||||||||||||||||||||||
| 50 | attacks on testers. | ||||||||||||||||||||||||||||
| 51 | Currently CPAN Testers reports are publicly available via the CPAN Testers Reports site, using | ||||||||||||||||||||||||||||
| 52 | a unique ID used by 'cpanstats' database or a GUID used by the Metabase data store. Either of | ||||||||||||||||||||||||||||
| 53 | these can be used to perform a lookup. The ID or GUID is displayed via the report display on | ||||||||||||||||||||||||||||
| 54 | the CPAN Testers Reports site. For example, | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | http://www.cpantesters.org/cpan/report/7019327 | ||||||||||||||||||||||||||||
| 57 | http://www.cpantesters.org/cpan/report/07019335-b19f-3f77-b713-d32bba55d77f | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | Here 7019327 is the ID and 07019335-b19f-3f77-b713-d32bba55d77f is the GUID. | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | use strict; use warnings; | ||||||||||||||||||||||||||||
| 62 | use CPAN::Search::Tester; | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | my $tester = CPAN::Search::Tester->new(); | ||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | print $tester->search('7019327') . "\n"; | ||||||||||||||||||||||||||||
| 67 | # or | ||||||||||||||||||||||||||||
| 68 | print $tester->search('07019335-b19f-3f77-b713-d32bba55d77f') . "\n"; | ||||||||||||||||||||||||||||
| 69 | # or | ||||||||||||||||||||||||||||
| 70 | print $tester->search(id => '7019327') . "\n"; | ||||||||||||||||||||||||||||
| 71 | # or | ||||||||||||||||||||||||||||
| 72 | print $tester->search(guid => '07019335-b19f-3f77-b713-d32bba55d77f') . "\n"; | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | =cut | ||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | around 'search' => sub | ||||||||||||||||||||||||||||
| 77 | { | ||||||||||||||||||||||||||||
| 78 | 4 | ▶ | my $orig = shift; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 79 | 4 | my $class = shift; | |||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | 4 | ▶ | if (@_ > 1 && !ref $_[0]) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
@_ > 1 and not ref $_[0]
MC/DC50%1/2
@_ > 1 and not ref $_[0]
@_ > 1
not ref $_[0]
Truth table66%2/3
A and not(B)
A= @_ > 1B= not ref $_[0]
| |||||||||||||||||||||||||||||
| 82 | { | ||||||||||||||||||||||||||||
| 83 | 2 | return $class->$orig($_[1]); | |||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||
| 85 | else | ||||||||||||||||||||||||||||
| 86 | { | ||||||||||||||||||||||||||||
| 87 | 2 | return $class->$orig(@_); | |||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||
| 89 | 2 | }; | |||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | sub search | ||||||||||||||||||||||||||||
| 92 | { | ||||||||||||||||||||||||||||
| 93 | 4 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
search: called CC=3 SCAR=21.8
| |||||||||||||||||||||||||||||
| 94 | 4 | my ($id) = pos_validated_list(\@_, | |||||||||||||||||||||||||||
| 95 | { isa => 'IDORGUID', coerce => 1, required => 1 }, | ||||||||||||||||||||||||||||
| 96 | MX_PARAMS_VALIDATE_NO_CACHE => 1); | ||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | 0 | $self->{browser}->get($URL); | |||||||||||||||||||||||||||
| 99 | 0 | $self->{browser}->form_number(1); | |||||||||||||||||||||||||||
| 100 | 0 | $self->{browser}->field('id', $id); | |||||||||||||||||||||||||||
| 101 | 0 | $self->{browser}->submit(); | |||||||||||||||||||||||||||
| 102 | 0 | my $content = $self->{browser}->content; | |||||||||||||||||||||||||||
| 103 | 0 | ▶ | return "No data found.\n" unless defined $content; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | 0 | ▶ | if ($content =~ /\<tr\>\<th\>Address\:\<\/th\>\<td\>(.*)\<\/td\>\<\/tr\>/) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 106 | { | ||||||||||||||||||||||||||||
| 107 | 0 | return $1; | |||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||
| 109 | else | ||||||||||||||||||||||||||||
| 110 | { | ||||||||||||||||||||||||||||
| 111 | 0 | return "No data found.\n"; | |||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||
| 115 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||
| 117 | Mohammad S Anwar, C<< <mohammad.anwar at yahoo.com> >> | ||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||
| 119 | =head1 BUGS | ||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | Please report any bugs or feature requests to C<bug-cpan-search-tester at rt.cpan.org>, or | ||||||||||||||||||||||||||||
| 122 | through the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=CPAN-Search-Tester>. | ||||||||||||||||||||||||||||
| 123 | I will be notified and then you'll automatically be notified of progress on your bug as I make | ||||||||||||||||||||||||||||
| 124 | changes. | ||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||
| 126 | =head1 SUPPORT | ||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||
| 128 | You can find documentation for this module with the perldoc command. | ||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||
| 130 | perldoc CPAN::Search::Tester | ||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||
| 132 | You can also look for information at: | ||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||
| 134 | =over 4 | ||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||
| 136 | =item * RT: CPAN's request tracker | ||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||
| 138 | L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=CPAN-Search-Tester> | ||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||
| 140 | =item * AnnoCPAN: Annotated CPAN documentation | ||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||
| 142 | L<http://annocpan.org/dist/CPAN-Search-Tester> | ||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||
| 144 | =item * CPAN Ratings | ||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||
| 146 | L<http://cpanratings.perl.org/d/CPAN-Search-Tester> | ||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||
| 148 | =item * Search CPAN | ||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||
| 150 | L<http://search.cpan.org/dist/CPAN-Search-Tester/> | ||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||
| 152 | =back | ||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||
| 154 | =head1 ACKNOWLEDGEMENT | ||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||
| 156 | This wouldn't have been possible without the service of cpantesters.org. | ||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||
| 158 | =head1 LICENSE AND COPYRIGHT | ||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||
| 160 | Copyright 2011 Mohammad S Anwar. | ||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||
| 162 | This program is free software; you can redistribute it and/or modify it under the terms of | ||||||||||||||||||||||||||||
| 163 | either: the GNU General Public License as published by the Free Software Foundation; or the | ||||||||||||||||||||||||||||
| 164 | Artistic License. | ||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||
| 166 | See http://dev.perl.org/licenses/ for more information. | ||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||
| 168 | =head1 DISCLAIMER | ||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||
| 170 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; | ||||||||||||||||||||||||||||
| 171 | without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||
| 173 | =cut | ||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||
| 175 | 2 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||
| 176 | 2 | ▶ | no Moose; # Keywords are removed from the CPAN::Search::Tester package | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 177 | 2 | ▶ | no Moose::Util::TypeConstraints; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||
| 179 | 2 | 1; # End of CPAN::Search::Tester | |||||||||||||||||||||||||||