lib/TUI/Validate/Validator.pm

filter: Statementstmt 50.0% 48 / 96 Branchbran 3.8% 1 / 26 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 70.0% 14 / 20 Podpod 54.5% 6 / 11 totaltotal 45.1% 69 / 153 CC 14 SCAR 23.7
CC
14
Cov
40%
STORABLE_attach
30.0
STORABLE_freeze
20.0
build
20.0
CRAP 10.7
« lib/TUI/toolkit/UO/Antlers.pm ↑ Summary lib/TUI/Dialogs/HistoryWindow.pm »
1 package TUI::Validate::Validator;
2 # ABSTRACT: Abstract base class for validators
3
4 11 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 11 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 11 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7
8 11 our $VERSION = '2.000003';
9 11 $VERSION =~ tr/_//d;
10 11 our $AUTHORITY = 'cpan:BRICKPOOL';
11
12 11 ▶use Exporter 'import';
Subroutine BEGIN: called CC=1 SCAR=0.0
13 11 our @EXPORT = qw(
14 TValidator
15 new_TValidator
16 );
17
18 11 ▶use Storable qw( freeze thaw );
Subroutine BEGIN: called CC=1 SCAR=0.0
19 11 ▶use TUI::toolkit;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 11 ▶use TUI::toolkit::Types qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
21 :is
22 :types
23 11 );
24
25 11 ▶use TUI::Objects::Object;
Subroutine BEGIN: called CC=1 SCAR=0.0
26 11 ▶use TUI::Objects::Stream;
Subroutine BEGIN: called CC=1 SCAR=0.0
27
28 sub TValidator() { __PACKAGE__ }
29 sub name() { 'TValidator' };
30 1 ▶sub new_TValidator { __PACKAGE__->from(@_) }
Subroutine new_TValidator: called CC=1 SCAR=0.0
Pod documented
31
32 11 extends TObject;
33
34 # public attributes
35 11 has status => ( is => 'rw', default => 0 );
36 11 has options => ( is => 'rw', default => 0 );
37
38 0 ▶sub error { # void ()
Subroutine error: not called CC=1 SCAR=6.9
Pod documented
39 0 state $sig = signature(
40 method => Object,
41 pos => [],
42 );
43 0 $sig->( @_ );
44 0 return;
45 }
46
47 1 ▶sub isValidInput { # $bool ($s, $suppressFill)
Subroutine isValidInput: called CC=1 SCAR=0.0
Pod documented
48 1 state $sig = signature(
49 method => Object,
50 pos => [Str, Bool],
51 );
52 1 $sig->( @_ );
53 1 return true;
54 }
55
56 2 ▶sub isValid { # $bool ($s)
Subroutine isValid: called CC=1 SCAR=0.0
Pod documented
57 2 state $sig = signature(
58 method => Object,
59 pos => [Str],
60 );
61 2 $sig->( @_ );
62 2 return true;
63 }
64
65 1 ▶sub transfer { # $n ($s, $buffer, $flags)
Subroutine transfer: called CC=1 SCAR=0.0
Pod documented
66 1 state $sig = signature(
67 method => Object,
68 pos => [Str, Any, PositiveOrZeroInt],
69 );
70 1 $sig->( @_ );
71 1 return 0;
72 }
73
74 1 ▶sub validate { # $bool ($s)
Subroutine validate: called CC=2 SCAR=7.9
Pod documented
75 1 state $sig = signature(
76 method => Object,
77 pos => [Str],
78 );
79 1 my ( $self, $s ) = $sig->( @_ );
80 1 ▶ if ( !$self->isValid( $s ) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->isValid($s)) 0 1 1
81 0 $self->error();
82 0 return false;
83 }
84 1 return true;
85 }
86
87 0 ▶sub STORABLE_freeze { # @list ($cloning)
Subroutine STORABLE_freeze: not called CC=4 SCAR=30.0
Pod undocumented
88 0 my ( $self, $cloning ) = @_;
89 0 ▶ assert ( is_Object $self );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Object($self) 0 0 0
90 0 ▶ assert ( is_Bool $cloning );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Bool($cloning) 0 0 0
91 0 ▶ assert ( not $cloning );
Branch: 1 branch
BranchTrueFalseTotal
if $cloning 0 0 0
92
93 0 my $stream = TStream->new();
94 0 $self->write( $stream );
95 0 return freeze $stream;
96 }
97
98 0 ▶sub STORABLE_attach { # $obj ($cloning, $serialized)
Subroutine STORABLE_attach: not called CC=5 SCAR=34.0
Pod undocumented
99 0 my ( $class, $cloning, $serialized ) = @_;
100 0 ▶ assert ( is_Str $class );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Str($class) 0 0 0
101 0 ▶ assert ( is_Bool $cloning );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Bool($cloning) 0 0 0
102 0 ▶ assert ( is_Str $serialized );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Str($serialized) 0 0 0
103 0 ▶ assert ( not $cloning );
Branch: 1 branch
BranchTrueFalseTotal
if $cloning 0 0 0
104
105 0 my $self = $class->build();
106 0 my $stream = thaw $serialized;
107 0 return $self->read( $stream );
108 }
109
110 0 ▶sub write :method { # void ($os)
Subroutine write: not called CC=2 SCAR=17.9
Pod undocumented
111 0 state $sig = signature(
112 method => Object,
113 pos => [Object],
114 );
115 0 my ( $self, $os ) = $sig->( @_ );
116 0 ▶ assert ( Storable::is_storing );
Branch: 1 branch
BranchTrueFalseTotal
unless &Storable::is_storing() 0 0 0
117 0 $os->put( $self->{options} );
118 0 return;
119 }
120
121 0 ▶sub read :method { # $self ($is)
Subroutine read: not called CC=2 SCAR=17.9
Pod undocumented
122 0 state $sig = signature(
123 method => Object,
124 pos => [Object],
125 );
126 0 my ( $self, $is ) = $sig->( @_ );
127 0 ▶ assert ( Storable::is_retrieving );
Branch: 1 branch
BranchTrueFalseTotal
unless &Storable::is_retrieving() 0 0 0
128 0 $self->{options} = $is->get();
129 0 $self->{status} = 0;
130 0 return $self;
131 }
132
133 0 ▶sub build { # $obj ()
Subroutine build: not called CC=4 SCAR=30.0
Pod undocumented
134 0 my ( $class ) = @_;
135 0 ▶ assert ( @_ == 1 );
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 1 0 0 0
136 0 ▶ assert ( is_Str $class );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Str($class) 0 0 0
137 0 ▶ assert ( Storable::is_retrieving );
Branch: 1 branch
BranchTrueFalseTotal
unless &Storable::is_retrieving() 0 0 0
138 0 return $class->from();
139 }
140
141 11 1
142
143 __END__
« lib/TUI/toolkit/UO/Antlers.pm ↑ Summary lib/TUI/Dialogs/HistoryWindow.pm »