Slack/Message.pm

filter: Statementstmt 42.8% 15 / 35 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 10 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 44.4% 4 / 9 Podpod 0.0% 0 / 5 totaltotal 26.3% 19 / 72 CC 10 SCAR 41.2
CC
10
Cov
28%
update
110.0
new
2.0
slack
2.0
CRAP 61.8
↑ Summary Slack.pm »
1 package Net::Async::Slack::Message;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 our $VERSION = '0.015'; # VERSION
7  
8 2 ▶use Scalar::Util qw(weaken);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use JSON::MaybeXS;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 2 my $json = JSON::MaybeXS->new;
12  
13 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=6.9
Pod undocumented
14 0 my $class = shift;
15 0 my $self = bless { @_ }, $class;
16 0 weaken $self->{slack};
17 0 $self
18 }
19  
20 0 ▶sub slack { shift->{slack} }
Subroutine slack: not called CC=1 SCAR=6.9
Pod undocumented
21 0 ▶sub channel { shift->{channel} }
Subroutine channel: not called CC=1 SCAR=6.9
Pod undocumented
22 0 ▶sub thread_ts { shift->{thread_ts} }
Subroutine thread_ts: not called CC=1 SCAR=6.9
Pod undocumented
23  
24 0 ▶sub update {
Subroutine update: not called CC=10 SCAR=47.0
Pod undocumented
25 0 my ($self, %args) = @_;
26 0 ▶ die 'You need to pass either text or attachments' unless $args{text} || $args{attachments} || $args{blocks};
Branch: 1 branch
BranchTrueFalseTotal
unless $args{"text"} or $args{"attachments"} or $args{"blocks"} 0 0 0
Condition0%0/6
$args{"text"} or $args{"attachments"} or $args{"blocks"}
l!l&&r!l&&!r
000
$args{"text"} or $args{"attachments"}
l!l&&r!l&&!r
000
MC/DC0%0/3
$args{"text"} or $args{"attachments"} or $args{"blocks"}
$args{"text"} $args{"attachments"} $args{"blocks"}
Truth table0%0/4
A or B or C
A= $args{"text"}B= $args{"attachments"}C= $args{"blocks"}
ABCresult
1XX1
01X1
0011
0000
27  
28 0 ▶ $args{text} //= '';
Condition0%0/2
$args{"text"} //= ""
l!l
00
MC/DC0%0/1
$args{"text"} //= ""
$args{"text"}
Truth table0%0/2
A
A= $args{"text"}
Aresult
11
00
29 0 my @content;
30 0 push @content, token => $self->slack->token;
31 0 push @content, channel => $self->channel;
32 0 push @content, ts => $self->thread_ts;
33  
34 0 ▶ push @content, text => $args{text} if defined $args{text};
Branch: 1 branch
BranchTrueFalseTotal
if defined $args{"text"} 0 0 0
35 0 ▶ push @content, attachments => $json->encode($args{attachments}) if $args{attachments};
Branch: 1 branch
BranchTrueFalseTotal
if $args{"attachments"} 0 0 0
36 0 ▶ push @content, blocks => $json->encode($args{blocks}) if $args{blocks};
Branch: 1 branch
BranchTrueFalseTotal
if $args{"blocks"} 0 0 0
37 0 ▶ $args{as_user} //= 'true';
Condition0%0/2
$args{"as_user"} //= "true"
l!l
00
MC/DC0%0/1
$args{"as_user"} //= "true"
$args{"as_user"}
Truth table0%0/2
A
A= $args{"as_user"}
Aresult
11
00
38 0 push @content, $_ => $args{$_} for grep exists $args{$_}, qw(parse link_names unfurl_links unfurl_media as_user reply_broadcast);
39 0 $self->slack->http_post(
40 $self->slack->endpoint(
41 'chat_update',
42 ),
43 \@content,
44 )
45 }
46  
47 2 1;
↑ Summary Slack.pm »