MenuGrinder/Plugin/Hotkey.pm untested

filter: Statementstmt 0.0% 0 / 15 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 4 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 27 CC 4 SCAR 25.1
CC
4
Cov
0%
item_pre_mogrify
20.0
plugin_depends
2.0
BEGIN
2.0
CRAP 12.3
1 package WWW::MenuGrinder::Plugin::Hotkey;
2 our $VERSION = '0.01_01';
3  
4  
5 # ABSTRACT: WWW::MenuGrinder plugin that generates hotkeys from labels.
6  
7 use Moose;
8  
9 with 'WWW::MenuGrinder::Role::ItemPreMogrifier';
10  
11 sub plugin_depends { qw(Visitor) }
12  
13 sub item_pre_mogrify {
14 my ($self, $item) = @_;
15  
16 return $item unless exists $item->{label};
17  
18 if ($item->{label} =~ s#_(.)#<u>$1</u>#) {
19 $item->{hotkey} = uc $1 unless defined $item->{hotkey};
20 }
21  
22 return $item;
23 }
24  
25 no Moose;
26 1;
27  
28  
29 __END__
30 =head1 NAME
31  
32 WWW::MenuGrinder::Plugin::Hotkey - WWW::MenuGrinder plugin that generates hotkeys from labels.
33  
34 =head1 VERSION
35  
36 version 0.01_01
37  
38 =head1 DESCRIPTION
39  
40 C<WWW::MenuGrinder::Plugin::HotKey> is a plugin for C<WWW::MenuGrinder>. You
41 should not use it directly, but include it in the C<plugins> section of a
42 C<WWW::MenuGrinder> config.
43  
44 When loaded, this plugin will scan the menu for C<label> keys containing
45 underscores. If an underscore is found, it will be removed, and the following
46 character wrapped in C<< <u> >> tags (for example, C<"Hot_key"> becomes
47 C<< "Hot<u>k</u>ey" >>, and the item's C<hotkey> key is set to the underlined
48 character.
49  
50 =head2 Configuration
51  
52 None.
53  
54 =head2 Dependencies
55  
56 C<WWW::MenuGrinder::Plugin::Visitor>.
57  
58 =head2 Bugs
59  
60 This should probably be way more generic, instead of only useful for me.
61 Suggestions welcome.
62  
63 =head1 AUTHOR
64  
65 Andrew Rodland <andrew@hbslabs.com>
66  
67 =head1 COPYRIGHT AND LICENSE
68  
69 This software is copyright (c) 2009 by HBS Labs, LLC..
70  
71 This is free software; you can redistribute it and/or modify it under
72 the same terms as perl itself.
73