File Coverage

blib/lib/Hubot/Scripts/help.pm
Criterion Covered Total %
statement 6 24 25.0
branch 0 4 0.0
condition n/a
subroutine 2 5 40.0
pod 0 1 0.0
total 8 34 23.5


line stmt bran cond sub pod time code
1             package Hubot::Scripts::help;
2             $Hubot::Scripts::help::VERSION = '0.2.7';
3 1     1   1151 use strict;
  1         3  
  1         44  
4 1     1   6 use warnings;
  1         2  
  1         403  
5              
6             sub load {
7 0     0 0   my ( $class, $robot ) = @_;
8             $robot->respond(
9             qr/help\s*(.*)?$/i,
10             sub {
11 0     0     my $msg = shift; # Hubot::Response
12 0           my @helps = $robot->helps;
13              
14 0           my $robotName = $robot->name;
15 0 0         unless ( $robotName =~ m/^hubot$/ ) {
16 0           map {s/hubot/$robotName/ig} @helps;
  0            
17             }
18              
19 0 0         if ( $msg->match->[0] ) {
20 0           my $regex = $msg->match->[0];
21 0           @helps = grep { $_ =~ /$regex/i } @helps;
  0            
22             }
23              
24 0           map {s/^/\# /} @helps;
  0            
25 0           $msg->send(@helps);
26             }
27 0           );
28              
29             $robot->respond(
30             qr/commands? *$/i,
31             sub {
32 0     0     my $msg = shift;
33 0           $msg->send( join( ', ', $robot->commands ) );
34             }
35 0           );
36             }
37              
38             1;
39              
40             =pod
41              
42             =encoding utf-8
43              
44             =head1 NAME
45              
46             Hubot::Scripts::help
47              
48             =head1 VERSION
49              
50             version 0.2.7
51              
52             =head1 SYNOPSIS
53              
54             hubot commands - Displays all commands at oneline
55             hubot help - Displays all of the help commands that Hubot knows about
56             hubot help <query> - Displays all help commands that match <query>
57              
58             =head1 DESCRIPTION
59              
60             These commands are grabbed from pod at the C<SYNOPSIS> section each file.
61              
62             =head1 AUTHOR
63              
64             Hyungsuk Hong <hshong@perl.kr>
65              
66             =head1 COPYRIGHT AND LICENSE
67              
68             This software is copyright (c) 2012 by Hyungsuk Hong.
69              
70             This is free software; you can redistribute it and/or modify it under
71             the same terms as the Perl 5 programming language system itself.
72              
73             =cut