line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Text::Emoticon; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
82006
|
use strict; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
112
|
|
4
|
|
|
|
|
|
|
our $VERSION = '0.04'; |
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
2199
|
use UNIVERSAL::require; |
|
2
|
|
|
|
|
7917
|
|
|
2
|
|
|
|
|
23
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
my %map; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub new { |
11
|
2
|
|
|
2
|
0
|
591
|
my $class = shift; |
12
|
2
|
50
|
|
|
|
7
|
if ($class eq __PACKAGE__) { |
13
|
2
|
|
|
|
|
3
|
my $driver = shift; |
14
|
2
|
50
|
|
|
|
7
|
my $args = @_ == 1 ? $_[0] : {@_}; |
15
|
|
|
|
|
|
|
|
16
|
2
|
|
|
|
|
5
|
my $subclass = "Text::Emoticon::$driver"; |
17
|
2
|
50
|
|
|
|
14
|
$subclass->require or die $@; |
18
|
0
|
|
|
|
|
|
return bless { %{$subclass->default_config}, %$args }, $subclass; |
|
0
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
} else { |
20
|
0
|
0
|
|
|
|
|
my $args = @_ == 1 ? $_[0] : {@_}; |
21
|
0
|
|
|
|
|
|
return bless { %{$class->default_config}, %$args }, $class; |
|
0
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub register_subclass { |
26
|
0
|
|
|
0
|
0
|
|
my $class = shift; |
27
|
0
|
|
|
|
|
|
my($map) = @_; |
28
|
0
|
|
|
|
|
|
my $subclass = caller; |
29
|
0
|
|
|
|
|
|
$map{$subclass} = $map; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
0
|
|
|
0
|
0
|
|
sub map { $map{ref($_[0])} } |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub pattern { |
35
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
36
|
0
|
|
0
|
|
|
|
$self->{re} ||= "(" . join("|", map quotemeta($_), sort { length($b) <=> length($a) } keys %{$self->map}) . ")"; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
|
$self->{re}; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub filter_one { |
41
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
42
|
0
|
|
|
|
|
|
my($text) = @_; |
43
|
0
|
|
|
|
|
|
$self->do_filter($self->map->{$text}); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub filter { |
47
|
0
|
|
|
0
|
0
|
|
my($self, $text) = @_; |
48
|
0
|
0
|
|
|
|
|
return unless defined $text; |
49
|
0
|
|
|
|
|
|
my $re = $self->pattern; |
50
|
0
|
0
|
|
|
|
|
if ($self->{strict}) { |
51
|
0
|
|
|
|
|
|
$text =~ s{(?do_filter($self->map->{$1})}eg; |
|
0
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
} else { |
53
|
0
|
|
|
|
|
|
$text =~ s{$re}{$self->do_filter($self->map->{$1})}eg; |
|
0
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
} |
55
|
0
|
|
|
|
|
|
return $text; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub do_filter { |
59
|
0
|
|
|
0
|
0
|
|
my($self, $icon) = @_; |
60
|
0
|
0
|
|
|
|
|
my $class = $self->{class} ? qq( class="$self->{class}") : ""; |
61
|
0
|
0
|
|
|
|
|
my $xhtml = $self->{xhtml} ? qq( /) : ""; |
62
|
|
|
|
|
|
|
|
63
|
0
|
|
|
|
|
|
return qq(); |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
1; |
68
|
|
|
|
|
|
|
__END__ |