blib/lib/WWW/ItsABot.pm

filter: Statementstmt 96.5% 28 / 29 Branchbran 75.0% 6 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 100% 1 / 1 totaltotal 93.1% 41 / 44 CC 5 SCAR 11.2
CC
5
Cov
92%
is_a_bot
5.1
BEGIN
1.0
BEGIN
1.0
CRAP 3.1
↑ Summary
1 package WWW::ItsABot;
2  
3 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 ▶use base 'Exporter';
Subroutine BEGIN: called CC=1 SCAR=0.0
6 3 ▶use LWP::Simple;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 3 ▶use Carp qw/croak/;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 =head1 NAME
10  
11 WWW::ItsABot - Ask itsabot.com if a Twitter user is a bot
12  
13 =head1 VERSION
14  
15 Version 0.01
16  
17 =cut
18  
19 3 our $VERSION = '0.01';
20 3 our $itsabot_url = 'http://www.itsabot.com/User';
21 3 our @EXPORT = ();
22 3 our @EXPORT_OK = qw(is_a_bot);
23  
24 =head1 SYNOPSIS
25  
26 use WWW::ItsABot qw/is_a_bot/;
27 my $username = 'foobar';
28 if ( is_a_bot($username) ) {
29 print "$username is a bot\n";
30 } else {
31 print "$username is not a bot\n";
32 }
33  
34 =head1 AUTHOR
35  
36 Jonathan Leto, C<< <jonathan at leto.net> >>
37  
38  
39 =head2 is_a_bot($username)
40  
41 Returns true is itsabot.com thinks $username is a bot, false otherwise.
42  
43 =cut
44  
45 sub is_a_bot($)
46 3 ▶{
Subroutine is_a_bot: called CC=5 SCAR=16.4
Pod documented
47 3 my ($username) = @_;
48 3 ▶ croak "is_a_bot(): Username empty" unless $username;
Branch: 1 branch
BranchTrueFalseTotal
unless $username 0 3 3
49 3 my $content = get("$itsabot_url/$username.csv");
50 # user,followers,friends,statuses,isabot,follow_ratio,followers_per_tweet
51 3 ▶ if ( $content ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($content) { } 3 0 3
52 3 my (@info) = split ',', $content;
53 3 ▶ if (defined $info[4]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $info[4]) { } 2 1 3
54 2 ▶ return $info[4] =~ /true/i ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$info[4] =~ /true/i ? : 1 1 2
55 } else {
56 1 croak "is_a_bot(): user does not exist";
57 }
58 } else {
59 0 croak "is_a_bot(): did not get a response";
60 }
61 }
62  
63 =head1 BUGS
64  
65 Please report any bugs or feature requests to C<bug-www-itsabot at rt.cpan.org>, or through
66 the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=WWW::ItsABot>. I will be notified, and then you'll
67 automatically be notified of progress on your bug as I make changes.
68  
69  
70 =head1 SUPPORT
71  
72 You can find documentation for this module with the perldoc command.
73  
74 perldoc WWW::ItsABot
75  
76  
77 You can also look for information at:
78  
79 =over 4
80  
81 =item * RT: CPAN's request tracker
82  
83 L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=WWW::ItsABot>
84  
85 =item * AnnoCPAN: Annotated CPAN documentation
86  
87 L<http://annocpan.org/dist/WWW::ItsABot>
88  
89 =item * CPAN Ratings
90  
91 L<http://cpanratings.perl.org/d/WWW::ItsABot>
92  
93 =item * Search CPAN
94  
95 L<http://search.cpan.org/dist/WWW::ItsABot>
96  
97 =back
98  
99  
100 =head1 ACKNOWLEDGEMENTS
101  
102  
103 =head1 COPYRIGHT & LICENSE
104  
105 Copyright 2009 Jonathan Leto, all rights reserved.
106  
107 This program is free software; you can redistribute it and/or modify it
108 under the same terms as Perl itself.
109  
110  
111 =cut
112  
113 3 1.0;
↑ Summary