line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ============================================================================ |
2
|
|
|
|
|
|
|
package MooseX::App::Plugin::Typo::Meta::Class; |
3
|
|
|
|
|
|
|
# ============================================================================ |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
966
|
use 5.010; |
|
1
|
|
|
|
|
4
|
|
6
|
1
|
|
|
1
|
|
6
|
use utf8; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
24
|
use namespace::autoclean; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
9
|
1
|
|
|
1
|
|
73
|
use Moose::Role; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
5388
|
use Text::WagnerFischer qw(distance); |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
239
|
|
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; |