line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Perlanet::Trait::FeedFile; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
6231
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
25
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
21
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
5
|
use Moose::Role; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
7
|
1
|
|
|
1
|
|
4439
|
use namespace::autoclean; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
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
|
1
|
|
|
1
|
|
59
|
use Carp qw( croak ); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
38
|
|
39
|
1
|
|
|
1
|
|
410
|
use Template; |
|
1
|
|
|
|
|
13649
|
|
|
1
|
|
|
|
|
126
|
|
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; |