line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Form::Factory::Feature::Control::Trim; |
2
|
|
|
|
|
|
|
$Form::Factory::Feature::Control::Trim::VERSION = '0.022'; |
3
|
1
|
|
|
1
|
|
622
|
use Moose; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
7
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
with qw( |
6
|
|
|
|
|
|
|
Form::Factory::Feature |
7
|
|
|
|
|
|
|
Form::Factory::Feature::Role::Clean |
8
|
|
|
|
|
|
|
Form::Factory::Feature::Role::Control |
9
|
|
|
|
|
|
|
); |
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
4966
|
use Carp (); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
164
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# ABSTRACT: Trims whitespace from a control value |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub check_control { |
17
|
8
|
|
|
8
|
1
|
15
|
my ($self, $control) = @_; |
18
|
|
|
|
|
|
|
|
19
|
8
|
50
|
|
|
|
24
|
return if $control->does('Form::Factory::Control::Role::ScalarValue'); |
20
|
|
|
|
|
|
|
|
21
|
0
|
|
|
|
|
0
|
Carp::croak("the trim feature only works on scalar values, not $control"); |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub clean { |
26
|
6
|
|
|
6
|
1
|
11
|
my $self = shift; |
27
|
6
|
|
|
|
|
188
|
my $control = $self->control; |
28
|
|
|
|
|
|
|
|
29
|
6
|
|
|
|
|
17
|
my $value = $control->current_value; |
30
|
6
|
|
|
|
|
24
|
$value =~ s/^\s*//; |
31
|
6
|
|
|
|
|
23
|
$value =~ s/\s*$//; |
32
|
|
|
|
|
|
|
|
33
|
6
|
|
|
|
|
17
|
$control->current_value($value); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
__END__ |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=pod |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=encoding UTF-8 |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head1 NAME |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
Form::Factory::Feature::Control::Trim - Trims whitespace from a control value |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head1 VERSION |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
version 0.022 |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head1 SYNOPSIS |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
has_control title => ( |
55
|
|
|
|
|
|
|
control => 'text', |
56
|
|
|
|
|
|
|
features => { |
57
|
|
|
|
|
|
|
trim => 1, |
58
|
|
|
|
|
|
|
}, |
59
|
|
|
|
|
|
|
); |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 DESCRIPTION |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
Strips whitespace from the front and back of the given values. |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 METHODS |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head2 check_control |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
Reports an error unless the control is a scalar value. |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head2 clean |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
Strips whitespace from the start and end of the control value. |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 AUTHOR |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
Andrew Sterling Hanenkamp <hanenkamp@cpan.org> |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
This software is copyright (c) 2015 by Qubling Software LLC. |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
84
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=cut |