Slack/Message.pm

filter: Statementstmt 44.1% 15 / 34 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 7 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 44.4% 4 / 9 Podpod 0.0% 0 / 5 totaltotal 29.2% 19 / 65 CC 8 SCAR 36.0
CC
8
Cov
32%
update
72.0
new
2.0
slack
2.0
CRAP 36.8
↑ Summary Slack/EventType.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.007'; # 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 sub new {
14 0 ▶ my $class = shift;
Subroutine new: not called CC=1 SCAR=6.9
Pod undocumented
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 sub update {
25 0 ▶ my ($self, %args) = @_;
Subroutine update: not called CC=8 SCAR=42.8
Pod undocumented
26 0 ▶ die 'You need to pass either text or attachments' unless $args{text} || $args{attachments};
Branch: 1 branch
BranchTrueFalseTotal
unless $args{"text"} or $args{"attachments"} 0 0 0
Condition0%0/3
$args{"text"} or $args{"attachments"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$args{"text"} or $args{"attachments"}
$args{"text"} $args{"attachments"}
Truth table0%0/3
A or B
A= $args{"text"}B= $args{"attachments"}
ABresult
1X1
011
000
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 ▶ $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
37 0 push @content, $_ => $args{$_} for grep exists $args{$_}, qw(parse link_names unfurl_links unfurl_media as_user reply_broadcast);
38 0 $self->slack->http_post(
39 $self->slack->endpoint(
40 'chat.update',
41 ),
42 \@content,
43 )
44 }
45  
46 2 1;
↑ Summary Slack/EventType.pm »