File Coverage

blib/lib/Egg/Model/FeedPP.pm
Criterion Covered Total %
statement 21 32 65.6
branch 0 2 0.0
condition 0 3 0.0
subroutine 7 11 63.6
pod 1 1 100.0
total 29 49 59.1


line stmt bran cond sub pod time code
1             package Egg::Model::FeedPP;
2             #
3             # Masatoshi Mizuno E<lt>lusheE<64>cpan.orgE<gt>
4             #
5             # $Id: FeedPP.pm 187 2007-08-07 19:00:30Z lushe $
6             #
7 2     2   8833 use strict;
  2         5  
  2         65  
8 2     2   10 use warnings;
  2         3  
  2         61  
9 2     2   11 use Carp qw/croak/;
  2         3  
  2         174  
10 2     2   12 use base qw/Egg::Model/;
  2         4  
  2         1040  
11 2     2   1279 use XML::FeedPP;
  2         34675  
  2         189  
12              
13             our $VERSION = '0.01';
14              
15              
16             =head1 NAME
17              
18             Egg::Model::FeedPP - XML::FeedPP for Egg::Model.
19              
20             =head1 SYNOPSIS
21              
22             configuration.
23              
24             ...
25             MODEL=> [
26             .....
27             [ FeedPP=> {} ],
28             ],
29              
30             example code.
31              
32             my $param= $view->params;
33             my $feed = $e->model('FeedPP')->feed('http://mydomain.name/index.rdf');
34             $param->{rss_title}= $feed->title;
35             $param->{rss_link} = $feed->link;
36             my @items;
37             for $item ($feed->get_item) {
38             push @items, {
39             title=> $item->title,
40             link => $item->link,
41             date => $item->pubDate,
42             };
43             }
44             $param->{rss_items}= \@items;
45              
46             =head1 DESCRIPTION
47              
48             It is a module to use XML::FeedPP with MODEL.
49              
50             The XML::FeedPP object will be usually received by the feed method, and you
51             operate the object directly though you do the method of XML::FeedPP with
52             AUTOLOAD in bind.
53              
54             * Functions other than relaying XML::FeedPP are not provided now.
55              
56             =head1 CONFIGURATION
57              
58             'FeedPP' is added to the setting of MODEL.
59              
60             MODEL => [
61             [ FeedPP => {} ],
62             ],
63              
64             * There is no set item of the option now.
65              
66             =head1 METHODS
67              
68             =cut
69              
70             our $AUTOLOAD;
71              
72             =head2 feed ( [SOURCE] )
73              
74             L<XML::FeedPP> object is returned.
75              
76             SOURCE is an argument passed to the constructor of XML::FeedPP.
77              
78             my $feed= $e->model('FeedPP')->feed('http://domain.name/index.rss');
79              
80             * Please see the document of L<XML::FeedPP> in detail.
81              
82             =cut
83             sub feed {
84 0     0 1   my $model = shift;
85 0   0       my $source= shift || croak q{ I want source. };
86 0           $model->{feed}= XML::FeedPP->new($source);
87             }
88             sub AUTOLOAD {
89 0     0     my $model= shift;
90 0 0         $model->{feed} || croak q{ feed is not prepared. };
91 0           my($method)= $AUTOLOAD=~/([^\:]+)$/;
92 2     2   211 no strict 'refs'; ## no critic
  2         4  
  2         61  
93 2     2   12 no warnings 'redefine';
  2         3  
  2         276  
94 0     0     *{__PACKAGE__."::$method"}= sub { shift->{feed}->$method(@_) };
  0            
  0            
95 0           $model->$method(@_);
96             }
97 0     0     sub DESTROY { }
98              
99             =head1 SEE ALSO
100              
101             L<XML::FeedPP>,
102             L<Egg::Release>,
103              
104             =head1 AUTHOR
105              
106             Masatoshi Mizuno E<lt>lusheE<64>cpan.orgE<gt>
107              
108             =head1 COPYRIGHT
109              
110             Copyright (C) 2007 by Bee Flag, Corp. E<lt>http://egg.bomcity.com/E<gt>, All Rights Reserved.
111              
112             This library is free software; you can redistribute it and/or modify
113             it under the same terms as Perl itself, either Perl version 5.8.6 or,
114             at your option, any later version of Perl 5 you may have available.
115              
116             =cut
117              
118             1;