File Coverage

blib/lib/App/GitHubWebhooks2Ikachan/Events/PullRequest.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::PullRequest;
2 2     2   955 use strict;
  2         3  
  2         63  
3 2     2   11 use warnings;
  2         3  
  2         50  
4 2     2   10 use utf8;
  2         4  
  2         13  
5 2     2   931 use String::IRC;
  2         1073  
  2         475  
6              
7             sub call {
8 6     6 0 15 my ($class, $context) = @_;
9              
10 6         29 my $pull_request = $context->dat->{pull_request};
11              
12 6         65 my $pull_request_title = $pull_request->{title};
13 6         19 my $user_name = $pull_request->{user}->{login};
14 6         11 my $url = $pull_request->{html_url};
15              
16 6         23 my $action = $context->dat->{action};
17 6         50 my $subscribe_actions = $context->req->param('pull_request');
18 6 100 100     148 if (
19 5         30 !$subscribe_actions || # Allow all actions
20             grep { $_ eq $action } split(/,/, $subscribe_actions) # Filter by specified actions
21             ) {
22 5         29 my $main_text = "[pull request $action (#$pull_request->{number})] $pull_request_title (\@$user_name)";
23              
24 5         41 return String::IRC->new($main_text)->green . " $url";
25             }
26              
27 1         6 return; # Not match any actions
28             }
29              
30             1;
31