| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# Interface::Validation Document Class |
|
2
|
|
|
|
|
|
|
package Interface::Validation::Document; |
|
3
|
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
22490
|
use Bubblegum; |
|
|
1
|
|
|
|
|
231141
|
|
|
|
1
|
|
|
|
|
6
|
|
|
5
|
1
|
|
|
1
|
|
698544
|
use Function::Parameters; |
|
|
1
|
|
|
|
|
3121
|
|
|
|
1
|
|
|
|
|
8
|
|
|
6
|
1
|
|
|
1
|
|
842
|
use Moose; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use Interface::Validation::Container; |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
use Bubblegum::Constraints -minimal; |
|
11
|
|
|
|
|
|
|
use Hash::Flatten ':all'; |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $VERSION = '0.01_01'; # VERSION |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
has 'criteria' => ( |
|
16
|
|
|
|
|
|
|
is => 'ro', |
|
17
|
|
|
|
|
|
|
isa => 'Interface::Validation::Container', |
|
18
|
|
|
|
|
|
|
default => sub { Interface::Validation::Container->new }, |
|
19
|
|
|
|
|
|
|
); |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
has 'name' => ( |
|
22
|
|
|
|
|
|
|
is => 'ro', |
|
23
|
|
|
|
|
|
|
isa => 'Str', |
|
24
|
|
|
|
|
|
|
required => 1 |
|
25
|
|
|
|
|
|
|
); |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub BUILDARGS { |
|
28
|
|
|
|
|
|
|
my ($class, @args) = @_; |
|
29
|
|
|
|
|
|
|
return $args[0] if isa_hashref $args[0]; |
|
30
|
|
|
|
|
|
|
return { @args % 2 == 1 ? ('name', @args) : @args }; |
|
31
|
|
|
|
|
|
|
} |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
method criterion { |
|
34
|
|
|
|
|
|
|
my $criterion = _string shift; |
|
35
|
|
|
|
|
|
|
my $directive = _string shift; |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
$self->criteria->set($criterion => $directive); |
|
38
|
|
|
|
|
|
|
return $self; |
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
method collapse_data { |
|
42
|
|
|
|
|
|
|
my $data = _hashref shift; |
|
43
|
|
|
|
|
|
|
return _hashref(flatten($data)); |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
method explode_data { |
|
47
|
|
|
|
|
|
|
my $data = _hashref shift; |
|
48
|
|
|
|
|
|
|
return _hashref(unflatten($data)); |
|
49
|
|
|
|
|
|
|
} |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
method match_criterion { |
|
52
|
|
|
|
|
|
|
my $query = quotemeta _string shift; |
|
53
|
|
|
|
|
|
|
my $data = _hashref shift; |
|
54
|
|
|
|
|
|
|
my $keys = []; |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
my $token; |
|
57
|
|
|
|
|
|
|
my $regex; |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
$token = quotemeta '\.\@'; |
|
60
|
|
|
|
|
|
|
$regex = ':\d+'; |
|
61
|
|
|
|
|
|
|
$query =~ s/$token/$regex/g; |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
$token = quotemeta '\*'; |
|
64
|
|
|
|
|
|
|
$regex = '[^\.]+'; |
|
65
|
|
|
|
|
|
|
$query =~ s/$token/$regex/g; |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
for my $key ($data->keys->list) { |
|
68
|
|
|
|
|
|
|
$keys->push($key) if $key =~ /^$query$/; |
|
69
|
|
|
|
|
|
|
} |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
return $keys; |
|
72
|
|
|
|
|
|
|
} |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
1; |