File Coverage

blib/lib/Slack/BlockKit/Block/RichText/List.pm
Criterion Covered Total %
statement 23 30 76.6
branch 0 2 0.0
condition n/a
subroutine 8 9 88.8
pod 0 1 0.0
total 31 42 73.8


line stmt bran cond sub pod time code
1             package Slack::BlockKit::Block::RichText::List 0.005;
2             # ABSTRACT: a Block Kit rich text list element
3 4     4   33 use Moose;
  4         12  
  4         57  
4 4     4   23470 use MooseX::StrictConstructor;
  4         12  
  4         45  
5              
6 4     4   16447 use Moose::Util::TypeConstraints qw(class_type enum);
  4         9  
  4         49  
7 4     4   2951 use MooseX::Types::Moose qw(ArrayRef);
  4         11  
  4         53  
8 4     4   26254 use Slack::BlockKit::Types qw(Pixels RichTextArray);
  4         8  
  4         240  
9              
10             #pod =head1 OVERVIEW
11             #pod
12             #pod This represents a rich text list, which will be rendered as either a bullet or
13             #pod numbered list.
14             #pod
15             #pod =cut
16              
17 4     4   10663 use v5.36.0;
  4         16  
18              
19             #pod =attr elements
20             #pod
21             #pod This must be an arrayref of L<rich text
22             #pod section|Slack::BlockKit::Block::RichText::Section> objects. Each section will
23             #pod be one item in the list.
24             #pod
25             #pod =cut
26              
27             has elements => (
28             isa => RichTextArray(),
29             traits => [ 'Array' ],
30             handles => { elements => 'elements' },
31             );
32              
33             #pod =attr indent
34             #pod
35             #pod This optional attribute is a count of pixels to indent the list. The author
36             #pod has never managed to use this successfully.
37             #pod
38             #pod =attr offset
39             #pod
40             #pod This optional attribute is a count of pixels to offset the list. The author
41             #pod has never managed to use this successfully.
42             #pod
43             #pod =attr border
44             #pod
45             #pod This optional attribute is a count of pixels for the list's border width. The
46             #pod author has never managed to use this successfully.
47             #pod
48             #pod =cut
49              
50             # I don't know how to use these successfully. -- rjbs, 2024-06-29
51             my @PX_PROPERTIES = qw(indent offset border);
52             for my $name (@PX_PROPERTIES) {
53             has $name => (
54             is => 'ro',
55             isa => Pixels(),
56             predicate => "has_$name",
57             );
58             }
59              
60             #pod =attr style
61             #pod
62             #pod This required attribute is I<not> the text style, but the list style. It may
63             #pod be either C<bullet> or C<ordered>.
64             #pod
65             #pod =cut
66              
67             has style => (
68             is => 'ro',
69             isa => enum([ qw(bullet ordered) ]),
70             required => 1,
71             );
72              
73 0     0 0   sub as_struct ($self) {
  0            
  0            
74             return {
75             type => 'rich_text_list',
76 0           elements => [ map {; $_->as_struct } $self->elements ],
77             style => $self->style,
78              
79 0 0         (map {; my $p = "has_$_"; ($self->$p ? ($_ => $self->$_) : ()) }
  0            
  0            
80             @PX_PROPERTIES)
81             };
82             }
83              
84 4     4   35 no Moose::Util::TypeConstraints;
  4         11  
  4         41  
85 4     4   987 no Moose;
  4         11  
  4         37  
86             __PACKAGE__->meta->make_immutable;
87              
88             __END__
89              
90             =pod
91              
92             =encoding UTF-8
93              
94             =head1 NAME
95              
96             Slack::BlockKit::Block::RichText::List - a Block Kit rich text list element
97              
98             =head1 VERSION
99              
100             version 0.005
101              
102             =head1 OVERVIEW
103              
104             This represents a rich text list, which will be rendered as either a bullet or
105             numbered list.
106              
107             =head1 PERL VERSION
108              
109             This module should work on any version of perl still receiving updates from
110             the Perl 5 Porters. This means it should work on any version of perl
111             released in the last two to three years. (That is, if the most recently
112             released version is v5.40, then this module should work on both v5.40 and
113             v5.38.)
114              
115             Although it may work on older versions of perl, no guarantee is made that the
116             minimum required version will not be increased. The version may be increased
117             for any reason, and there is no promise that patches will be accepted to
118             lower the minimum required perl.
119              
120             =head1 ATTRIBUTES
121              
122             =head2 elements
123              
124             This must be an arrayref of L<rich text
125             section|Slack::BlockKit::Block::RichText::Section> objects. Each section will
126             be one item in the list.
127              
128             =head2 indent
129              
130             This optional attribute is a count of pixels to indent the list. The author
131             has never managed to use this successfully.
132              
133             =head2 offset
134              
135             This optional attribute is a count of pixels to offset the list. The author
136             has never managed to use this successfully.
137              
138             =head2 border
139              
140             This optional attribute is a count of pixels for the list's border width. The
141             author has never managed to use this successfully.
142              
143             =head2 style
144              
145             This required attribute is I<not> the text style, but the list style. It may
146             be either C<bullet> or C<ordered>.
147              
148             =head1 AUTHOR
149              
150             Ricardo SIGNES <cpan@semiotic.systems>
151              
152             =head1 COPYRIGHT AND LICENSE
153              
154             This software is copyright (c) 2024 by Ricardo SIGNES.
155              
156             This is free software; you can redistribute it and/or modify it under
157             the same terms as the Perl 5 programming language system itself.
158              
159             =cut