line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
3
|
|
|
3
|
|
896
|
use strict; |
|
3
|
|
|
|
|
10
|
|
|
3
|
|
|
|
|
187
|
|
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package HTML::FormFu::Filter::CompoundSprintf; |
4
|
|
|
|
|
|
|
$HTML::FormFu::Filter::CompoundSprintf::VERSION = '2.07'; |
5
|
|
|
|
|
|
|
# ABSTRACT: CompoundSprintf filter |
6
|
|
|
|
|
|
|
|
7
|
3
|
|
|
3
|
|
19
|
use Moose; |
|
3
|
|
|
|
|
9
|
|
|
3
|
|
|
|
|
31
|
|
8
|
3
|
|
|
3
|
|
21332
|
use MooseX::Attribute::Chained; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
154
|
|
9
|
|
|
|
|
|
|
extends 'HTML::FormFu::Filter'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
with 'HTML::FormFu::Role::Filter::Compound'; |
12
|
|
|
|
|
|
|
|
13
|
3
|
|
|
3
|
|
20
|
use HTML::FormFu::Constants qw( $EMPTY_STR ); |
|
3
|
|
|
|
|
9
|
|
|
3
|
|
|
|
|
435
|
|
14
|
3
|
|
|
3
|
|
23
|
use Carp qw( croak ); |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
626
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
has sprintf => ( is => 'rw', traits => ['Chained'] ); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub filter { |
19
|
2
|
|
|
2
|
0
|
7
|
my ( $self, $value ) = @_; |
20
|
|
|
|
|
|
|
|
21
|
2
|
50
|
33
|
|
|
35
|
return if !defined $value || $value eq $EMPTY_STR; |
22
|
|
|
|
|
|
|
|
23
|
2
|
|
|
|
|
102
|
my $sprintf = $self->sprintf; |
24
|
|
|
|
|
|
|
|
25
|
2
|
50
|
|
|
|
8
|
croak 'sprintf pattern required' if !defined $sprintf; |
26
|
|
|
|
|
|
|
|
27
|
2
|
|
|
|
|
13
|
my @values = $self->_get_values($value); |
28
|
|
|
|
|
|
|
|
29
|
2
|
|
|
|
|
26
|
$value = CORE::sprintf( $sprintf, @values ); |
30
|
|
|
|
|
|
|
|
31
|
2
|
|
|
|
|
12
|
return $value; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
1; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
__END__ |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=pod |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=encoding UTF-8 |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head1 NAME |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
HTML::FormFu::Filter::CompoundSprintf - CompoundSprintf filter |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head1 VERSION |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
version 2.07 |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head1 SYNOPSIS |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
--- |
55
|
|
|
|
|
|
|
element: |
56
|
|
|
|
|
|
|
- type: Multi |
57
|
|
|
|
|
|
|
name: date |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
elements: |
60
|
|
|
|
|
|
|
- name: day |
61
|
|
|
|
|
|
|
- name: month |
62
|
|
|
|
|
|
|
- name: year |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
filter: |
65
|
|
|
|
|
|
|
- type: CompoundSprintf |
66
|
|
|
|
|
|
|
sprintf: '%02d-%02d-%04d' |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
# get the compound-value |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
my $date = $form->param_value('date'); |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 DESCRIPTION |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
For use with a L<HTML::FormFu::Element::Multi> group of fields. |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
Uses a sprintf pattern to join the input from several fields into a single |
77
|
|
|
|
|
|
|
value. |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head1 METHODS |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head2 sprintf |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
Arguments: $string |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
C<sprintf> pattern used to join the individually submitted parts. |
86
|
|
|
|
|
|
|
The pattern is passed to the perl-core C<sprintf> function. |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head2 field_order |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Inherited. See L<HTML::FormFu::Filter::_Compound/field_order> for details. |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
--- |
93
|
|
|
|
|
|
|
element: |
94
|
|
|
|
|
|
|
- type: Multi |
95
|
|
|
|
|
|
|
name: date |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
elements: |
98
|
|
|
|
|
|
|
- name: month |
99
|
|
|
|
|
|
|
- name: day |
100
|
|
|
|
|
|
|
- name year |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
filter: |
103
|
|
|
|
|
|
|
- type: CompoundSprintf |
104
|
|
|
|
|
|
|
field_order: |
105
|
|
|
|
|
|
|
- day |
106
|
|
|
|
|
|
|
- month |
107
|
|
|
|
|
|
|
- year |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head1 AUTHOR |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
Carl Franks, C<cfranks@cpan.org> |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head1 LICENSE |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
This library is free software, you can redistribute it and/or modify it under |
116
|
|
|
|
|
|
|
the same terms as Perl itself. |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head1 AUTHOR |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
Carl Franks <cpan@fireartist.com> |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
This software is copyright (c) 2018 by Carl Franks. |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
127
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=cut |