FOXSports.pm

filter: Statementstmt 45.1% 56 / 124 Branchbran 7.6% 6 / 78 Conditioncond 20.0% 1 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 50.0% 19 / 38 Podpod 73.3% 11 / 15 totaltotal 35.3% 93 / 263 CC 42 SCAR 26.2
CC
42
Cov
30%
AUTOLOAD
53.4
parse_team
30.0
__ANON__
20.0
CRAP 13.8
↑ Summary FOXSports/Utils.pm »
1 #=========================================================i======================
2 # Copyright (c) Brian Perez 2005. All rights reserved.
3 #--------------------------------------------------------------------------------
4 # This library is free software; you can redistribute it
5 # and/or modify it under the same terms as Perl itself.
6 #================================================================================
7 package XML::RSS::FOXSports;
8  
9 1 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 1 ▶use XML::RSS::Parser;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 ▶use base qw(XML::RSS::Parser);
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 1 ▶use LWP::UserAgent;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 1 ▶use XML::RSS::FOXSports::Constants qw(:feed_urls HEADLINE_BASE_URL TEAM_TO_ID);
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 1 our $VERSION = '0.02';
21  
22 1 my $ua = LWP::UserAgent->new();
23 1 $ua->agent('XML::RSS::FOXSports/'.$VERSION);
24  
25 1 my $DEBUG = 0;
26  
27 1 ▶sub new {
Subroutine new: called CC=5 SCAR=17.3
Pod documented
28 1 my $proto = shift;
29 1 ▶ my $class = ref($proto) || $proto;
Condition33%1/3
ref $proto || $proto
l!l&&r!l&&!r
010
MC/DC0%0/2
ref $proto || $proto
ref $proto $proto
Truth table33%1/3
A || B
A= ref $protoB= $proto
ABresult
1X1
011
000
30 1 my %opts = @_;
31 1 my $self = $class->SUPER::new();
32 1 ▶ $self->_set_fsutil unless $opts{NoUtil};
Branch: 1 branch
BranchTrueFalseTotal
unless $opts{"NoUtil"} 1 0 1
33 1 ▶ $self->_set_fsmeta if $opts{Meta};
Branch: 1 branch
BranchTrueFalseTotal
if $opts{"Meta"} 0 1 1
34 1 ▶ $self->_set_debug if $opts{Debug};
Branch: 1 branch
BranchTrueFalseTotal
if $opts{"Debug"} 0 1 1
35 1 return $self;
36 }
37  
38 #-- AUTOLOAD ------
39 #-- used for method proxies
40 0 ▶sub AUTOLOAD {
Subroutine AUTOLOAD: not called CC=8 SCAR=39.8
41 0 our $AUTOLOAD;
42 0 my ($method, $feed);
43 0 ($method = $AUTOLOAD) =~ s/.*:://;
44 0 ▶ warn "[dbg] method called: $method" if $DEBUG;
Branch: 1 branch
BranchTrueFalseTotal
if $DEBUG 0 0 0
45 0 ▶ die "$method is not a currently supported method" unless $method =~ /^parse_/;
Branch: 1 branch
BranchTrueFalseTotal
unless $method =~ /^parse_/ 0 0 0
46 0 $feed = uc ((split('_', $method, 2))[1]);
47 #-- headlines ----
48 0 ▶ if (defined HEADLINE_FEED_URLS->{$feed}) {
Branch: 3 branches
BranchTrueFalseTotal
if (defined {BASEBALL => 'http://msn.foxsports.com/feedout/syndicatedContent?categoryId=49', BASKETBALL => 'http://msn.foxsports.com/feedout/syndicatedContent?categoryId=73', COLLEGE_BASKETBALL => 'http://msn.foxsports.com/feedout/syndicatedContent?categoryId=24', COLLEGE_FOOTBALL => 'http://msn.foxsports.com/feedout/syndicatedContent?categoryId=99', FOOTBALL => 'http://msn.foxsports.com/feedout/syndicatedContent?categoryId=5', GOLF => 'http://msn.foxsports.com/feedout/syndicatedContent?categoryId=220', HEADLINES => 'http://msn.foxsports.com/feedout/syndicatedContent?categoryId=0', HOCKEY => 'http://msn.foxsports.com/feedout/syndicatedContent?categoryId=142', HORSERACING => 'http://msn.foxsports.com/feedout/syndicatedContent?categoryId=241', MLB => 'http://msn.foxsports.com/feedout/syndicatedContent?categoryId=49', NASCAR => 'http://msn.foxsports.com/feedout/syndicatedContent?categoryId=167', NBA => 'http://msn.foxsports.com/feedout/syndicatedContent?categoryId=73', NCAA_BK => 'http://msn.foxsports.com/feedout/syndicatedContent?categoryId=99', NCAA_FB => 'http://msn.foxsports.com/feedout/syndicatedContent?categoryId=24', NFL => 'http://msn.foxsports.com/feedout/syndicatedContent?categoryId=5', NHL => 'http://msn.foxsports.com/feedout/syndicatedContent?categoryId=142', SOCCER => 'http://msn.foxsports.com/feedout/syndicatedContent?categoryId=176', TENNIS => 'http://msn.foxsports.com/feedout/syndicatedContent?categoryId=199', WNBA => 'http://msn.foxsports.com/feedout/syndicatedContent?categoryId=90'}->{$feed}) { } 0 0 0
elsif (defined {BASEBALL_VIDEO => 'http://rss.video.msn.com/s/us/rss.aspx?t=Fox%20Sports&p=33&c=Baseball%20News&title=Fox%20Sports%20video%20-%20Baseball%20News', BASKETBALL_VIDEO => 'http://rss.video.msn.com/s/us/rss.aspx?t=Fox%20Sports&p=33&c=NBA%20News&title=Fox%20Sports%20video%20-%20NBA%20news', COLLEGE_BASKETBALL_VIDEO => 'http://rss.video.msn.com/s/us/rss.aspx?t=Fox%20Sports&p=33&c=College%20BK%20News&title=Fox%20Sports%20video%20-%20College%20BK%20News', COLLEGE_FOOTBALL_VIDEO => 'http://rss.video.msn.com/s/us/rss.aspx?t=Fox%20Sports&p=33&c=College%20FB%20News&title=Fox%20Sports%20video%20-%20College%20FB%20News', FOOTBALL_VIDEO => 'http://rss.video.msn.com/s/us/rss.aspx?t=Fox%20Sports&p=33&c=NFL%20News&title=Fox%20Sports%20video%20-%20NFL%20news', HOCKEY_VIDEO => 'http://rss.video.msn.com/s/us/rss.aspx?t=Fox%20Sports&p=33&c=Hockey%20News&title=Fox%20Sports%20video%20-%20Hockey%20news', MLB_VIDEO => 'http://rss.video.msn.com/s/us/rss.aspx?t=Fox%20Sports&p=33&c=Baseball%20News&title=Fox%20Sports%20video%20-%20Baseball%20News', MORE_VIDEO => 'http://rss.video.msn.com/s/us/rss.aspx?t=Fox%20Sports&p=33&c=More%20Fox%20Sports&title=Fox%20Sports%20video%20-%20More%20Fox%20Sports%25', MOST_WATCHED_VIDEO => 'http://rss.video.msn.com/s/us/rss.aspx?t=hotVideo&c=topsports&title=%20MSN%20Video%20-%20sports&p=05', NBA_VIDEO => 'http://rss.video.msn.com/s/us/rss.aspx?t=Fox%20Sports&p=33&c=NBA%20News&title=Fox%20Sports%20video%20-%20NBA%20news', NCAA_BK_VIDEO => 'http://rss.video.msn.com/s/us/rss.aspx?t=Fox%20Sports&p=33&c=College%20BK%20News&title=Fox%20Sports%20video%20-%20College%20BK%20News', NCAA_FB_VIDEO => 'http://rss.video.msn.com/s/us/rss.aspx?t=Fox%20Sports&p=33&c=College%20FB%20News&title=Fox%20Sports%20video%20-%20College%20FB%20News', NFL_VIDEO => 'http://rss.video.msn.com/s/us/rss.aspx?t=Fox%20Sports&p=33&c=NFL%20News&title=Fox%20Sports%20video%20-%20NFL%20news', NHL_VIDEO => 'http://rss.video.msn.com/s/us/rss.aspx?t=Fox%20Sports&p=33&c=Hockey%20News&title=Fox%20Sports%20video%20-%20Hockey%20news', TOP_NEWS_VIDEO => 'http://rss.video.msn.com/s/us/rss.aspx?t=Fox%20Sports&p=33&c=Top%20News&title=Fox%20Sports%20video%20-%20Top%20news'}->{$feed}) { } 0 0 0
elsif ($feed =~ /_TEAM$/) { } 0 0 0
49 {
50 0 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.2
51 0 *{$AUTOLOAD} =
52 0 ▶ sub {
Subroutine __ANON__: not called CC=4 SCAR=30.0
53 0 my ($rss_xml, $message) = $_[0]->_get_rss_feed(HEADLINE_FEED_URLS->{$feed});
54 0 ▶ croak "rss xml feed is empty with message $message" unless defined $rss_xml;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $rss_xml 0 0 0
55 0 ▶ $_[0]->_save_meta_data($feed, HEADLINE_FEED_URLS->{$feed}) if $_[0]->{_fsmeta};
Branch: 1 branch
BranchTrueFalseTotal
if $_[0]{"_fsmeta"} 0 0 0
56 #-- for xml::rss::parser 4.0 compatibility
57 0 ▶ return $_[0]->SUPER::parse_string($rss_xml) if $_[0]->SUPER::can('parse_string');
Branch: 1 branch
BranchTrueFalseTotal
if $_[0]->SUPER::can("parse_string") 0 0 0
58 0 return $_[0]->SUPER::parse($rss_xml);
59 0 };
60 0 goto &{$AUTOLOAD};
61 }
62 }
63 #-- video ----
64 elsif (defined VIDEO_FEED_URLS->{$feed}) {
65 {
66 0 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.2
67 0 *{$AUTOLOAD} =
68 0 ▶ sub {
Subroutine __ANON__: not called CC=4 SCAR=30.0
69 0 my ($rss_xml, $message) = $_[0]->_get_rss_feed(VIDEO_FEED_URLS->{$feed});
70 0 ▶ croak "rss xml feed is empty with message $message" unless defined $rss_xml;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $rss_xml 0 0 0
71 0 ▶ $_[0]->_save_meta_data($feed, VIDEO_FEED_URLS->{$feed}) if $_[0]->{_fsmeta};
Branch: 1 branch
BranchTrueFalseTotal
if $_[0]{"_fsmeta"} 0 0 0
72 #-- for xml::rss::parser 4.0 compatibility
73 0 ▶ return $_[0]->SUPER::parse_string($rss_xml) if $_[0]->SUPER::can('parse_string');
Branch: 1 branch
BranchTrueFalseTotal
if $_[0]->SUPER::can("parse_string") 0 0 0
74 0 return $_[0]->SUPER::parse($rss_xml);
75 0 };
76 0 goto &{$AUTOLOAD};
77 }
78 } #-- specific team (e.g., Giants, 49ers, Galaxy)
79 elsif ($feed =~ /_TEAM$/) {
80 0 my ($league, $ext) = split('_', $feed, 2);
81 0 ▶ if (defined TEAM_TO_ID->{$league}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined {"MLB" => {"angels" => 71589,"astros" => 71604,"athletics" => 71597,"blue_jays" => 71600,"braves" => 71601,"brewers" => 71594,"cardinals" => 71610,"cubs" => 71602,"devil_rays" => 71616,"diamondbacks" => 71615,"dodgers" => 71605,"giants" => 71612,"indians" => 71591,"mariners" => 71598,"marlins" => 71614,"mets" => 71607,"nationals" => 71606,"orioles" => 71587,"padres" => 71611,"phillies" => 71608,"pirates" => 71609,"rangers" => 71599,"red_sox" => 71588,"reds" => 71603,"rockies" => 71613,"royals" => 71593,"tigers" => 71592,"twins" => 71595,"white_sox" => 71590,"yankees" => 71596},"MLS" => {"chicago" => 375,"chivas" => 3465,"chivas_usa" => 3465,"colorado" => 379,"columbus" => 376,"crew" => 376,"dallas" => 377,"dc_united" => 371,"earthquakes" => 382,"fc_dallas" => 377,"fire" => 375,"galaxy" => 381,"kansas_city" => 380,"los_angeles" => 381,"metros" => 374,"metrostars" => 374,"new_england" => 373,"quakes" => 382,"rapids" => 379,"real_salt_lake" => 2422,"revolution" => 373,"revs" => 373,"rsl" => 2422,"san_jose" => 382,"united" => 371,"wizards" => 380},"NBA" => {"bobcats" => 71951,"bucks" => 71089,"bulls" => 71078,"cavaliers" => 71079,"celtics" => 71076,"clippers" => 71086,"grizzlies" => 71103,"hawks" => 71075,"heat" => 71088,"hornets" => 71077,"jazz" => 71100,"kings" => 71097,"knicks" => 71092,"lakers" => 71087,"magic" => 71093,"mavericks" => 71080,"nets" => 71091,"nuggets" => 71081,"pacers" => 71085,"pistons" => 71082,"raptors" => 71102,"rockets" => 71084,"sixers" => 71094,"spurs" => 71098,"suns" => 71095,"supersonics" => 71099,"timberwolves" => 71090,"trail_blazers" => 71096,"warriors" => 71083,"wizards" => 71101},"NFL" => {"bears" => 67040,"bengals" => 67041,"bills" => 67039,"broncos" => 67044,"browns" => 67042,"buccaneers" => 67061,"cardinals" => 67066,"chargers" => 67068,"chiefs" => 67049,"colts" => 67048,"cowboys" => 67043,"dolphins" => 67052,"eagles" => 67058,"falcons" => 67038,"forty_niners" => 67059,"giants" => 67056,"jaguars" => 67064,"jets" => 67057,"lions" => 67045,"niners" => 67059,"packers" => 67046,"panthers" => 67063,"patriots" => 67054,"raiders" => 67050,"rams" => 67051,"ravens" => 67065,"redskins" => 67062,"saints" => 67055,"seahawks" => 67060,"steelers" => 67067,"texans" => 67071,"titans" => 67047,"vikings" => 67053},"NHL" => {"avalanche" => 66316,"blackhawks" => 66303,"blue_jackets" => 66328,"blues" => 66318,"bruins" => 66300,"canadiens" => 66309,"canucks" => 66321,"capitals" => 66322,"coyotes" => 66323,"devils" => 66310,"flames" => 66302,"flyers" => 66314,"hurricanes" => 66306,"islanders" => 66311,"kings" => 66307,"lightning" => 66319,"maple_leafs" => 66320,"mighty_ducks" => 66324,"oilers" => 66305,"panthers" => 66325,"penguins" => 66315,"predators" => 66326,"rangers" => 66312,"red_wings" => 66304,"sabres" => 66301,"senators" => 66313,"sharks" => 66317,"stars" => 66308,"thrashers" => 66327,"wild" => 66329}}->{$league}) 0 0 0
82 0 ▶ croak 'sports team was not found, perhaps you forgot to supply one.' unless defined $_[1];
Branch: 1 branch
BranchTrueFalseTotal
unless defined $_[1] 0 0 0
83 {
84 0 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.2
85 0 *{$AUTOLOAD} =
86 0 ▶ sub {
Subroutine __ANON__: not called CC=4 SCAR=30.0
87 0 my $url = HEADLINE_BASE_URL . TEAM_TO_ID->{$league}->{lc $_[1]};
88 0 my ($rss_xml, $message) = $_[0]->_get_rss_feed($url);
89 0 ▶ croak "rss xml feed is empty with message $message" unless defined $rss_xml;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $rss_xml 0 0 0
90 0 ▶ $_[0]->_save_meta_data($league.'_'.lc $_[1], $url) if $_[0]->{_fsmeta};
Branch: 1 branch
BranchTrueFalseTotal
if $_[0]{"_fsmeta"} 0 0 0
91 #-- for xml::rss::parser 4.0 compatibility
92 0 ▶ return $_[0]->SUPER::parse_string($rss_xml) if $_[0]->SUPER::can('parse_string');
Branch: 1 branch
BranchTrueFalseTotal
if $_[0]->SUPER::can("parse_string") 0 0 0
93 0 return $_[0]->SUPER::parse($rss_xml);
94 0 };
95 0 goto &{$AUTOLOAD};
96 }
97 }
98 }
99 else {
100 0 die "$method is not a currently supported method";
101 }
102 }
103  
104 #-- parse_team ------
105 0 ▶sub parse_team {
Subroutine parse_team: not called CC=5 SCAR=34.0
Pod documented
106 0 ▶ warn "[dbg] (parse_team) league:$_[1] team:$_[2]" if $DEBUG;
Branch: 1 branch
BranchTrueFalseTotal
if $DEBUG 0 0 0
107 0 ▶ TEAM_TO_ID->{uc $_[1]} or die "the league $_[1] is not currently available";
Branch: 1 branch
BranchTrueFalseTotal
{"MLB" => {"angels" => 71589,"astros" => 71604,"athletics" => 71597,"blue_jays" => 71600,"braves" => 71601,"brewers" => 71594,"cardinals" => 71610,"cubs" => 71602,"devil_rays" => 71616,"diamondbacks" => 71615,"dodgers" => 71605,"giants" => 71612,"indians" => 71591,"mariners" => 71598,"marlins" => 71614,"mets" => 71607,"nationals" => 71606,"orioles" => 71587,"padres" => 71611,"phillies" => 71608,"pirates" => 71609,"rangers" => 71599,"red_sox" => 71588,"reds" => 71603,"rockies" => 71613,"royals" => 71593,"tigers" => 71592,"twins" => 71595,"white_sox" => 71590,"yankees" => 71596},"MLS" => {"chicago" => 375,"chivas" => 3465,"chivas_usa" => 3465,"colorado" => 379,"columbus" => 376,"crew" => 376,"dallas" => 377,"dc_united" => 371,"earthquakes" => 382,"fc_dallas" => 377,"fire" => 375,"galaxy" => 381,"kansas_city" => 380,"los_angeles" => 381,"metros" => 374,"metrostars" => 374,"new_england" => 373,"quakes" => 382,"rapids" => 379,"real_salt_lake" => 2422,"revolution" => 373,"revs" => 373,"rsl" => 2422,"san_jose" => 382,"united" => 371,"wizards" => 380},"NBA" => {"bobcats" => 71951,"bucks" => 71089,"bulls" => 71078,"cavaliers" => 71079,"celtics" => 71076,"clippers" => 71086,"grizzlies" => 71103,"hawks" => 71075,"heat" => 71088,"hornets" => 71077,"jazz" => 71100,"kings" => 71097,"knicks" => 71092,"lakers" => 71087,"magic" => 71093,"mavericks" => 71080,"nets" => 71091,"nuggets" => 71081,"pacers" => 71085,"pistons" => 71082,"raptors" => 71102,"rockets" => 71084,"sixers" => 71094,"spurs" => 71098,"suns" => 71095,"supersonics" => 71099,"timberwolves" => 71090,"trail_blazers" => 71096,"warriors" => 71083,"wizards" => 71101},"NFL" => {"bears" => 67040,"bengals" => 67041,"bills" => 67039,"broncos" => 67044,"browns" => 67042,"buccaneers" => 67061,"cardinals" => 67066,"chargers" => 67068,"chiefs" => 67049,"colts" => 67048,"cowboys" => 67043,"dolphins" => 67052,"eagles" => 67058,"falcons" => 67038,"forty_niners" => 67059,"giants" => 67056,"jaguars" => 67064,"jets" => 67057,"lions" => 67045,"niners" => 67059,"packers" => 67046,"panthers" => 67063,"patriots" => 67054,"raiders" => 67050,"rams" => 67051,"ravens" => 67065,"redskins" => 67062,"saints" => 67055,"seahawks" => 67060,"steelers" => 67067,"texans" => 67071,"titans" => 67047,"vikings" => 67053},"NHL" => {"avalanche" => 66316,"blackhawks" => 66303,"blue_jackets" => 66328,"blues" => 66318,"bruins" => 66300,"canadiens" => 66309,"canucks" => 66321,"capitals" => 66322,"coyotes" => 66323,"devils" => 66310,"flames" => 66302,"flyers" => 66314,"hurricanes" => 66306,"islanders" => 66311,"kings" => 66307,"lightning" => 66319,"maple_leafs" => 66320,"mighty_ducks" => 66324,"oilers" => 66305,"panthers" => 66325,"penguins" => 66315,"predators" => 66326,"rangers" => 66312,"red_wings" => 66304,"sabres" => 66301,"senators" => 66313,"sharks" => 66317,"stars" => 66308,"thrashers" => 66327,"wild" => 66329}}->{uc $_[1]} or die "the league $_[1] is not currently available" 0 0 0
108 0 ▶ TEAM_TO_ID->{uc $_[1]}{lc $_[2]} or die "the team $_[2] is not currently available";
Branch: 1 branch
BranchTrueFalseTotal
{"MLB" => {"angels" => 71589,"astros" => 71604,"athletics" => 71597,"blue_jays" => 71600,"braves" => 71601,"brewers" => 71594,"cardinals" => 71610,"cubs" => 71602,"devil_rays" => 71616,"diamondbacks" => 71615,"dodgers" => 71605,"giants" => 71612,"indians" => 71591,"mariners" => 71598,"marlins" => 71614,"mets" => 71607,"nationals" => 71606,"orioles" => 71587,"padres" => 71611,"phillies" => 71608,"pirates" => 71609,"rangers" => 71599,"red_sox" => 71588,"reds" => 71603,"rockies" => 71613,"royals" => 71593,"tigers" => 71592,"twins" => 71595,"white_sox" => 71590,"yankees" => 71596},"MLS" => {"chicago" => 375,"chivas" => 3465,"chivas_usa" => 3465,"colorado" => 379,"columbus" => 376,"crew" => 376,"dallas" => 377,"dc_united" => 371,"earthquakes" => 382,"fc_dallas" => 377,"fire" => 375,"galaxy" => 381,"kansas_city" => 380,"los_angeles" => 381,"metros" => 374,"metrostars" => 374,"new_england" => 373,"quakes" => 382,"rapids" => 379,"real_salt_lake" => 2422,"revolution" => 373,"revs" => 373,"rsl" => 2422,"san_jose" => 382,"united" => 371,"wizards" => 380},"NBA" => {"bobcats" => 71951,"bucks" => 71089,"bulls" => 71078,"cavaliers" => 71079,"celtics" => 71076,"clippers" => 71086,"grizzlies" => 71103,"hawks" => 71075,"heat" => 71088,"hornets" => 71077,"jazz" => 71100,"kings" => 71097,"knicks" => 71092,"lakers" => 71087,"magic" => 71093,"mavericks" => 71080,"nets" => 71091,"nuggets" => 71081,"pacers" => 71085,"pistons" => 71082,"raptors" => 71102,"rockets" => 71084,"sixers" => 71094,"spurs" => 71098,"suns" => 71095,"supersonics" => 71099,"timberwolves" => 71090,"trail_blazers" => 71096,"warriors" => 71083,"wizards" => 71101},"NFL" => {"bears" => 67040,"bengals" => 67041,"bills" => 67039,"broncos" => 67044,"browns" => 67042,"buccaneers" => 67061,"cardinals" => 67066,"chargers" => 67068,"chiefs" => 67049,"colts" => 67048,"cowboys" => 67043,"dolphins" => 67052,"eagles" => 67058,"falcons" => 67038,"forty_niners" => 67059,"giants" => 67056,"jaguars" => 67064,"jets" => 67057,"lions" => 67045,"niners" => 67059,"packers" => 67046,"panthers" => 67063,"patriots" => 67054,"raiders" => 67050,"rams" => 67051,"ravens" => 67065,"redskins" => 67062,"saints" => 67055,"seahawks" => 67060,"steelers" => 67067,"texans" => 67071,"titans" => 67047,"vikings" => 67053},"NHL" => {"avalanche" => 66316,"blackhawks" => 66303,"blue_jackets" => 66328,"blues" => 66318,"bruins" => 66300,"canadiens" => 66309,"canucks" => 66321,"capitals" => 66322,"coyotes" => 66323,"devils" => 66310,"flames" => 66302,"flyers" => 66314,"hurricanes" => 66306,"islanders" => 66311,"kings" => 66307,"lightning" => 66319,"maple_leafs" => 66320,"mighty_ducks" => 66324,"oilers" => 66305,"panthers" => 66325,"penguins" => 66315,"predators" => 66326,"rangers" => 66312,"red_wings" => 66304,"sabres" => 66301,"senators" => 66313,"sharks" => 66317,"stars" => 66308,"thrashers" => 66327,"wild" => 66329}}->{uc $_[1]}{lc $_[2]} or die "the team $_[2] is not currently available" 0 0 0
109 0 my $sub = join('','parse_', $_[1], '_team');
110 0 ▶ warn "[dbg] (parse_team) sub:$sub" if $DEBUG;
Branch: 1 branch
BranchTrueFalseTotal
if $DEBUG 0 0 0
111 0 $_[0]->$sub($_[2]);
112 }
113  
114  
115 #-- util methods ------
116 1 ▶sub http_timeout { $_[1] ? $ua->timeout($_[1]) : $ua->timeout }
Subroutine http_timeout: called CC=2 SCAR=7.6
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
$_[1] ? : 0 1 1
117 0 ▶sub last_parsed_url { $_[0]->{_fsmeta}{last_parsed_url} or '' }
Subroutine last_parsed_url: not called CC=2 SCAR=17.9
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
$_[0]{"_fsmeta"}{"last_parsed_url"} or "" 0 0 0
118 0 ▶sub last_parsed_feed { $_[0]->{_fsmeta}{last_parsed_feed} or '' }
Subroutine last_parsed_feed: not called CC=2 SCAR=17.9
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
$_[0]{"_fsmeta"}{"last_parsed_feed"} or "" 0 0 0
119 0 ▶sub parsed_feed { $_[0]->{_fsmeta}{parsed_feeds} or {} }
Subroutine parsed_feed: not called CC=2 SCAR=17.9
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
$_[0]{"_fsmeta"}{"parsed_feeds"} or {} 0 0 0
120  
121 0 ▶sub get_feed_url {
Subroutine get_feed_url: not called CC=2 SCAR=17.9
Pod documented
122 $_[0]->{_fsutil}
123 0 ▶ ? $_[0]->{_fsutil}->get_feed_url($_[1])
Branch: 1 branch
BranchTrueFalseTotal
$_[0]{'_fsutil'} ? : 0 0 0
124 : $_[0]->_na;
125 }
126  
127 0 ▶sub get_feed_urls {
Subroutine get_feed_urls: not called CC=2 SCAR=17.9
Pod documented
128 $_[0]->{_fsutil}
129 ? $_[0]->{_fsutil}->get_feed_urls
130 0 ▶ : $_[0]->_na;
Branch: 1 branch
BranchTrueFalseTotal
$_[0]{'_fsutil'} ? : 0 0 0
131 }
132  
133 0 ▶sub get_available_feeds {
Subroutine get_available_feeds: not called CC=2 SCAR=17.9
Pod documented
134 $_[0]->{_fsutil}
135 ? $_[0]->{_fsutil}->get_available_feeds
136 0 ▶ : $_[0]->_na;
Branch: 1 branch
BranchTrueFalseTotal
$_[0]{'_fsutil'} ? : 0 0 0
137 }
138  
139 0 ▶sub get_available_teams {
Subroutine get_available_teams: not called CC=2 SCAR=17.9
Pod documented
140 $_[0]->{_fsutil}
141 ? $_[0]->{_fsutil}->get_available_teams
142 0 ▶ : $_[0]->_na;
Branch: 1 branch
BranchTrueFalseTotal
$_[0]{'_fsutil'} ? : 0 0 0
143 }
144  
145 1 ▶sub get_available_leagues {
Subroutine get_available_leagues: called CC=2 SCAR=7.6
Pod documented
146 $_[0]->{_fsutil}
147 ? $_[0]->{_fsutil}->get_available_leagues
148 1 ▶ : $_[0]->_na;
Branch: 1 branch
BranchTrueFalseTotal
$_[0]{'_fsutil'} ? : 1 0 1
149 }
150  
151 0 ▶sub get_available_headline_feeds {
Subroutine get_available_headline_feeds: not called CC=2 SCAR=17.9
Pod documented
152 $_[0]->{_fsutil}
153 ? $_[0]->{_fsutil}->get_available_headline_feeds
154 0 ▶ : $_[0]->_na;
Branch: 1 branch
BranchTrueFalseTotal
$_[0]{'_fsutil'} ? : 0 0 0
155 }
156  
157 0 ▶sub get_available_video_feeds {
Subroutine get_available_video_feeds: not called CC=2 SCAR=17.9
Pod documented
158 $_[0]->{_fsutil}
159 ? $_[0]->{_fsutil}->get_available_video_feeds
160 0 ▶ : $_[0]->_na;
Branch: 1 branch
BranchTrueFalseTotal
$_[0]{'_fsutil'} ? : 0 0 0
161 }
162  
163 0 ▶sub get_available_leagues_teams {
Subroutine get_available_leagues_teams: not called CC=2 SCAR=17.9
Pod documented
164 $_[0]->{_fsutil}
165 ? $_[0]->{_fsutil}->get_available_leagues_teams
166 0 ▶ : $_[0]->_na;
Branch: 1 branch
BranchTrueFalseTotal
$_[0]{'_fsutil'} ? : 0 0 0
167 }
168  
169 1 ▶sub debug { $_[1] ? $_[0]->_set_debug($_[1]) : $DEBUG }
Subroutine debug: called CC=2 SCAR=7.6
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
$_[1] ? : 0 1 1
170  
171 1 ▶sub DESTROY {
Subroutine DESTROY: called CC=1 SCAR=0.0
172 1 my $self = shift;
173 1 delete $self->{_fsutil};
174 1 delete $self->{_fsmeta};
175 #$self->SUPER::DESTROY;
176 }
177  
178  
179 #== PRIVATE METHODS ===================================
180  
181 0 ▶sub _get_rss_feed {
Subroutine _get_rss_feed: not called CC=4 SCAR=30.0
182 0 my $res = $ua->get($_[1]);
183 0 ▶ warn "[dbg] url requested: $_[1]" if $DEBUG;
Branch: 1 branch
BranchTrueFalseTotal
if $DEBUG 0 0 0
184 0 ▶ warn "[dbg] status line: $res->status_line" if $DEBUG;
Branch: 1 branch
BranchTrueFalseTotal
if $DEBUG 0 0 0
185 0 ▶ return $res->content, undef if $res->is_success;
Branch: 1 branch
BranchTrueFalseTotal
if $res->is_success 0 0 0
186 0 return undef, $res->status_line;
187 }
188  
189 #-- avoid clashes
190 1 ▶sub _set_fsutil {
Subroutine _set_fsutil: called CC=1 SCAR=0.0
191 1 ▶ use XML::RSS::FOXSports::Utils;
Subroutine BEGIN: called CC=1 SCAR=0.0
192 1 $_[0]->{_fsutil} = XML::RSS::FOXSports::Utils->new();
193 }
194  
195 0 ▶sub _set_fsmeta {
Subroutine _set_fsmeta: not called CC=1 SCAR=6.9
196 $_[0]->{_fsmeta} = {
197 0 last_parsed_feed => '',
198 last_parsed_url => '',
199 parsed_feeds => {},
200 };
201 }
202  
203 1 ▶sub _na { "not available" }
Subroutine _na: called CC=1 SCAR=0.0
204  
205 0 ▶sub _set_debug { $DEBUG = $_[1] || 1; }
Subroutine _set_debug: not called CC=2 SCAR=17.9
Condition0%0/2
$_[1] || 1
l!l
00
MC/DC0%0/1
$_[1] || 1
$_[1]
Truth table0%0/2
A
A= $_[1]
Aresult
11
00
206  
207 0 ▶sub _save_meta_data {
Subroutine _save_meta_data: not called CC=1 SCAR=6.9
208 0 $_[0]->{_fsmeta}{last_parsed_feed} = $_[1];
209 0 $_[0]->{_fsmeta}{last_parsed_url} = $_[2];
210 0 $_[0]->{_fsmeta}{parsed_feeds}{$_[1]}++;
211 }
212  
213  
214 1 1;
215  
216  
217 __END__
↑ Summary FOXSports/Utils.pm »