File Coverage

blib/lib/XML/NewsML_G2/Role/Writer/News_Item_Video.pm
Criterion Covered Total %
statement 16 16 100.0
branch 1 2 50.0
condition n/a
subroutine 3 3 100.0
pod n/a
total 20 21 95.2


line stmt bran cond sub pod time code
1             package XML::NewsML_G2::Role::Writer::News_Item_Video;
2              
3 2     2   1267 use Moose::Role;
  2         4  
  2         15  
4 2     2   9949 use namespace::autoclean;
  2         5  
  2         15  
5              
6             with 'XML::NewsML_G2::Role::Writer';
7              
8             around '_build_g2_catalog_schemes' => sub {
9             my ( $orig, $self, @args ) = @_;
10             my $result = $self->$orig(@args);
11             $result->{rnd} = undef;
12             return $result;
13             };
14              
15             after '_create_remote_content' => sub {
16             my ( $self, $root, $video ) = @_;
17              
18             foreach (
19             qw/size width height duration videoframerate videoavgbitrate audiosamplerate/
20             ) {
21             $root->setAttribute( $_, $video->$_ ) if defined $video->$_;
22             }
23              
24             my $rendition =
25             $self->scheme_manager->build_qcode( 'vidrnd', $video->rendition );
26             $root->setAttribute( 'rendition', $rendition ) if $rendition;
27              
28             my $audiochannels =
29             $self->scheme_manager->build_qcode( 'adc', $video->audiochannels );
30             $root->setAttribute( 'audiochannels', $audiochannels ) if $audiochannels;
31             };
32              
33             sub _create_icon {
34 9     9   25 my ( $self, $root ) = @_;
35              
36 9         16 for my $icon ( @{ $self->news_item->icon } ) {
  9         240  
37 10         341 my $rendition =
38             $self->scheme_manager->build_qcode( 'rnd', $icon->rendition );
39 10         34 my $icon_element =
40             $self->create_element( 'icon', rendition => $rendition, );
41              
42 10         23 foreach (qw/href width height/) {
43 30 50       848 next unless $icon->$_;
44 30         609 $icon_element->setAttribute( $_, $icon->$_ );
45             }
46 10         118 $root->appendChild($icon_element);
47             }
48 9         100 return;
49             }
50              
51             1;
52             __END__
53              
54             =head1 NAME
55              
56             XML::NewsML_G2::Role::Writer::News_Item_Video - Role for writing news items of type 'video'
57              
58             =head1 DESCRIPTION
59              
60             This module serves as a role for all NewsML-G2 writer classes and get automatically applied when the according news item type is written
61              
62             =head1 AUTHOR
63              
64             Stefan Hrdlicka C<< <stefan.hrdlicka@apa.at> >>
65              
66             =head1 LICENCE AND COPYRIGHT
67              
68             Copyright (c) 2014, APA-IT. All rights reserved.
69              
70             See L<XML::NewsML_G2> for the license.