line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ============================================================================ |
2
|
|
|
|
|
|
|
package MooseX::App::Plugin::Typo::Meta::Class; |
3
|
|
|
|
|
|
|
# ============================================================================ |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
900
|
use 5.010; |
|
1
|
|
|
|
|
3
|
|
6
|
1
|
|
|
1
|
|
4
|
use utf8; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
4
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
44
|
use namespace::autoclean; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
4
|
|
9
|
1
|
|
|
1
|
|
53
|
use Moose::Role; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
4
|
|
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
3320
|
use Text::WagnerFischer qw(distance); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
199
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
around 'command_candidates' => sub { |
14
|
|
|
|
|
|
|
my ($orig,$self,$command) = @_; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
my $lc_command = lc($command); |
17
|
|
|
|
|
|
|
my $commands = $self->app_commands; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# Fuzzy match |
20
|
|
|
|
|
|
|
my @candidates; |
21
|
|
|
|
|
|
|
my $candidate_length = length($command); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# Compare all commands to find matching candidates |
24
|
|
|
|
|
|
|
foreach my $command_name (keys %$commands) { |
25
|
|
|
|
|
|
|
my $candidate_substr = substr($command_name,0,$candidate_length+1); |
26
|
|
|
|
|
|
|
if ($lc_command eq $command_name) { |
27
|
|
|
|
|
|
|
return $command_name; |
28
|
|
|
|
|
|
|
} elsif ($lc_command eq $candidate_substr |
29
|
|
|
|
|
|
|
|| distance($lc_command,$candidate_substr) <= 1) { |
30
|
|
|
|
|
|
|
push(@candidates,$command_name); |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
return [ sort @candidates ]; |
34
|
|
|
|
|
|
|
}; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
1; |