Perlanet/Trait/FeedFile.pm

filter: Statementstmt 96.3% 26 / 27 Branchbran 50.0% 2 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 87.5% 7 / 8 Podpod n/a totaltotal 89.7% 35 / 39 CC 3 SCAR 5.4
CC
3
Cov
90%
__ANON__
3.1
__ANON__
2.0
BEGIN
1.0
CRAP 1.7
« Perlanet/Trait/OPML.pm ↑ Summary Perlanet/Trait/YAMLConfig.pm »
1 package Perlanet::Trait::FeedFile;
2  
3 11 ▶use 5.10.0;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 11 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 11 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 11 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 11 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 =head1 NAME
11  
12 Perlanet::Trait::FeedFile - save the aggregated feed to a file
13  
14 =head1 SYNOPSIS
15  
16 my $perlanet = Perlanet->new_with_traits(
17 traits => [ 'Perlanet::Trait::FeedFile' ]
18 );
19  
20 $perlanet->run;
21  
22 =head1 DESCRIPTION
23  
24 When the aggregation is complete and the feed is being rendered, it will be
25 saved to disk in XML format.
26  
27 =head1 ATTRIBUTES
28  
29 =head2 feed_file
30  
31 The path to the file to save the feed to.
32  
33 =head2 feed_format
34  
35 The format of the XML to use - may be RSS or Atom
36  
37 =cut
38  
39 11 ▶use Template;
Subroutine BEGIN: called CC=1 SCAR=0.0
40  
41 has 'feed' => (
42 isa => 'HashRef',
43 is => 'ro',
44 0 ▶ default => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
45 0 { file => 'atom.xml', format => 'Atom' };
46 },
47 11 );
48  
49 2 ▶after 'render' => sub {
Subroutine __ANON__: called CC=3 SCAR=11.2
50 2 my $self = shift;
51 2 my ($feed) = @_;
52 2 ▶ return unless $self->feed->{file};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->feed->{"file"} 0 2 2
53  
54 open my $feedfile, '>', $self->feed->{file}
55 2 ▶ or die 'Cannot open ' . $self->feed->{file} . " for writing: $!\n";
Branch: 1 branch
BranchTrueFalseTotal
open my $feedfile, ">", $self->feed->{"file"} or die 'Cannot open ' . $self->feed->{"file"} . " for writing: $!\n" 2 0 2
56 2 print $feedfile $feed->as_xml($self->feed->{format});
57 2 close $feedfile;
58 11 };
59  
60 =head1 AUTHOR
61  
62 Oliver Charles, <oliver.g.charles@googlemail.com>
63  
64 =head1 COPYRIGHT AND LICENSE
65  
66 Copyright (c) 2010 by Magnum Solutions Ltd.
67  
68 This library is free software; you can redistribute it and/or modify
69 it under the same terms as Perl itself, either Perl version 5.10.0 or,
70 at your option, any later version of Perl 5 you may have available.
71  
72 =cut
73  
74 11 1;
« Perlanet/Trait/OPML.pm ↑ Summary Perlanet/Trait/YAMLConfig.pm »