line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Brick::Strings; |
2
|
5
|
|
|
5
|
|
36
|
use strict; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
163
|
|
3
|
|
|
|
|
|
|
|
4
|
5
|
|
|
5
|
|
24
|
use base qw(Exporter); |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
464
|
|
5
|
5
|
|
|
5
|
|
32
|
use vars qw($VERSION); |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
250
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
$VERSION = '0.901'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
package Brick::Bucket; |
10
|
5
|
|
|
5
|
|
81
|
use strict; |
|
5
|
|
|
|
|
12
|
|
|
5
|
|
|
|
|
2647
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=encoding utf8 |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 NAME |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
Brick::General - constraints for domain-nonspecific stuff |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 SYNOPSIS |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
use Brick; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 DESCRIPTION |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=over 4 |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=item $bucket->value_length_is_exactly( HASHREF ) |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
exact_length |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=cut |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub _value_length_is_exactly |
33
|
|
|
|
|
|
|
{ |
34
|
0
|
|
|
0
|
|
|
my( $bucket, $setup ) = @_; |
35
|
|
|
|
|
|
|
|
36
|
0
|
|
|
|
|
|
$setup->{minimum_length} = $setup->{exact_length}; |
37
|
0
|
|
|
|
|
|
$setup->{maximum_length} = $setup->{exact_length}; |
38
|
|
|
|
|
|
|
|
39
|
0
|
|
|
|
|
|
$bucket->_value_length_is_between( $setup ); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=item $bucket->value_length_is_greater_than( HASHREF ) |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
minimum_length |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=cut |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub _value_length_is_equal_to_greater_than |
49
|
|
|
|
|
|
|
{ |
50
|
0
|
|
|
0
|
|
|
my( $bucket, $setup ) = @_; |
51
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
my @caller = $bucket->__caller_chain_as_list(); |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
$bucket->add_to_bucket( { |
56
|
|
|
|
|
|
|
name => $setup->{name} || $caller[0]{'sub'}, |
57
|
|
|
|
|
|
|
description => "Length must be $setup->{minimum_length} or more characters", |
58
|
|
|
|
|
|
|
code => sub { |
59
|
|
|
|
|
|
|
die { |
60
|
|
|
|
|
|
|
message => "[$_[0]->{ $setup->{field} }] isn't $setup->{minimum_length} or more characters", |
61
|
|
|
|
|
|
|
handler => $caller[0]{'sub'}, |
62
|
|
|
|
|
|
|
failed_field => $setup->{field}, |
63
|
|
|
|
|
|
|
failed_value => $_[0]->{ $setup->{field} }, |
64
|
|
|
|
|
|
|
} unless $setup->{minimum_length} <= length( $_[0]->{ $setup->{field} } ) |
65
|
0
|
0
|
|
0
|
|
|
}, |
66
|
0
|
|
0
|
|
|
|
} ); |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=item $bucket->value_length_is_less_than( HASHREF ) |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
maximum_length |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=cut |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub _value_length_is_equal_to_less_than |
76
|
|
|
|
|
|
|
{ |
77
|
0
|
|
|
0
|
|
|
my( $bucket, $setup ) = @_; |
78
|
|
|
|
|
|
|
|
79
|
0
|
|
|
|
|
|
my @caller = $bucket->__caller_chain_as_list(); |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
$bucket->add_to_bucket( { |
82
|
|
|
|
|
|
|
name => $setup->{name} || $caller[0]{'sub'}, |
83
|
|
|
|
|
|
|
description => "Length must be $setup->{maximum_length} or fewer characters", |
84
|
|
|
|
|
|
|
code => sub { |
85
|
|
|
|
|
|
|
die { |
86
|
|
|
|
|
|
|
message => "[$_[0]->{ $setup->{field} }] isn't $setup->{maximum_length} or fewer characters", |
87
|
|
|
|
|
|
|
handler => $caller[0]{'sub'}, |
88
|
|
|
|
|
|
|
failed_field => $setup->{field}, |
89
|
|
|
|
|
|
|
failed_value => $_[0]->{ $setup->{field} }, |
90
|
|
|
|
|
|
|
} unless length( $_[0]->{ $setup->{field} } ) <= $setup->{maximum_length} |
91
|
0
|
0
|
|
0
|
|
|
}, |
92
|
0
|
|
0
|
|
|
|
} ); |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=item $bucket->value_length_is_between( HASHREF ) |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
minimum_length |
98
|
|
|
|
|
|
|
maximum_length |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=cut |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub _value_length_is_between |
103
|
|
|
|
|
|
|
{ |
104
|
0
|
|
|
0
|
|
|
my( $bucket, $setup ) = @_; |
105
|
|
|
|
|
|
|
|
106
|
0
|
|
|
|
|
|
local $setup->{name} = ''; |
107
|
|
|
|
|
|
|
|
108
|
0
|
|
|
|
|
|
my $min = $bucket->_value_length_is_equal_to_greater_than( $setup ); |
109
|
|
|
|
|
|
|
|
110
|
0
|
|
|
|
|
|
my $max = $bucket->_value_length_is_equal_to_less_than( $setup ); |
111
|
|
|
|
|
|
|
|
112
|
0
|
|
|
|
|
|
my $composed = $bucket->__compose_satisfy_all( $min, $max ); |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=back |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head1 TO DO |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
TBA |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head1 SEE ALSO |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
TBA |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=head1 SOURCE AVAILABILITY |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
This source is in Github: |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
https://github.com/briandfoy/brick |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head1 AUTHOR |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
brian d foy, C<< >> |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=head1 COPYRIGHT |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
Copyright © 2007-2021, brian d foy . All rights reserved. |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
You may redistribute this under the terms of the Artistic License 2.0. |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=cut |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
1; |