Code/AtomParser.pm

filter: Statementstmt 100% 32 / 32 Branchbran 87.5% 7 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 100% 2 / 2 totaltotal 97.9% 47 / 48 CC 5 SCAR 11.0
CC
5
Cov
98%
parse
5.0
BEGIN
1.0
BEGIN
1.0
CRAP 3.0
« Code/Wiki.pm ↑ Summary Code/DateTime.pm »
1 package Net::Google::Code::AtomParser;
2 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 2 ▶use Params::Validate ':all';
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use HTML::Entities;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 4 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
9 4 my $class = shift;
10 4 bless \(my $a), $class;
11 }
12  
13 4 ▶sub parse {
Subroutine parse: called CC=5 SCAR=16.1
Pod documented
14 4 my $self = shift;
15 4 my ($content) = validate_pos( @_, 1 );
16  
17 4 my $feed = {};
18 4 my $entries = [];
19  
20 4 ▶ if ( $content =~ /<feed .*?>(.*?)<entry>/s ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($content =~ /<feed .*?>(.*?)<entry>/s) 4 0 4
21 4 my $feed_info = $1;
22 4 ▶ while ( $feed_info =~ m{<(?!link)(\w+).*?>(.*)</\1>}sg ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($feed_info =~ m[<(?!link)(\w+).*?>(.*)</\1>]gs) 12 4 16
23 12 $feed->{$1} = decode_entities($2);
24 }
25 }
26  
27 4 ▶ while ( $content =~ m{<entry>(.*?)</entry>}sg ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($content =~ m[<entry>(.*?)</entry>]gs) 80 4 84
28 80 my $entry_info = $1;
29 80 my $entry = {};
30 80 ▶ while ( $entry_info =~ m{<(?!link)(\w+).*?>(.*)</\1>}sg ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($entry_info =~ m[<(?!link)(\w+).*?>(.*)</\1>]gs) 400 80 480
31 400 my $value = $2;
32 400 $value =~ s!\s*<(\w+)>(.*?)</\1>\s*!$2!g;
33 400 $entry->{$1} = decode_entities($value);
34 }
35 80 push @$entries, $entry;
36 }
37 4 return ( $feed, $entries );
38 }
39  
40 2 1;
41  
42 __END__
« Code/Wiki.pm ↑ Summary Code/DateTime.pm »