line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Data::Microformat::hCard::type; |
2
|
14
|
|
|
14
|
|
1722
|
use base qw(Data::Microformat); |
|
14
|
|
|
|
|
25
|
|
|
14
|
|
|
|
|
1705
|
|
3
|
|
|
|
|
|
|
|
4
|
14
|
|
|
14
|
|
69
|
use strict; |
|
14
|
|
|
|
|
21
|
|
|
14
|
|
|
|
|
466
|
|
5
|
14
|
|
|
14
|
|
60
|
use warnings; |
|
14
|
|
|
|
|
20
|
|
|
14
|
|
|
|
|
10045
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = "0.04"; |
8
|
|
|
|
|
|
|
|
9
|
39
|
|
|
39
|
1
|
146
|
sub class_name { "REPLACE_WITH_KIND" } |
10
|
46
|
|
|
46
|
1
|
134
|
sub plural_fields { qw(type) } |
11
|
46
|
|
|
46
|
1
|
182
|
sub singular_fields { qw(value kind) } |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub from_tree |
14
|
|
|
|
|
|
|
{ |
15
|
22
|
|
|
22
|
1
|
37
|
my $class = shift; |
16
|
22
|
|
|
|
|
29
|
my $tree = shift; |
17
|
|
|
|
|
|
|
|
18
|
22
|
|
|
|
|
131
|
$tree = $tree->look_down("class", qr/./); |
19
|
|
|
|
|
|
|
|
20
|
22
|
50
|
|
|
|
943
|
return unless $tree; |
21
|
|
|
|
|
|
|
|
22
|
22
|
|
|
|
|
97
|
my $object = Data::Microformat::hCard::type->new; |
23
|
22
|
|
|
|
|
68
|
$object->{_no_dupe_keys} = 1; |
24
|
22
|
|
|
|
|
71
|
$object->kind($class->_remove_newlines($class->_trim($tree->attr('class')))); |
25
|
22
|
|
|
|
|
75
|
my @bits = $tree->content_list; |
26
|
22
|
|
|
|
|
153
|
foreach my $bit (@bits) |
27
|
|
|
|
|
|
|
{ |
28
|
47
|
100
|
66
|
|
|
173
|
if (ref($bit) eq "HTML::Element") |
|
|
100
|
100
|
|
|
|
|
29
|
|
|
|
|
|
|
{ |
30
|
19
|
50
|
|
|
|
62
|
next unless $bit->attr('class'); |
31
|
19
|
|
|
|
|
212
|
my @types = split(" ", $bit->attr('class')); |
32
|
19
|
|
|
|
|
179
|
foreach my $type (@types) |
33
|
|
|
|
|
|
|
{ |
34
|
19
|
|
|
|
|
66
|
$type = $class->_trim($type); |
35
|
19
|
|
|
|
|
53
|
my @cons = $bit->content_list; |
36
|
19
|
|
|
|
|
151
|
my $data = $class->_trim($cons[0]); |
37
|
19
|
100
|
66
|
|
|
54
|
if ($bit->tag eq "abbr" && $bit->attr('title')) |
|
|
100
|
33
|
|
|
|
|
|
|
|
66
|
|
|
|
|
38
|
|
|
|
|
|
|
{ |
39
|
2
|
|
|
|
|
39
|
$data = $class->_trim($bit->attr('title')); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
elsif ($tree->attr('class') =~ m/(email|tel)/ && $bit->tag =~ m/(a|area)/ && $bit->attr('href')) |
42
|
|
|
|
|
|
|
{ |
43
|
2
|
|
|
|
|
62
|
$data = $class->_trim($class->_url_decode($bit->attr('href'))); |
44
|
2
|
|
|
|
|
14
|
$data =~ s/^(mailto|tel)\://; |
45
|
2
|
|
|
|
|
3
|
$data =~ s/\?$//; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
19
|
50
|
|
|
|
736
|
if ($type eq $object->kind) |
49
|
|
|
|
|
|
|
{ |
50
|
0
|
|
|
|
|
0
|
$object->value($data); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
else |
53
|
|
|
|
|
|
|
{ |
54
|
19
|
|
|
|
|
111
|
$object->$type($data); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
elsif ($tree->attr('class') =~ m/(email|tel)/ && $tree->tag =~ m/(a|area)/ && $tree->attr('href')) |
59
|
|
|
|
|
|
|
{ |
60
|
|
|
|
|
|
|
# This check deals with non-nested mailto links-- such as are created by the official hCard creator. |
61
|
2
|
|
|
|
|
69
|
my $data = $class->_trim($class->_url_decode($tree->attr('href'))); |
62
|
2
|
|
|
|
|
11
|
$data =~ s/^(mailto|tel)\://; |
63
|
2
|
|
|
|
|
6
|
$data =~ s/\?$//; |
64
|
2
|
|
|
|
|
12
|
$object->value($data); |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
else |
67
|
|
|
|
|
|
|
{ |
68
|
26
|
|
|
|
|
789
|
$bit = $class->_trim($bit); |
69
|
26
|
100
|
100
|
|
|
163
|
if (length $bit > 0 && !$object->value) |
70
|
|
|
|
|
|
|
{ |
71
|
16
|
|
|
|
|
68
|
$object->value($bit); |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
} |
75
|
22
|
|
|
|
|
43
|
$object->{_no_dupe_keys} = 0; |
76
|
22
|
|
|
|
|
62
|
return $object; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
1; |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
__END__ |