blib/lib/WebService/NextEpisode.pm

filter: Statementstmt 81.4% 22 / 27 Branchbran 50.0% 1 / 2 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 6 / 6 Podpod 100% 1 / 1 totaltotal 75.6% 31 / 41 CC 3 SCAR 8.2
CC
3
Cov
75%
of
4.4
BEGIN
1.0
BEGIN
1.0
CRAP 2.3
↑ Summary
1 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 package WebService::NextEpisode;
4 3 ▶use LWP::Simple;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 ▶use HTML::TreeBuilder::XPath;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 # ABSTRACT: Fetches air date from next-episode.net
8 3 our $VERSION = '0.003'; # VERSION
9  
10 3 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 =pod
13  
14 =encoding utf8
15  
16 =head1 NAME
17  
18 WebService::NextEpisode - Fetch air date from next-episode.net
19  
20  
21 =head1 SYNOPSIS
22  
23 $ perl -MWebService::NextEpisode -e 'print WebService::NextEpisode::of "Better Call Saul"'
24 Mon Jun 05, 2017
25  
26  
27 =head1 METHODS AND ARGUMENTS
28  
29  
30 =over 4
31  
32 =item of($show)
33  
34 Retrieves air date of next epsiode of $show
35  
36 =cut
37  
38 1 ▶sub of {
Subroutine of: called CC=3 SCAR=14.7
Pod documented
39 1 my ($show_minus, $show) = (shift) x 2;
40  
41 1 $show =~ s/ /+/g;
42 1 $show_minus =~ s/ /-/g;
43  
44 1 ▶ my $page = get("http://next-episode.net/$show_minus")
Condition33%1/3
&get("http://next-episode.net/$show_minus") // &get("http://next-episode.net/site-search-$show.html")
l!l&&r!l&&!r
001
MC/DC0%0/2
&get("http://next-episode.net/$show_minus") // &get("http://next-episode.net/site-search-$show.html")
&get("http://next-episode.net/$show_minus") &get("http://next-episode.net/site-search-$show.html")
Truth table33%1/3
A // B
A= &get("http://next-episode.net/$show_minus")B= &get("http://next-episode.net/site-search-$show.html")
ABresult
1X1
011
000
45 // get("http://next-episode.net/site-search-$show.html");
46 1 ▶ defined $page or die "Couldn't get it!";
Branch: 1 branch
BranchTrueFalseTotal
defined $page or die "Couldn't get it!" 0 1 1
47  
48 0 my $tree = HTML::TreeBuilder::XPath->new;
49 0 $tree->parse($page);
50  
51 0 my $next = $tree->findvalue( '/html/body//div[@id="next_episode"]');
52  
53 0 $next =~ s/.*Date:(.*)Season.*/$1/;
54  
55 0 return $next;
56 }
57  
58  
59  
60 3 1;
61 __END__
↑ Summary