Silki/Role/Controller/RevisionsAtomFeed.pm untested

filter: Statementstmt 0.0% 0 / 44 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 60 CC 3 SCAR 17.5
CC
3
Cov
0%
_output_atom_feed_for_revisions
12.0
BEGIN
2.0
BEGIN
2.0
CRAP 5.8
1 package Silki::Role::Controller::RevisionsAtomFeed;
2 {
3 $Silki::Role::Controller::RevisionsAtomFeed::VERSION = '0.29';
4 }
5  
6 use strict;
7 use warnings;
8 use namespace::autoclean;
9  
10 use Silki::I18N qw( loc );
11  
12 use Moose::Role;
13  
14 sub _output_atom_feed_for_revisions {
15 my $self = shift;
16 my $c = shift;
17 my $revisions = shift;
18 my $feed_title = shift;
19 my $alt_uri = shift;
20 my $self_uri = shift;
21 my $page = shift;
22  
23 my @entries;
24  
25 my $updated;
26 while ( my ( $page, $revision )
27 = $page ? ( $page, $revisions->next() ) : $revisions->next() ) {
28 last unless $revision;
29  
30 $updated ||= $revision->creation_datetime();
31  
32 my $entry_title = $page->title() . ' ('
33 . loc( 'revision %1', $revision->revision_number() ) . ')';
34  
35 my $entry_uri = $revision->uri( with_host => 1 );
36  
37 my $content = $revision->content_as_html( user => $c->user() );
38  
39 push @entries,
40 [
41 title => $entry_title,
42 link => $entry_uri,
43 id => $entry_uri,
44 author => $revision->user()->best_name(),
45 updated => DateTime::Format::W3CDTF->format_datetime(
46 $revision->creation_datetime()->clone()->set_time_zone('UTC')
47 ),
48 content => { type => 'html', content => $content },
49 ];
50 }
51  
52 my $feed = XML::Atom::SimpleFeed->new(
53 title => $feed_title,
54 link => $alt_uri,
55 id => $alt_uri,
56 link => {
57 rel => 'self',
58 href => $self_uri,
59 },
60 updated => DateTime::Format::W3CDTF->format_datetime(
61 $updated->clone()->set_time_zone('UTC')
62 ),
63 );
64  
65 $feed->add_entry( @{$_} ) for @entries;
66  
67 $c->response()->content_type('application/atom+xml');
68  
69 my $xml = $feed->as_string();
70 $c->response()->content_length( length $xml );
71  
72 $c->response()->body($xml);
73  
74 $c->response()->status(200);
75  
76 $c->detach();
77 }
78  
79 1;
80  
81 # ABSTRACT: Generates an atom feed from a set of revisions
82  
83 __END__