blib/lib/XML/NewsML_G2/Role/Writer_2_9.pm

filter: Statementstmt 62.0% 36 / 58 Branchbran 44.4% 8 / 18 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 36.3% 4 / 11 Podpod n/a totaltotal 55.1% 48 / 87 CC 14 SCAR 20.0
CC
14
Cov
58%
__ANON__
20.0
__ANON__
12.0
__ANON__
6.0
CRAP 7.4
« blib/lib/XML/NewsML_G2/Role/Writer.pm ↑ Summary Build »
1 package XML::NewsML_G2::Role::Writer_2_9;
2  
3 4 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 4 has 'schema_location',
7 isa => 'Str',
8 is => 'ro',
9 default =>
10 'http://iptc.org/std/nar/2006-10-01/ http://www.iptc.org/std/NewsML-G2/2.9/specification/NewsML-G2_2.9-spec-All-Power.xsd';
11 4 has 'g2_catalog_url',
12 isa => 'Str',
13 is => 'ro',
14 default =>
15 'http://www.iptc.org/std/catalog/catalog.IPTC-G2-Standards_18.xml';
16  
17 override '_create_rights_info' => sub {
18 3 ▶ my ( $self, $root ) = @_;
Subroutine __ANON__: called CC=5 SCAR=16.6
19 3 ▶ return unless $self->news_item->copyright_holder;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->news_item->copyright_holder 0 3 3
20  
21 3 my $ri = $self->create_element('rightsInfo');
22  
23 3 $ri->appendChild(
24 my $crh = $self->create_element(
25 'copyrightHolder',
26 _name_text => $self->news_item->copyright_holder
27 )
28 );
29 3 ▶ if ( my $qcode = $self->news_item->copyright_holder->qcode ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $qcode = $self->news_item->copyright_holder->qcode) 3 0 3
30 3 $self->scheme_manager->add_qcode_or_literal( $crh,
31 'copyright_holder', $qcode );
32 }
33  
34 3 my $notice = $self->news_item->copyright_holder->notice;
35 3 ▶ $ri->appendChild(
Branch: 1 branch
BranchTrueFalseTotal
if $notice 3 0 3
36 $self->create_element( 'copyrightNotice', _text => $notice ) )
37 if $notice;
38 3 ▶ $ri->appendChild(
Branch: 1 branch
BranchTrueFalseTotal
if $self->news_item->usage_terms 3 0 3
39 $self->create_element(
40 'usageTerms', _text => $self->news_item->usage_terms
41 )
42 ) if $self->news_item->usage_terms;
43  
44 3 $root->appendChild($ri);
45 3 return;
46 4 };
47  
48 override '_create_catalogs' => sub {
49 3 ▶ my ( $self, $root ) = @_;
Subroutine __ANON__: called CC=4 SCAR=13.9
50 3 $root->appendChild(
51 $self->create_element( 'catalogRef', href => $self->g2_catalog_url )
52 );
53  
54 3 my $cat;
55 3 foreach my $scheme ( $self->scheme_manager->get_all_schemes() ) {
56 70 ▶ if ( $scheme->uri ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($scheme->uri) 32 38 70
57 32 ▶ $root->appendChild( $cat = $self->create_element('catalog') )
Branch: 1 branch
BranchTrueFalseTotal
unless $cat 3 29 32
58 unless $cat;
59 32 $cat->appendChild(
60 $self->create_element(
61 'scheme',
62 alias => $scheme->alias,
63 uri => $scheme->uri
64 )
65 );
66 }
67 }
68 3 return;
69 4 };
70  
71 override '_create_hierarchy' => sub {
72 0 ▶ my ( $self, $node, $schema ) = @_;
Subroutine __ANON__: not called CC=2 SCAR=17.9
73 0 my @res;
74  
75 0 ▶ do {
Branch: 1 branch
BranchTrueFalseTotal
$node = $node->parent and do { do { unshift @res, $self->scheme_manager->build_qcode($schema, $node->qcode) } } 0 0 0
76 0 unshift @res,
77 $self->scheme_manager->build_qcode( $schema, $node->qcode() );
78 } while ( $node = $node->parent() );
79  
80 0 return $self->create_element( 'hierarchyInfo', _text => join ' ', @res );
81 4 };
82  
83 override '_create_infosources' => sub {
84 0 ▶ my ( $self, $root ) = @_;
Subroutine __ANON__: not called CC=3 SCAR=24.8
85 0 foreach ( @{ $self->news_item->sources } ) {
86 0 ▶ next if $_ eq uc $self->news_item->provider->qcode;
Branch: 1 branch
BranchTrueFalseTotal
if $_ eq uc $self->news_item->provider->qcode 0 0 0
87 0 $root->appendChild( my $i =
88 $self->create_element( 'infoSource', literal => $_ ) );
89 0 $self->scheme_manager->add_role( $i, 'isrol', 'originfo' );
90 }
91 0 return;
92 4 };
93  
94 override '_create_company_data' => sub {
95 0 ▶ my ( $self, $org, $root ) = @_;
Subroutine __ANON__: not called CC=4 SCAR=30.0
96 0 ▶ return unless ( $self->scheme_manager->crel );
Branch: 1 branch
BranchTrueFalseTotal
unless $self->scheme_manager->crel 0 0 0
97  
98 0 my $crel_alias = $self->scheme_manager->crel->alias;
99 $root->appendChild(
100 $self->create_element(
101 'related',
102 rel => "$crel_alias:index",
103 literal => $_
104 )
105 0 ) foreach ( @{ $org->indices } );
106 $root->appendChild(
107 $self->create_element(
108 'related',
109 rel => "$crel_alias:exchange",
110 literal => $_
111 )
112 0 ) foreach ( @{ $org->stock_exchanges } );
113 4 };
114  
115 override '_create_creator' => sub {
116 0 ▶ my ( $self, $creator ) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
117 0 return $self->create_element( 'creator', literal => $creator->name );
118 4 };
119  
120 4 ▶override '_create_teaser' => sub { };
Subroutine __ANON__: not called CC=1 SCAR=0.0
121 4 ▶override '_create_copyright_holder_remoteinfo' => sub { };
Subroutine __ANON__: not called CC=1 SCAR=0.0
122  
123 ## no critic (ControlStructures::ProhibitYadaOperator Subroutines::RequireFinalReturn)
124 0 ▶sub _create_subjects_concepts {...}
Subroutine _create_subjects_concepts: not called CC=1 SCAR=6.9
125  
126 4 1;
127 __END__
128  
129 =head1 NAME
130  
131 XML::NewsML_G2::Role::Writer_2_9 - create XML DOM tree conforming to version
132 2.9 of the NewsML-G2 specification
133  
134 Check the documentation of L<XML::NewsML_G2::Writer> for general
135 information on this class.
136  
137 =head1 AUTHOR
138  
139 Philipp Gortan C<< <philipp.gortan@apa.at> >>
140  
141 =head1 LICENCE AND COPYRIGHT
142  
143 Copyright (c) 2013-2014, APA-IT. All rights reserved.
144  
145 See L<XML::NewsML_G2> for the license.
« blib/lib/XML/NewsML_G2/Role/Writer.pm ↑ Summary Build »