File Coverage

blib/lib/XML/NewsML_G2/Role/Writer/News_Item_Picture.pm
Criterion Covered Total %
statement 6 6 100.0
branch n/a
condition n/a
subroutine 2 2 100.0
pod n/a
total 8 8 100.0


line stmt bran cond sub pod time code
1             package XML::NewsML_G2::Role::Writer::News_Item_Picture;
2              
3 4     4   2973 use Moose::Role;
  4         10  
  4         39  
4 4     4   22762 use namespace::autoclean;
  4         11  
  4         34  
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             $result->{colsp} = undef;
13             return $result;
14             };
15              
16             before '_create_authors' => sub {
17             my ( $self, $root ) = @_;
18              
19             if ( $self->news_item->photographer ) {
20             my $c = $self->_create_creator( $self->news_item->photographer );
21             $root->appendChild($c);
22             $self->scheme_manager->add_qcode( $c, 'crol', 'photographer' );
23             }
24             return;
25             };
26              
27             after '_create_remote_content' => sub {
28             my ( $self, $root, $picture ) = @_;
29              
30             return unless $picture->isa('XML::NewsML_G2::Picture');
31              
32             foreach (qw/width height orientation/) {
33             $root->setAttribute( $_, $picture->$_ ) if defined $picture->$_;
34             }
35              
36             my $rendition =
37             $self->scheme_manager->build_qcode( 'rnd', $picture->rendition );
38             $root->setAttribute( 'rendition', $rendition ) if $rendition;
39              
40             my $colsp =
41             $self->scheme_manager->build_qcode( 'colsp', $picture->colorspace );
42             $root->setAttribute( 'colourspace', $colsp ) if $colsp;
43              
44             if ( my $altId = $picture->altId ) {
45             $root->appendChild(
46             $self->create_element( 'altId', _text => $altId ) );
47             }
48             return;
49             };
50              
51             1;
52             __END__
53              
54             =head1 NAME
55              
56             XML::NewsML_G2::Role::Writer::News_Item_Picture - Role for writing news items of type 'picture'
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             Christian Eder C<< <christian.eder@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.