| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
1
|
|
|
1
|
|
37788
|
use strict; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
58
|
|
|
2
|
1
|
|
|
1
|
|
7
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
42
|
|
|
3
|
1
|
|
|
1
|
|
33
|
use 5.010; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
79
|
|
|
4
|
|
|
|
|
|
|
package Data::Rx::Type::PCRE; |
|
5
|
|
|
|
|
|
|
{ |
|
6
|
|
|
|
|
|
|
$Data::Rx::Type::PCRE::VERSION = '0.005'; |
|
7
|
|
|
|
|
|
|
} |
|
8
|
1
|
|
|
1
|
|
5
|
use parent 'Data::Rx::CommonType::EasyNew'; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
10
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# ABSTRACT: PCRE string checking for Rx (experimental) |
|
11
|
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
9424
|
use Carp (); |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
267
|
|
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
|
15
|
0
|
|
|
0
|
|
|
sub type_uri { 'tag:rjbs.manxome.org,2008-10-04:rx/pcre/str' } |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub guts_from_arg { |
|
18
|
|
|
|
|
|
|
my ($class, $arg, $rx, $type) = @_; |
|
19
|
|
|
|
|
|
|
$arg ||= {}; |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
my $regex = $arg->{regex}; |
|
22
|
|
|
|
|
|
|
my $flags = $arg->{flags} // ''; |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
Carp::croak("no regex supplied for $class type") unless defined $regex; |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
my $regex_str = (length $flags) ? "(?$flags)$regex" : $regex; |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
my $re = do { |
|
29
|
1
|
|
|
1
|
|
2210
|
use re::engine::PCRE; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
qr{$regex_str}; |
|
31
|
|
|
|
|
|
|
}; |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
return { |
|
34
|
|
|
|
|
|
|
re => $re, |
|
35
|
|
|
|
|
|
|
re_str => $regex_str, |
|
36
|
|
|
|
|
|
|
}; |
|
37
|
|
|
|
|
|
|
} |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub assert_valid { |
|
40
|
|
|
|
|
|
|
my ($self, $value) = @_; |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
unless ($value =~ $self->{re}) { |
|
43
|
|
|
|
|
|
|
$self->fail({ |
|
44
|
|
|
|
|
|
|
error => [ qw(value) ], |
|
45
|
|
|
|
|
|
|
# we should pick better delimiters -- rjbs, 2012-09-18 |
|
46
|
|
|
|
|
|
|
message => "found value does not match /$self->{re_str}/", |
|
47
|
|
|
|
|
|
|
value => $value, |
|
48
|
|
|
|
|
|
|
}); |
|
49
|
|
|
|
|
|
|
} |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
return 1; |
|
52
|
|
|
|
|
|
|
} |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
1; |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
__END__ |