Backbone/Bot/Role/GroupChat.pm untested

filter: Statementstmt 0.0% 0 / 21 Branchbran n/a Conditioncond 0.0% 0 / 3 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 32 CC 1 SCAR 6.9
CC
1
Cov
0%
list_group_names
2.0
find_group
2.0
BEGIN
2.0
CRAP 2.0
1 package Bot::Backbone::Bot::Role::GroupChat;
2 $Bot::Backbone::Bot::Role::GroupChat::VERSION = '0.160630';
3 use v5.10;
4 use Moose::Role;
5  
6 use List::Util qw( first );
7  
8 use namespace::autoclean;
9  
10 # ABSTRACT: Provides some group related help tools
11  
12  
13 sub list_group_names {
14 my $self = shift;
15 return map { $_->group }
16 grep { $_->isa('Bot::Backbone::Service::GroupChat') }
17 $self->list_services;
18 }
19  
20  
21 sub find_group {
22 my ($self, $name) = @_;
23 return first { $_->isa('Bot::Backbone::Service::GroupChat')
24 and $_->group eq $name } $self->list_services;
25 }
26  
27 1;
28  
29 __END__
30  
31 =pod
32  
33 =encoding UTF-8
34  
35 =head1 NAME
36  
37 Bot::Backbone::Bot::Role::GroupChat - Provides some group related help tools
38  
39 =head1 VERSION
40  
41 version 0.160630
42  
43 =head1 SYNOPSIS
44  
45 service group_foo => (
46 service => 'GroupChat',
47 chat => 'jabber_chat',
48 group => 'foo',
49 );
50  
51 service group_bar => (
52 service => 'GroupChat',
53 chat => 'jabber_chat',
54 group => 'bar',
55 );
56  
57 ...
58  
59 for my $name ($bot->list_group_names) { say " * $name" }
60  
61 my $chat = $bot->find_group('foo');
62 $chat->send_message({ text => 'just to group foo' });
63  
64 =head1 DESCRIPTION
65  
66 This role is automatically applied to any bot that has one or more L<Bot::Backbone::Service::GroupChat> services.
67  
68 =head1 METHODS
69  
70 =head2 list_group_names
71  
72 Returns the names of all the groups that this bot has joined or intends on joining.
73  
74 =head2 find_group
75  
76 my $chat = $bot->find_group('foo');
77  
78 Returns the L<Bot::Backbone::Service::GroupChat> that entered the named group.
79  
80 =head1 AUTHOR
81  
82 Andrew Sterling Hanenkamp <hanenkamp@cpan.org>
83  
84 =head1 COPYRIGHT AND LICENSE
85  
86 This software is copyright (c) 2016 by Qubling Software LLC.
87  
88 This is free software; you can redistribute it and/or modify it under
89 the same terms as the Perl 5 programming language system itself.
90  
91 =cut