| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Perlanet::Trait::FeedFile; |
|
2
|
|
|
|
|
|
|
|
|
3
|
6
|
|
|
6
|
|
3234
|
use strict; |
|
|
6
|
|
|
|
|
17
|
|
|
|
6
|
|
|
|
|
184
|
|
|
4
|
6
|
|
|
6
|
|
34
|
use warnings; |
|
|
6
|
|
|
|
|
17
|
|
|
|
6
|
|
|
|
|
163
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
6
|
|
|
6
|
|
33
|
use Moose::Role; |
|
|
6
|
|
|
|
|
15
|
|
|
|
6
|
|
|
|
|
51
|
|
|
7
|
6
|
|
|
6
|
|
34538
|
use namespace::autoclean; |
|
|
6
|
|
|
|
|
15
|
|
|
|
6
|
|
|
|
|
59
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 NAME |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
Perlanet::Trait::FeedFile - save the aggregated feed to a file |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
my $perlanet = Perlanet->new_with_traits( |
|
16
|
|
|
|
|
|
|
traits => [ 'Perlanet::Trait::FeedFile' ] |
|
17
|
|
|
|
|
|
|
); |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
$perlanet->run; |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
When the aggregation is complete and the feed is being rendered, it will be |
|
24
|
|
|
|
|
|
|
saved to disk in XML format. |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head2 feed_file |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
The path to the file to save the feed to. |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head2 feed_format |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
The format of the XML to use - may be RSS or Atom |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=cut |
|
37
|
|
|
|
|
|
|
|
|
38
|
6
|
|
|
6
|
|
489
|
use Carp qw( croak ); |
|
|
6
|
|
|
|
|
14
|
|
|
|
6
|
|
|
|
|
327
|
|
|
39
|
6
|
|
|
6
|
|
35
|
use Template; |
|
|
6
|
|
|
|
|
14
|
|
|
|
6
|
|
|
|
|
986
|
|
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
has 'feed' => ( |
|
42
|
|
|
|
|
|
|
isa => 'HashRef', |
|
43
|
|
|
|
|
|
|
is => 'rw', |
|
44
|
|
|
|
|
|
|
default => sub { |
|
45
|
|
|
|
|
|
|
{ file => 'atom.xml', format => 'Atom' } |
|
46
|
|
|
|
|
|
|
}, |
|
47
|
|
|
|
|
|
|
); |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
after 'render' => sub { |
|
50
|
|
|
|
|
|
|
my ($self, $feed) = @_; |
|
51
|
|
|
|
|
|
|
return unless $self->feed->{file}; |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
open my $feedfile, '>', $self->feed->{file} |
|
54
|
|
|
|
|
|
|
or croak 'Cannot open ' . $self->feed->{file} . " for writing: $!"; |
|
55
|
|
|
|
|
|
|
print $feedfile $feed->as_xml($self->feed->{format}); |
|
56
|
|
|
|
|
|
|
close $feedfile; |
|
57
|
|
|
|
|
|
|
}; |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head1 AUTHOR |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
Oliver Charles, <oliver.g.charles@googlemail.com> |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
Copyright (c) 2010 by Magnum Solutions Ltd. |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
|
68
|
|
|
|
|
|
|
it under the same terms as Perl itself, either Perl version 5.10.0 or, |
|
69
|
|
|
|
|
|
|
at your option, any later version of Perl 5 you may have available. |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=cut |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
1; |