Social/Twitter.pm

filter: Statementstmt 93.3% 14 / 15 Branchbran 50.0% 1 / 2 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 3 / 3 Podpod n/a totaltotal 82.6% 19 / 23 CC 3 SCAR 8.8
CC
3
Cov
84%
_build_share_count
3.3
BEGIN
1.0
BEGIN
1.0
CRAP 2.4
« Social/BASE.pm ↑ Summary Social/StumbleUpon.pm »
1 package URL::Social::Twitter;
2 6 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 6 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 6 extends 'URL::Social::BASE';
6  
7 =head1 NAME
8  
9 URL::Social::Twitter - Interface to the Twitter API.
10  
11 =head1 DESCRIPTION
12  
13 Do not use this module directly. Access it from L<URL::Social> instead;
14  
15 use URL::Social;
16  
17 my $social = URL::Social->new(
18 url => '...',
19 );
20  
21 print $social->twitter->share_count . "\n";
22  
23 =head1 METHODS
24  
25 =cut
26  
27 6 has 'share_count' => ( isa => 'Maybe[Int]', is => 'ro', lazy_build => 1 );
28  
29 =head2 share_count
30  
31 Returns the number of times the URL in question has been shared/tweeted.
32  
33 Returns undef if it fails to retrieve the data from Twitter.
34  
35 =cut
36  
37 1 ▶sub _build_share_count {
Subroutine _build_share_count: called CC=3 SCAR=12.0
38 1 my $self = shift;
39  
40 1 my $url = 'http://cdn.api.twitter.com/1/urls/count.json?url=' . $self->url;
41  
42 1 ▶ if ( my $share_count = $self->get_url_json($url)->{count} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $share_count = $self->get_url_json($url)->{'count'}) { } 1 0 1
43 1 ▶ return $share_count || 0;
Condition50%1/2
$share_count || 0
l!l
10
MC/DC0%0/1
$share_count || 0
$share_count
Truth table50%1/2
A
A= $share_count
Aresult
11
00
44 }
45 else {
46 0 return undef;
47 }
48 }
49  
50 #
51 # The End
52 #
53 6 __PACKAGE__->meta->make_immutable;
54  
55 6 1;
56  
57 =head1 LICENSE AND COPYRIGHT
58  
59 Copyright 2013-2014 Tore Aursand.
60  
61 This program is free software; you can redistribute it and/or modify it
62 under the terms of the the Artistic License (2.0). You may obtain a
63 copy of the full license at:
64  
65 L<http://www.perlfoundation.org/artistic_license_2_0>
66  
67 Any use, modification, and distribution of the Standard or Modified
68 Versions is governed by this Artistic License. By using, modifying or
69 distributing the Package, you accept this license. Do not use, modify,
70 or distribute the Package, if you do not accept this license.
71  
72 If your Modified Version has been derived from a Modified Version made
73 by someone other than you, you are nevertheless required to ensure that
74 your Modified Version complies with the requirements of this license.
75  
76 This license does not grant you the right to use any trademark, service
77 mark, tradename, or logo of the Copyright Holder.
78  
79 This license includes the non-exclusive, worldwide, free-of-charge
80 patent license to make, have made, use, offer to sell, sell, import and
81 otherwise transfer the Package with respect to any patent claims
82 licensable by the Copyright Holder that are necessarily infringed by the
83 Package. If you institute patent litigation (including a cross-claim or
84 counterclaim) against any party alleging that the Package constitutes
85 direct or contributory patent infringement, then this Artistic License
86 to you shall terminate on the date that such litigation is filed.
87  
88 Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER
89 AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES.
90 THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
91 PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY
92 YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR
93 CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR
94 CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE,
95 EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
« Social/BASE.pm ↑ Summary Social/StumbleUpon.pm »