File Coverage

blib/lib/Slack/BlockKit/Block/RichText/Channel.pm
Criterion Covered Total %
statement 11 11 100.0
branch n/a
condition n/a
subroutine 4 4 100.0
pod n/a
total 15 15 100.0


line stmt bran cond sub pod time code
1             package Slack::BlockKit::Block::RichText::Channel 0.005;
2             # ABSTRACT: a Block Kit rich text element that mentions a #channel
3              
4 4     4   30 use Moose;
  4         7  
  4         37  
5 4     4   20106 use MooseX::StrictConstructor;
  4         10  
  4         38  
6              
7             with 'Slack::BlockKit::Role::HasMentionStyle';
8              
9             #pod =head1 OVERVIEW
10             #pod
11             #pod This represents the mention of a specific Slack channel in a hunk of rich text.
12             #pod The channel name will be styled and linked-to. So, to send something like:
13             #pod
14             #pod We are discussing this on <#kerfuffles>.
15             #pod
16             #pod You would use the L<sugar|Slack::BlockKit::Sugar> like so:
17             #pod
18             #pod blocks(richtext(section(
19             #pod "We are discussing this on ", channel($channel_id), "."
20             #pod )));
21             #pod
22             #pod =cut
23              
24 4     4   15554 use v5.36.0;
  4         34  
25              
26             #pod =attr channel_id
27             #pod
28             #pod This must be the Slack channel id for the channel being mentioned. This is
29             #pod generally a bunch of alphanumeric characters beginning with C<C>.
30             #pod
31             #pod =cut
32              
33             has channel_id => (
34             is => 'ro',
35             isa => 'Str',
36             required => 1,
37             );
38              
39             sub as_struct ($self) {
40             return {
41             type => 'channel',
42             channel_id => $self->channel_id,
43             };
44             }
45              
46 4     4   32 no Moose;
  4         9  
  4         27  
47             __PACKAGE__->meta->make_immutable;
48              
49             __END__
50              
51             =pod
52              
53             =encoding UTF-8
54              
55             =head1 NAME
56              
57             Slack::BlockKit::Block::RichText::Channel - a Block Kit rich text element that mentions a #channel
58              
59             =head1 VERSION
60              
61             version 0.005
62              
63             =head1 OVERVIEW
64              
65             This represents the mention of a specific Slack channel in a hunk of rich text.
66             The channel name will be styled and linked-to. So, to send something like:
67              
68             We are discussing this on <#kerfuffles>.
69              
70             You would use the L<sugar|Slack::BlockKit::Sugar> like so:
71              
72             blocks(richtext(section(
73             "We are discussing this on ", channel($channel_id), "."
74             )));
75              
76             =head1 PERL VERSION
77              
78             This module should work on any version of perl still receiving updates from
79             the Perl 5 Porters. This means it should work on any version of perl
80             released in the last two to three years. (That is, if the most recently
81             released version is v5.40, then this module should work on both v5.40 and
82             v5.38.)
83              
84             Although it may work on older versions of perl, no guarantee is made that the
85             minimum required version will not be increased. The version may be increased
86             for any reason, and there is no promise that patches will be accepted to
87             lower the minimum required perl.
88              
89             =head1 ATTRIBUTES
90              
91             =head2 channel_id
92              
93             This must be the Slack channel id for the channel being mentioned. This is
94             generally a bunch of alphanumeric characters beginning with C<C>.
95              
96             =head1 AUTHOR
97              
98             Ricardo SIGNES <cpan@semiotic.systems>
99              
100             =head1 COPYRIGHT AND LICENSE
101              
102             This software is copyright (c) 2024 by Ricardo SIGNES.
103              
104             This is free software; you can redistribute it and/or modify it under
105             the same terms as the Perl 5 programming language system itself.
106              
107             =cut