lib/TUI/Objects/Collection.pm

filter: Statementstmt 89.6% 87 / 97 Branchbran 46.4% 13 / 28 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 85.7% 18 / 21 Podpod 12.5% 1 / 8 totaltotal 77.2% 119 / 154 CC 15 SCAR 15.1
CC
15
Cov
80%
build
20.0
STORABLE_attach
5.2
STORABLE_freeze
4.1
CRAP 4.5
« lib/TUI/Help/HelpWindow.pm ↑ Summary lib/TUI/ColorSel/MonoSelector.pm »
1 package TUI::Objects::Collection;
2 # ABSTRACT: TCollection provides a mechanism for managing any data collection.
3
4 52 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 52 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 52 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7
8 52 our $VERSION = '2.000003';
9 52 $VERSION =~ tr/_//d;
10 52 our $AUTHORITY = 'cpan:BRICKPOOL';
11
12 52 ▶use Exporter 'import';
Subroutine BEGIN: called CC=1 SCAR=0.0
13 52 our @EXPORT = qw(
14 TCollection
15 new_TCollection
16 );
17
18 52 ▶use Devel::StrictMode;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 52 ▶use if STRICT => 'Hash::Util';
Subroutine BEGIN: called CC=1 SCAR=0.0
20 52 ▶use Scalar::Util qw( reftype );
Subroutine BEGIN: called CC=1 SCAR=0.0
21 52 ▶use Storable qw( freeze thaw );
Subroutine BEGIN: called CC=1 SCAR=0.0
22 52 ▶use TUI::toolkit;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 52 ▶use TUI::toolkit::Types qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
24 :is
25 :types
26 52 );
27
28 52 ▶use TUI::Objects::NSCollection;
Subroutine BEGIN: called CC=1 SCAR=0.0
29 52 ▶use TUI::Objects::Stream;
Subroutine BEGIN: called CC=1 SCAR=0.0
30 52 ▶use TUI::Objects::Streamable;
Subroutine BEGIN: called CC=1 SCAR=0.0
31
32 sub TCollection() { __PACKAGE__ }
33 sub name() { 'TCollection' };
34 1 ▶sub new_TCollection { __PACKAGE__->from(@_) }
Subroutine new_TCollection: called CC=1 SCAR=0.0
Pod documented
35
36 52 extends TNSCollection;
37 52 with: *DOES = TStreamable->can('DOES');
38
39 2 ▶sub STORABLE_freeze { # @list ($cloning)
Subroutine STORABLE_freeze: called CC=4 SCAR=14.1
Pod undocumented
40 2 my ( $self, $cloning ) = @_;
41 2 ▶ assert ( is_Object $self );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Object($self) 0 2 2
42 2 ▶ assert ( is_Bool $cloning );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Bool($cloning) 0 2 2
43 2 ▶ assert ( not $cloning );
Branch: 1 branch
BranchTrueFalseTotal
if $cloning 0 2 2
44
45 2 my $stream = TStream->new();
46 2 $self->write( $stream );
47 2 return freeze $stream;
48 }
49
50 2 ▶sub STORABLE_attach { # $obj ($cloning, $serialized)
Subroutine STORABLE_attach: called CC=5 SCAR=16.5
Pod undocumented
51 2 my ( $class, $cloning, $serialized ) = @_;
52 2 ▶ assert ( is_Str $class );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Str($class) 0 2 2
53 2 ▶ assert ( is_Bool $cloning );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Bool($cloning) 0 2 2
54 2 ▶ assert ( is_Str $serialized );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Str($serialized) 0 2 2
55 2 ▶ assert ( not $cloning );
Branch: 1 branch
BranchTrueFalseTotal
if $cloning 0 2 2
56
57 2 my $self = $class->build();
58 2 my $stream = thaw $serialized;
59 2 return $self->read( $stream );
60 }
61
62 0 ▶sub writeItem { # void ($item, $os)
Subroutine writeItem: not called CC=1 SCAR=6.9
Pod undocumented
63 ...
64 0 }
65
66 0 ▶sub readItem { # $item|undef ($is)
Subroutine readItem: not called CC=1 SCAR=6.9
Pod undocumented
67 ...
68 0 }
69
70 2 ▶sub write :method { # void ($os)
Subroutine write: called CC=3 SCAR=11.0
Pod undocumented
71 2 state $sig = signature(
72 method => Object,
73 pos => [Object],
74 );
75 2 my ( $self, $os ) = $sig->( @_ );
76 2 ▶ assert ( Storable::is_storing );
Branch: 1 branch
BranchTrueFalseTotal
unless &Storable::is_storing() 0 2 2
77
78 $os->put(
79 $self->{count},
80 $self->{limit},
81 $self->{delta},
82 2 );
83 2 ▶ for ( my $idx = 0 ; $idx < $self->{count} ; $idx++ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($idx < $self->{"count"}) 5 2 7
84 5 $self->writeItem( $self->SUPER::at( $idx ), $os );
85 }
86
87 2 return;
88 }
89
90 2 ▶sub read :method { # $self ($is)
Subroutine read: called CC=3 SCAR=11.0
Pod undocumented
91 2 state $sig = signature(
92 method => Object,
93 pos => [Object],
94 );
95 2 my ( $self, $is ) = $sig->( @_ );
96 2 ▶ assert ( Storable::is_retrieving );
Branch: 1 branch
BranchTrueFalseTotal
unless &Storable::is_retrieving() 0 2 2
97
98 2 $self->{count} = $is->get();
99 2 my $savedLimit = $is->get();
100 2 $self->{delta} = $is->get();
101 2 $self->setLimit( $savedLimit );
102 2 ▶ for ( my $idx = 0 ; $idx < $self->{count} ; $idx++ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($idx < $self->{"count"}) 5 2 7
103 5 $self->SUPER::atPut( $idx, $self->readItem( $is ) );
104 }
105
106 2 return $self;
107 }
108
109 0 ▶sub build { # $obj ()
Subroutine build: not called CC=4 SCAR=30.0
Pod undocumented
110 0 my ( $class ) = @_;
111 0 ▶ assert ( @_ == 1 );
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 1 0 0 0
112 0 ▶ assert ( is_Str $class );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Str($class) 0 0 0
113 0 ▶ assert ( Storable::is_retrieving );
Branch: 1 branch
BranchTrueFalseTotal
unless &Storable::is_retrieving() 0 0 0
114 0 return $class->new(
115 limit => 0,
116 delta => 0,
117 );
118 }
119
120 52 1
121
122 __END__
« lib/TUI/Help/HelpWindow.pm ↑ Summary lib/TUI/ColorSel/MonoSelector.pm »