File Coverage

blib/lib/Feed/Data/Parser/RSS.pm
Criterion Covered Total %
statement 20 22 90.9
branch 1 4 25.0
condition 1 3 33.3
subroutine 7 7 100.0
pod 0 1 0.0
total 29 37 78.3


line stmt bran cond sub pod time code
1             package Feed::Data::Parser::RSS;
2              
3 6     6   5322 use Moo;
  6         13  
  6         50  
4             extends 'Feed::Data::Parser::Base';
5 6     6   3030 use XML::RSS::LibXML;
  6         14  
  6         149  
6 6     6   4541 use Ref::Util ':all';
  6         4838  
  6         1883  
7 6     6   52 use Compiled::Params::OO qw/cpo/;
  6         14  
  6         117  
8 6     6   768 use Types::Standard qw/Object HashRef Str/;
  6         74  
  6         131  
9              
10             our $validate;
11             BEGIN {
12 6     6   23929 $validate = cpo(
13             get_value => [Object, HashRef, Str],
14             );
15             }
16              
17             has '+parser' => (
18             default => sub {
19             my $self = shift;
20             return XML::RSS::LibXML->new->parse($self->content_ref);
21             },
22             );
23              
24             sub get_value {
25 132     132 0 350 my ($self, $item, $action) = $validate->get_value->(@_);
26            
27 132         1384 my $value = $item->{$action};
28              
29 132 50 33     348 if ( is_scalarref(\$value) || is_arrayref($value) ){
    0          
30 132         397 return $value;
31             }
32             elsif ( is_hashref($value) ){
33 0           return $value->{encoded};
34             }
35            
36 0           return '';
37             }
38              
39             1; # End of Feed::Data