| 1 | package Net::Google::Calendar::FeedLink; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | { | ||||||||||||||||||||||||||||||||||||||||||
| 3 | 6 | $Net::Google::Calendar::FeedLink::VERSION = '1.05'; | |||||||||||||||||||||||||||||||||||||||||
| 4 | } | ||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | 6 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 6 | ▶ | use XML::Atom::Feed; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 6 | ▶ | use XML::Atom::Link; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 6 | ▶ | use base qw(XML::Atom::Link Net::Google::Calendar::Base); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 6 | ▶ | use LWP::Simple qw(get); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||
| 14 | Net::Google::Calendar::FeedLink - represents a link to a feed | ||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||
| 16 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | my @feeds = $comments->feeds; | ||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||
| 20 | foreach my $feed (@feeds) { | ||||||||||||||||||||||||||||||||||||||||||
| 21 | print "There are ".$feed->count_hint." comments in this feed\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 22 | print "Is this feed read only? ".$feed->read_only."\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 23 | print "This feed ".(($feed->href)? "is" : "isn't" )." remote\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 24 | print "This feed is of type ".$feed->rel."\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||
| 26 | my $atom = $cal->get_feed($feed->feed); # $obj is an XML::Atom::Feed | ||||||||||||||||||||||||||||||||||||||||||
| 27 | foreach my $comment ($atom->entries) { | ||||||||||||||||||||||||||||||||||||||||||
| 28 | print "\t".$comment->title."\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||
| 32 | =head1 METHODS | ||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||
| 34 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||
| 36 | =head2 new | ||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||
| 38 | Create a new FeedLink | ||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||
| 40 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | return $class->SUPER::new(@_); | |||||||||||||||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||
| 47 | =head2 count_hint | ||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||
| 49 | Hints at the number of entries in the feed. | ||||||||||||||||||||||||||||||||||||||||||
| 50 | Depending on the implementation, may not be a precise count. | ||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||
| 52 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | ▶ | sub count_hint { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
count_hint: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | return $self->_do('@countHint', @_); | |||||||||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||
| 59 | =head2 element_name | ||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||
| 61 | Return our Element name | ||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||
| 63 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | ▶ | sub element_name { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
element_name: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | return 'gd:feedLink'; | |||||||||||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||
| 69 | =head2 read_only [boolean] | ||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||
| 71 | Specifies whether the contained feed is read-only. | ||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||
| 73 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | ▶ | sub read_only { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
read_only: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | ▶ | if (@_) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | my $val = @_; | |||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | ▶ | push @_, ($val)? 'true' : 'false'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | return _convert_bool($self->_do('@readOnly', @_)); | |||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | ▶ | sub _convert_bool { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_convert_bool: not called CC=8 SCAR=42.8
| |||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | my $val = shift; | |||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | ▶ | return '' if !defined $val; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | ▶ | return $val if ($val =~ m!^(\d+)$! && ($val==0 or $val==1)); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$val =~ /^(\d+)$/ and $val == 0 || $val == 1
$val == 0 or $val == 1
MC/DC0%0/3
$val =~ /^(\d+)$/ and $val == 0 || $val == 1
$val =~ /^(\d+)$/
$val == 0
$val == 1
Truth table0%0/4
A and B or C
A= $val =~ /^(\d+)$/B= $val == 0C= $val == 1
| |||||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | ▶ | return 0 if $val eq 'false'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | ▶ | return 1 if $val eq 'true'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 90 | #die "Illegal boolean value $val"; | ||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | ▶ | return ($val)? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||
| 94 | =head2 rel [rel] | ||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||
| 96 | Specifies the link relation; allows the service to provide | ||||||||||||||||||||||||||||||||||||||||||
| 97 | multiple types of feed links for a single entity. Has the | ||||||||||||||||||||||||||||||||||||||||||
| 98 | same semantics and allowed values as the rel attribute of | ||||||||||||||||||||||||||||||||||||||||||
| 99 | the <atom:link> element. | ||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||
| 101 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | ▶ | sub rel { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
rel: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | return $self->_do('@rel', @_); | |||||||||||||||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||
| 109 | =head2 href [url] | ||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||
| 111 | Specifies the feed URI. If the nested feed is embedded and not | ||||||||||||||||||||||||||||||||||||||||||
| 112 | linked, this attribute may be omitted. | ||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||
| 114 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | ▶ | sub href { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
href: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | return URI->new($self->_do('@href')); | |||||||||||||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | ▶ | sub _do { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_do: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | my $name = shift; | |||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | my $attr = ($name =~ s!^@!!); | |||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | my $gd_ns = ''; # $self->{_gd_ns}; | |||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | ▶ | if (@_) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | my $new = shift; | |||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | ▶ | if ($attr) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | $self->set_attr($name, $new); | |||||||||||||||||||||||||||||||||||||||||
| 131 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | $self->set($gd_ns, "${name}", '', { value => "${new}" }); | |||||||||||||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | my $val; | |||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | ▶ | if ($attr) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | $val = $self->get_attr($name); | |||||||||||||||||||||||||||||||||||||||||
| 138 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | $val = $self->_my_get($gd_ns, "${name}"); | |||||||||||||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | return $val; | |||||||||||||||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||
| 144 | =head2 feed [feed] | ||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||
| 146 | Get the Atom feed. | ||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||
| 148 | Returns a URI object if the feed is remote | ||||||||||||||||||||||||||||||||||||||||||
| 149 | or a scalar containing an XML::Atom::Feed object | ||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||
| 151 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | ▶ | sub feed { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
feed: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | my $ns = ""; # "http://purl.org/atom/ns#"; | |||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | ▶ | if (@_) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | my $feed = shift; | |||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | XML::Atom::Base::set($self, $ns, 'feed', $feed, {}); | |||||||||||||||||||||||||||||||||||||||||
| 159 | #$self->add($ns, 'feed', $feed, {}); | ||||||||||||||||||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | my $href = $self->href; | |||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | ▶ | if (defined $href) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | return URI->new($href); | |||||||||||||||||||||||||||||||||||||||||
| 164 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | ▶ | my $feed = $self->_do('feed') || return; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->_do('feed') || (return)
MC/DC0%0/1
$self->_do('feed') || (return)
$self->_do('feed')
Truth table0%0/2
A
A= $self->_do('feed')
| |||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | my $tmp = XML::Atom::Feed->new( Elem => $feed ); | |||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | $tmp->{ns} = $ns; | |||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | return $tmp; | |||||||||||||||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||||||||||||||||
| 171 | 6 | 1; | |||||||||||||||||||||||||||||||||||||||||