blib/lib/Net/Google/PicasaWeb/Feed.pm untested

filter: Statementstmt 0.0% 0 / 29 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 3 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 4 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 45 CC 5 SCAR 29.7
CC
5
Cov
0%
from_feed
30.0
BEGIN
2.0
BEGIN
2.0
CRAP 19.5
1 use strict;
2 use warnings;
3  
4 package Net::Google::PicasaWeb::Feed;
5 use Moose;
6  
7 extends 'Net::Google::PicasaWeb::Base';
8  
9 =head1 NAME
10  
11 Net::Google::PicasaWeb::Feed - base class for feed entries
12  
13 =head1 DESCRIPTION
14  
15 Provides some common functions for feed-based objects.
16  
17 =cut
18  
19 has url => (
20 is => 'rw',
21 isa => 'Str',
22 );
23  
24 has title => (
25 is => 'rw',
26 isa => 'Str',
27 );
28  
29 has summary => (
30 is => 'rw',
31 isa => 'Str',
32 );
33  
34 has author_name => (
35 is => 'rw',
36 isa => 'Str',
37 );
38  
39 has author_uri => (
40 is => 'rw',
41 isa => 'Str',
42 );
43  
44 has entry_id => (
45 is => 'rw',
46 isa => 'Str',
47 );
48  
49 has user_id => (
50 is => 'rw',
51 isa => 'Str',
52 );
53  
54 =head1 METHODS
55  
56 =head2 from_feed
57  
58 my $feed = $class->from_feed($service, $entry);
59  
60 This method creates the feed object from the service object and an L<XML::Twig::Elt> representing the element returned descring that object.
61  
62 =cut
63  
64 sub from_feed {
65 my ($class, $service, $entry) = @_;
66  
67 my $url = $entry->field('id');
68 $url =~ s/^\s+//; $url =~ s/\s+$//;
69 $url =~ s{/data/entry/}{/data/feed/};
70  
71 my %params = (
72 service => $service,
73 twig => $entry,
74 url => $url,
75 title => $entry->field('title'),
76 summary => $entry->field('summary'),
77 entry_id => $entry->field('gphoto:id'),
78 user_id => $entry->field('gphoto:user'),
79 );
80  
81 if (my $author = $entry->first_child('author')) {
82 $params{author_name} = $author->field('name')
83 if $author->has_child('name');
84 $params{author_uri} = $author->field('uri')
85 if $author->has_child('uri');
86 $params{user_id} ||= $author->field('gphoto:user')
87 if $author->has_child('gphoto:user');
88 }
89  
90 return $class->new(\%params);
91 }
92  
93 =head1 AUTHOR
94  
95 Andrew Sterling Hanenkamp, C<< <hanenkamp at cpan.org> >>
96  
97 =head1 COPYRIGHT & LICENSE
98  
99 Copyright 2008 Andrew Sterling Hanenkamp
100  
101 This program is free software; you can redistribute it and/or modify it
102 under the same terms as Perl itself.
103  
104 =cut
105  
106 1;