| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# $Id: /mirror/perl/URI-Match/trunk/lib/URI/Match.pm 8767 2007-11-08T01:41:57.358392Z daisuke $ |
|
2
|
|
|
|
|
|
|
# |
|
3
|
|
|
|
|
|
|
# Copyright (c) 2007 Daisuke Maki |
|
4
|
|
|
|
|
|
|
# All rights reserved. |
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
package URI::Match; |
|
7
|
2
|
|
|
2
|
|
36849
|
use strict; |
|
|
2
|
|
|
|
|
6
|
|
|
|
2
|
|
|
|
|
77
|
|
|
8
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
63
|
|
|
9
|
2
|
|
|
2
|
|
1063
|
use URI(); |
|
|
2
|
|
|
|
|
5719
|
|
|
|
2
|
|
|
|
|
47
|
|
|
10
|
2
|
|
|
2
|
|
15
|
use vars ('$VERSION'); |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
667
|
|
|
11
|
|
|
|
|
|
|
$VERSION = '0.00001'; |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub URI::match_parts |
|
14
|
|
|
|
|
|
|
{ |
|
15
|
12
|
|
|
12
|
0
|
27384
|
my $self = shift; |
|
16
|
|
|
|
|
|
|
|
|
17
|
12
|
100
|
|
|
|
38
|
if (@_ == 1) { |
|
18
|
2
|
|
|
|
|
8
|
return $self->_match( undef, $_[0] ); |
|
19
|
|
|
|
|
|
|
} |
|
20
|
|
|
|
|
|
|
|
|
21
|
10
|
|
|
|
|
13
|
my $matched = 0; |
|
22
|
10
|
|
|
|
|
14
|
my $count = 0; |
|
23
|
10
|
|
|
|
|
21
|
while (@_) { |
|
24
|
12
|
|
|
|
|
31
|
my($part, $cond) = splice(@_, 0, 2); |
|
25
|
12
|
|
|
|
|
14
|
$count++; |
|
26
|
|
|
|
|
|
|
|
|
27
|
12
|
100
|
|
|
|
39
|
$matched++ if $self->_match( $part, $cond ); |
|
28
|
|
|
|
|
|
|
} |
|
29
|
10
|
|
|
|
|
245
|
return $matched == $count; |
|
30
|
|
|
|
|
|
|
} |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub URI::_match |
|
33
|
|
|
|
|
|
|
{ |
|
34
|
14
|
|
|
14
|
|
21
|
my ($self, $part, $cond) = @_; |
|
35
|
|
|
|
|
|
|
|
|
36
|
14
|
50
|
50
|
|
|
221
|
my $target = |
|
|
|
100
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
! defined $part ? $self : |
|
38
|
|
|
|
|
|
|
$self->can($part) ? ( $self->$part || '' ) : '' |
|
39
|
|
|
|
|
|
|
; |
|
40
|
|
|
|
|
|
|
|
|
41
|
14
|
|
|
|
|
5460
|
my $ref = ref $cond ; |
|
42
|
14
|
100
|
100
|
|
|
67
|
if (! $ref || $ref eq 'Regexp') { |
|
|
|
100
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
43
|
10
|
|
|
|
|
670
|
return $target =~ /$cond/; |
|
44
|
|
|
|
|
|
|
} elsif ($ref eq 'CODE') { |
|
45
|
2
|
|
|
|
|
7
|
return $cond->($target, $self); |
|
46
|
2
|
|
|
|
|
20
|
} elsif ( my $code = eval { $cond->can('match') } ) { |
|
47
|
2
|
|
|
|
|
9
|
return $code->( $cond, $target, $self ); |
|
48
|
|
|
|
|
|
|
} |
|
49
|
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
|
return (); |
|
51
|
|
|
|
|
|
|
} |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
1; |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
__END__ |