File Coverage

blib/lib/Slack/BlockKit/Block/RichText/Quote.pm
Criterion Covered Total %
statement 14 19 73.6
branch 0 2 0.0
condition n/a
subroutine 5 6 83.3
pod 0 1 0.0
total 19 28 67.8


line stmt bran cond sub pod time code
1             package Slack::BlockKit::Block::RichText::Quote 0.005;
2             # ABSTRACT: a Block Kit rich text "quoted text" block
3              
4 4     4   26 use Moose;
  4         8  
  4         38  
5 4     4   19756 use MooseX::StrictConstructor;
  4         8  
  4         40  
6              
7 4     4   13860 use Slack::BlockKit::Types qw(ExpansiveElementList Pixels);
  4         10  
  4         45  
8              
9             #pod =head1 OVERVIEW
10             #pod
11             #pod This is a "quote" element, which is formatted something like C<< > >>-prefixed
12             #pod text in Markdown.
13             #pod
14             #pod =cut
15              
16 4     4   9289 use v5.36.0;
  4         19  
17              
18             #pod =attr border
19             #pod
20             #pod This property is meant to be the number of pixels wide the border is. In
21             #pod practice, the author has only found this to cause Slack to reject Block Kit
22             #pod structures.
23             #pod
24             #pod =cut
25              
26             has border => (
27             is => 'ro',
28             isa => Pixels(),
29             predicate => 'has_border',
30             );
31              
32             #pod =attr elements
33             #pod
34             #pod This is an arrayref of rich text elements.
35             #pod
36             #pod =cut
37              
38             has elements => (
39             isa => ExpansiveElementList(),
40             traits => [ 'Array' ],
41             handles => { elements => 'elements' },
42             );
43              
44 0     0 0   sub as_struct ($self) {
  0            
  0            
45             return {
46             type => 'rich_text_quote',
47 0 0         elements => [ map {; $_->as_struct } $self->elements ],
  0            
48             ($self->has_border ? (border => $self->border) : ()),
49             };
50             }
51              
52 4     4   27 no Moose;
  4         8  
  4         25  
53             __PACKAGE__->meta->make_immutable;
54              
55             __END__
56              
57             =pod
58              
59             =encoding UTF-8
60              
61             =head1 NAME
62              
63             Slack::BlockKit::Block::RichText::Quote - a Block Kit rich text "quoted text" block
64              
65             =head1 VERSION
66              
67             version 0.005
68              
69             =head1 OVERVIEW
70              
71             This is a "quote" element, which is formatted something like C<< > >>-prefixed
72             text in Markdown.
73              
74             =head1 PERL VERSION
75              
76             This module should work on any version of perl still receiving updates from
77             the Perl 5 Porters. This means it should work on any version of perl
78             released in the last two to three years. (That is, if the most recently
79             released version is v5.40, then this module should work on both v5.40 and
80             v5.38.)
81              
82             Although it may work on older versions of perl, no guarantee is made that the
83             minimum required version will not be increased. The version may be increased
84             for any reason, and there is no promise that patches will be accepted to
85             lower the minimum required perl.
86              
87             =head1 ATTRIBUTES
88              
89             =head2 border
90              
91             This property is meant to be the number of pixels wide the border is. In
92             practice, the author has only found this to cause Slack to reject Block Kit
93             structures.
94              
95             =head2 elements
96              
97             This is an arrayref of rich text elements.
98              
99             =head1 AUTHOR
100              
101             Ricardo SIGNES <cpan@semiotic.systems>
102              
103             =head1 COPYRIGHT AND LICENSE
104              
105             This software is copyright (c) 2024 by Ricardo SIGNES.
106              
107             This is free software; you can redistribute it and/or modify it under
108             the same terms as the Perl 5 programming language system itself.
109              
110             =cut