File Coverage

blib/lib/App/GitHubWebhooks2Ikachan/Events/Issues.pm
Criterion Covered Total %
statement 24 24 100.0
branch 2 2 100.0
condition 3 3 100.0
subroutine 5 5 100.0
pod 0 1 0.0
total 34 35 97.1


line stmt bran cond sub pod time code
1             package App::GitHubWebhooks2Ikachan::Events::Issues;
2 3     3   1071 use strict;
  3         32  
  3         162  
3 3     3   18 use warnings;
  3         9  
  3         109  
4 3     3   19 use utf8;
  3         7  
  3         24  
5 3     3   2288 use String::IRC;
  3         2597  
  3         854  
6              
7             sub call {
8 6     6 0 17 my ($class, $context) = @_;
9              
10 6         32 my $issue = $context->dat->{issue};
11              
12 6         63 my $issue_title = $issue->{title};
13 6         17 my $user_name = $issue->{user}->{login};
14 6         19 my $url = $issue->{html_url};
15              
16 6         22 my $action = $context->dat->{action};
17 6         48 my $subscribe_actions = $context->req->param('issues');
18 6 100 100     525 if (
19 4         21 !$subscribe_actions # Allow all actions
20             || grep { $_ eq $action } split(/,/, $subscribe_actions) # Filter by specified actions
21             ) {
22 5         27 my $main_text = "[issue $action (#$issue->{number})] $issue_title (\@$user_name)";
23              
24 5         34 return String::IRC->new($main_text)->green . " $url";
25             }
26              
27 1         6 return; # Not match any actions
28             }
29              
30             1;
31