EventList.pm

filter: Statementstmt 100% 25 / 25 Branchbran 100% 2 / 2 Conditioncond 100% 3 / 3 MC/DCmcdc 100% 2 / 2 Subroutinesub 100% 6 / 6 Podpod 100% 1 / 1 totaltotal 100% 39 / 39 CC 4 SCAR 8.5
CC
4
Cov
100%
get_highest_id
4.0
BEGIN
1.0
BEGIN
1.0
CRAP 2.3
« Client.pm ↑ Summary Event.pm »
1 package Osgood::EventList;
2 6 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 6 ▶use MooseX::AttributeHelpers;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 6 ▶use MooseX::Iterator;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 6 ▶use MooseX::Storage;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 6 with Storage('format' => 'JSON', 'io' => 'File');
8  
9 has 'events' => (
10 metaclass => 'Collection::Array',
11 is => 'rw',
12 isa => 'ArrayRef',
13 4 ▶ default => sub { [] },
Subroutine __ANON__: called CC=1 SCAR=0.0
14 6 provides => {
15 push => 'add_to_events',
16 count => 'size'
17 }
18 );
19  
20 6 has 'iterator' => (
21 metaclass => 'Iterable',
22 iterate_over => 'events'
23 );
24  
25 =head1 NAME
26  
27 Osgood::EventList - A list of Osgood events.
28  
29 =head1 DESCRIPTION
30  
31 A list of events.
32  
33 =head1 SYNOPSIS
34  
35 my $list = Osgood::EventList->new;
36 $list->add_to_events($event);
37 print $list->size."\n";
38  
39 =head1 METHODS
40  
41 =head2 Constructor
42  
43 =head2 new
44  
45 Creates a new Osgood::EventList object.
46  
47 =head2 add_to_events
48  
49 Add the specified event to the list.
50  
51 =head2 events
52  
53 Set/Get the ArrayRef of events in this list.
54  
55 =head2 iterator
56  
57 Returns a MooseX::Iterator for iterating over events.
58  
59 =head2 size
60  
61 Returns the number of events in this list.
62  
63 =head2 get_highest_id
64  
65 Retrieves the largest id from the list of events. This is useful for keeping
66 state with an external process that needs to 'remember' the last event id
67 it handled.
68  
69 =cut
70 1 ▶sub get_highest_id {
Subroutine get_highest_id: called CC=4 SCAR=13.9
Pod documented
71 1 my ($self) = @_;
72  
73 1 my $high = undef;
74 1 foreach my $event (@{ $self->events }) {
75 4 ▶ if(!defined($high) || ($high < $event->id)) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $high or $high < $event->id) 2 2 4
Condition100%3/3
not defined $high or $high < $event->id
l!l&&r!l&&!r
112
MC/DC100%2/2
not defined $high or $high < $event->id
not defined $high $high < $event->id
Truth table100%3/3
not(A) or B
A= not defined $highB= $high < $event->id
ABresult
1X1
011
000
76 2 $high = $event->id;
77 }
78 }
79  
80 1 return $high;
81 }
82  
83 =head1 AUTHOR
84  
85 Cory 'G' Watson <gphat@cpan.org>
86  
87 =head1 SEE ALSO
88  
89 perl(1), L<Osgood::Event>
90  
91 =head1 COPYRIGHT AND LICENSE
92  
93 Copyright 2008-2009 by Magazines.com, LLC
94  
95 You can redistribute and/or modify this code under the same terms as Perl
96 itself.
97  
98 =cut
99  
100 6 __PACKAGE__->meta->make_immutable;
101  
102 6 1;
« Client.pm ↑ Summary Event.pm »