File Coverage

blib/lib/CPAN/Search/Tester.pm
Criterion Covered Total %
statement 17 24 70.8
branch 1 6 16.6
condition 3 6 50.0
subroutine 6 6 100.0
pod 1 1 100.0
total 28 43 65.1


line stmt bran cond sub pod time code
1             package CPAN::Search::Tester;
2              
3             $CPAN::Search::Tester::VERSION = '0.04';
4             $CPAN::Search::Tester::AUTHORITY = 'cpan:MANWAR';
5              
6             =head1 NAME
7              
8             CPAN::Search::Tester - Interface to search CPAN module tester.
9              
10             =head1 VERSION
11              
12             Version 0.04
13              
14             =cut
15              
16 2     2   16809 use 5.006;
  2         6  
  2         70  
17 2     2   1152 use Data::Dumper;
  2         14771  
  2         124  
18 2     2   1465 use WWW::Mechanize;
  2         276209  
  2         96  
19              
20 2     2   1500 use Moo;
  2         29618  
  2         12  
21 2     2   4310 use namespace::clean;
  2         25412  
  2         15  
22              
23             my $URL = 'http://stats.cpantesters.org/cpanmail.html';
24              
25             =head1 DESCRIPTION
26              
27             This module is a very thin wrapper for "Find A Tester" feature provided by cpantesters.org.
28              
29             =cut
30              
31             has 'browser' => (is => 'ro', default => sub { return new WWW::Mechanize(autocheck => 1); });
32              
33             =head1 METHODS
34              
35             =head2 search()
36              
37             Search a CPAN Tester for the given ID or GUID. Please use with care and do *NOT*
38             generate spam attacks on testers.
39             Currently CPAN Testers reports are publicly available via CPAN Testers Reports
40             site, using a unique ID used by 'cpanstats' database or a GUID used by the
41             Metabase data store. Either of these can be used to perform a lookup. The ID or
42             GUID is displayed via the report display on the CPAN Testers Reports site.
43              
44             For example,
45              
46             http://www.cpantesters.org/cpan/report/7019327
47             http://www.cpantesters.org/cpan/report/07019335-b19f-3f77-b713-d32bba55d77f
48              
49             Here 7019327 is the ID and 07019335-b19f-3f77-b713-d32bba55d77f is the GUID.
50              
51             use strict; use warnings;
52             use CPAN::Search::Tester;
53              
54             print CPAN::Search::Tester->new->search('7019327') . "\n";
55             print CPAN::Search::Tester->new->search('07019335-b19f-3f77-b713-d32bba55d77f') . "\n";
56              
57             =cut
58              
59             sub search {
60 4     4 1 13062 my ($self, $param) = @_;
61              
62 4 50 33     61 die "ERROR: Invalid ID or GUID received."
      66        
63             unless (defined $param
64             &&
65             (($param =~ /^\d+$/)
66             ||
67             ($param =~ /^[a-z0-9]+\-[a-z0-9]+\-[a-z0-9]+\-[a-z0-9]+\-[a-z0-9]+$/)));
68              
69 0           $self->{browser}->get($URL);
70 0           $self->{browser}->form_number(1);
71 0           $self->{browser}->field('id', $param);
72 0           $self->{browser}->submit();
73 0           my $content = $self->{browser}->content;
74 0 0         return "No data found.\n" unless defined $content;
75              
76 0 0         ($content =~ /\\Address\:\<\/th\>\(.*)\<\/td\>\<\/tr\>/)
77             ?
78             (return $1)
79             :
80             (return "No data found.\n");
81             }
82              
83             =head1 AUTHOR
84              
85             Mohammad S Anwar, C<< >>
86              
87             =head1 REPOSITORY
88              
89             L
90              
91             =head1 BUGS
92              
93             Please report any bugs or feature requests to C,
94             or through the web interface at L.
95             I will be notified and then you'll automatically be notified of progress on your
96             bug as I make changes.
97              
98             =head1 SUPPORT
99              
100             You can find documentation for this module with the perldoc command.
101              
102             perldoc CPAN::Search::Tester
103              
104             You can also look for information at:
105              
106             =over 4
107              
108             =item * RT: CPAN's request tracker
109              
110             L
111              
112             =item * AnnoCPAN: Annotated CPAN documentation
113              
114             L
115              
116             =item * CPAN Ratings
117              
118             L
119              
120             =item * Search CPAN
121              
122             L
123              
124             =back
125              
126             =head1 ACKNOWLEDGEMENT
127              
128             This wouldn't have been possible without the service of cpantesters.org.
129              
130             =head1 LICENSE AND COPYRIGHT
131              
132             Copyright (C) 2011 - 2015 Mohammad S Anwar.
133              
134             This program is free software; you can redistribute it and/or modify it under
135             the terms of the the Artistic License (2.0). You may obtain a copy of the full
136             license at:
137              
138             L
139              
140             Any use, modification, and distribution of the Standard or Modified Versions is
141             governed by this Artistic License.By using, modifying or distributing the Package,
142             you accept this license. Do not use, modify, or distribute the Package, if you do
143             not accept this license.
144              
145             If your Modified Version has been derived from a Modified Version made by someone
146             other than you,you are nevertheless required to ensure that your Modified Version
147             complies with the requirements of this license.
148              
149             This license does not grant you the right to use any trademark, service mark,
150             tradename, or logo of the Copyright Holder.
151              
152             This license includes the non-exclusive, worldwide, free-of-charge patent license
153             to make, have made, use, offer to sell, sell, import and otherwise transfer the
154             Package with respect to any patent claims licensable by the Copyright Holder that
155             are necessarily infringed by the Package. If you institute patent litigation
156             (including a cross-claim or counterclaim) against any party alleging that the
157             Package constitutes direct or contributory patent infringement,then this Artistic
158             License to you shall terminate on the date that such litigation is filed.
159              
160             Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND
161             CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED
162             WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
163             NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW. UNLESS
164             REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT,
165             INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE
166             OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
167              
168             =cut
169              
170             1; # End of CPAN::Search::Tester