File Coverage

blib/lib/XML/NewsML_G2/Package_Item.pm
Criterion Covered Total %
statement 13 15 86.6
branch n/a
condition n/a
subroutine 5 6 83.3
pod 1 1 100.0
total 19 22 86.3


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