TVRage/EpisodeListRequest.pm

filter: Statementstmt 71.0% 27 / 38 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 88.8% 8 / 9 Podpod 100% 1 / 1 totaltotal 69.2% 36 / 52 CC 3 SCAR 13.9
CC
3
Cov
64%
getEpisodeList
12.0
BEGIN
1.0
BEGIN
1.0
CRAP 4.0
« TVRage/Episode.pm ↑ Summary TVRage/ShowList.pm »
1 #===============================================================================
2 # FILE: EpisodeListRequest.pm
3 # AUTHOR: Kyle Brandt (mn), kyle@kbrandt.com , http://www.kbrandt.com
4 # COMPANY: Home
5 #===============================================================================
6  
7 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 package WebService::TVRage::EpisodeListRequest;
11 1 ▶use Mouse;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use LWP::UserAgent;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use HTTP::Request::Common;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 ▶use XML::Simple;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 1 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 1 ▶use WebService::TVRage::EpisodeList;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 1 has 'episodeID' => ( is => 'rw');
18 1 has 'URL' => ( is => 'rw',
19 default => 'http://www.tvrage.com/feeds/episode_list.php?sid=');
20  
21 0 ▶sub getEpisodeList {
Subroutine getEpisodeList: not called CC=3 SCAR=24.8
Pod documented
22 0 my $self = shift;
23 0 my $uA = LWP::UserAgent->new( timeout => 20);
24 0 my $episodeListReq = HTTP::Request->new(GET => $self->URL . $self->episodeID);
25 0 my $episodeListResponse = $uA->request($episodeListReq);
26 0 ▶ print $episodeListResponse->error_as_HTML unless $episodeListResponse->is_success;
Branch: 1 branch
BranchTrueFalseTotal
unless $episodeListResponse->is_success 0 0 0
27 0 my $xml = new XML::Simple;
28 0 my $processedXML = $xml->XMLin( $episodeListResponse->decoded_content, (ForceArray => ['Season', 'episode']));
29 #return undef if ref $processedXML->{name};
30 0 ▶ return undef unless defined $processedXML->{Episodelist};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $processedXML->{"Episodelist"} 0 0 0
31 0 my $object = WebService::TVRage::EpisodeList->new();
32 0 $object->_episodeListHash($processedXML);
33 0 return $object;
34 }
35  
36 1 1;
37  
38 =head1 NAME
39  
40 WebService::TVRage::EpisodeListRequest - Requests A List of Episodes for a show using TVRage's XML Service
41  
42 =head1 SYNOPSIS
43
44 my $heroes = WebService::TVRage::EpisodeListRequest->new();
45 $heroes->episodeID('8172');
46 my $episodeList = $heroes->getEpisodeList();
47  
48 =head1 Methods
49  
50 =head2 new()
51  
52 my $heroes = WebService::TVRage::EpisodeListRequest->new( episodeID => '8172');
53  
54 Constructor object for creating a request to get episode information for the specified show.
55  
56 =over 1
57  
58 =item episodeID
59
60 This is the TVRage's ID for ths show. Use WebService::TVRage::ShowSearchRequest to find out what the id of your show is.
61
62 =item URL
63
64 This is the TVRage URL that the request gets sent to, you shouldn't need to edit this.
65
66 =back
67  
68 =head2 getEpisodeList()
69  
70 $heroes->getEpisodeList()
71  
72 Sends a request to TVRage for which ever show you specified with episodeID and returns a WebService::TVRage::EpisodeList object
73  
74 =head1 AUTHOR
75  
76 Kyle Brandt, kyle@kbrandt.com
77 http://www.kbrandt.com
78  
79 =cut
80  
81  
« TVRage/Episode.pm ↑ Summary TVRage/ShowList.pm »