blib/lib/XML/NewsML_G2/Package_Item.pm

filter: Statementstmt 95.4% 21 / 22 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 83.3% 5 / 6 Podpod 100% 1 / 1 totaltotal 93.1% 27 / 29 CC 1 SCAR 1.5
CC
1
Cov
95%
_build_sent
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.2
« blib/lib/XML/NewsML_G2/AnyItem.pm ↑ Summary blib/lib/XML/NewsML_G2.pm »
1 package XML::NewsML_G2::Package_Item;
2  
3 19 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 19 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 19 ▶use XML::NewsML_G2::Group;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 19 extends 'XML::NewsML_G2::AnyItem';
8  
9 19 has '+nature', default => 'composite';
10 19 has 'title', isa => 'Str', is => 'ro';
11  
12 19 has 'root_group',
13 isa => 'XML::NewsML_G2::Group',
14 is => 'ro',
15 lazy => 1,
16 builder => '_build_root_group';
17  
18 19 has 'root_role', isa => 'Str', is => 'ro', default => 'main';
19 19 has 'root_id', isa => 'Str', is => 'ro', default => 'root_group';
20  
21 sub _build_sent {
22 0 ▶ return DateTime->now( time_zone => 'local' );
Subroutine _build_sent: not called CC=1 SCAR=6.9
23 }
24  
25 sub _build_root_group {
26 1 ▶ my $self = shift;
Subroutine _build_root_group: called CC=1 SCAR=0.0
27 1 return XML::NewsML_G2::Group->new( role => $self->root_role );
28 }
29  
30 sub add_to_root_group {
31 1 ▶ my ( $self, @items ) = @_;
Subroutine add_to_root_group: called CC=1 SCAR=0.0
Pod documented
32 1 return $self->root_group->add_item(@items);
33 }
34  
35 19 __PACKAGE__->meta->make_immutable;
36  
37 19 1;
38 __END__
39  
40 =head1 NAME
41  
42 XML::NewsML_G2::Package_Item - a package of news items
43  
44 =for test_synopsis
45 my ($prov_apa, $text_item, $pic_item);
46  
47 =head1 SYNOPSIS
48  
49 my $pi = XML::NewsML_G2::Package_Item->new
50 (language => 'de', provider => $prov_apa);
51 $pi->add_to_root_group($text_item, $pic_item);
52  
53  
54 =head1 DESCRIPTION
55  
56 A package item is a collection of news items, that are published
57 together. The structure of packages is flexible to support nested
58 groups of items - please see the NewsML-G2 specification for details.
59  
60 Each package item is built up by one root group, which is an instance
61 of L<XML::NewsML_G2::Group>.
62  
63 =head1 ATTRIBUTES
64  
65 =over 4
66  
67 =item title
68 Optional title of the package.
69  
70 =item root_group
71  
72 Upon creation of the package item, a new, empty
73 L<XML::NewsML_G2::Group> is created and stored in the C<root_group>
74 attribute.
75  
76 =item root_role
77  
78 The root group needs a role that specifies the type of content the
79 package contains. Defaults to 'main'.
80  
81 =item root_id
82  
83 All groups are identified by IDs. This attribute is used to name the
84 root group - all other groups are named automatically. Defaults to
85 'root_group'.
86  
87 =back
88  
89 =head1 METHODS
90  
91 =over 4
92  
93 =item add_to_root_group
94  
95 Use this method to add news items and groups to the root group.
96  
97 =back
98  
99 =head1 AUTHOR
100  
101 Philipp Gortan C<< <philipp.gortan@apa.at> >>
102  
103 =head1 LICENCE AND COPYRIGHT
104  
105 Copyright (c) 2014, APA-IT. All rights reserved.
106  
107 See L<XML::NewsML_G2> for the license.
« blib/lib/XML/NewsML_G2/AnyItem.pm ↑ Summary blib/lib/XML/NewsML_G2.pm »