Entity/Status.pm

filter: Statementstmt 94.5% 52 / 55 Branchbran 0.0% 0 / 2 Conditioncond 66.6% 2 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 87.5% 7 / 8 Podpod n/a totaltotal 87.1% 61 / 70 CC 2 SCAR 5.5
CC
2
Cov
90%
__ANON__
4.3
BEGIN
1.0
BEGIN
1.0
CRAP 1.7
« Entity/Account.pm ↑ Summary Types.pm »
1 package Mastodon::Entity::Status;
2  
3 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 3 our $VERSION = '0.018'; # TRIAL
7  
8 3 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 3 with 'Mastodon::Role::Entity';
10  
11 3 ▶use Types::Standard qw( Maybe Int Str Bool ArrayRef Enum );
Subroutine BEGIN: called CC=1 SCAR=0.0
12 3 ▶use Mastodon::Types qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
13 URI Account Status DateTime Attachment Mention Tag Application
14 3 );
15  
16 3 ▶use Log::Any;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 3 my $log = Log::Any->get_logger( category => 'Mastodon' );
18  
19 3 has account => (
20 is => 'ro', isa => Account, coerce => 1, required => 1,
21 );
22  
23 3 has application => (
24 is => 'ro', isa => Maybe [Application], coerce => 1,
25 );
26  
27 3 has content => (
28 is => 'ro', isa => Str,
29 );
30  
31 3 has created_at => (
32 is => 'ro', isa => DateTime, coerce => 1,
33 );
34  
35 3 has emojis => (
36 is => 'ro', isa => ArrayRef,
37 );
38  
39 3 has favourited => (
40 is => 'ro', isa => Bool, coerce => 1,
41 );
42  
43 3 has favourites_count => (
44 is => 'ro', isa => Int, required => 1,
45 );
46  
47 3 has id => (
48 is => 'ro', isa => Int,
49 );
50  
51 3 has in_reply_to_account_id => (
52 is => 'ro', isa => Maybe [Int],
53 );
54  
55 3 has in_reply_to_id => (
56 is => 'ro', isa => Maybe [Int],
57 );
58  
59 3 has media_attachments => (
60 is => 'ro', isa => ArrayRef [Attachment], coerce => 1,
61 );
62  
63 3 has mentions => (
64 is => 'ro', isa => ArrayRef [Mention], coerce => 1,
65 );
66  
67 3 has reblog => (
68 is => 'ro', isa => Maybe [Status], coerce => 1,
69 );
70  
71 3 has reblogged => (
72 is => 'ro', isa => Bool, coerce => 1,
73 );
74  
75 3 has reblogs_count => (
76 is => 'ro', isa => Int,
77 );
78  
79 3 has sensitive => (
80 is => 'ro', isa => Bool, coerce => 1,
81 );
82  
83 3 has spoiler_text => (
84 is => 'ro', isa => Str,
85 );
86  
87 3 has tags => (
88 is => 'ro', isa => ArrayRef [Tag], coerce => 1,
89 );
90  
91 3 has uri => (
92 is => 'ro', isa => Str,
93 );
94  
95 3 has url => (
96 is => 'ro', isa => URI, coerce => 1,
97 );
98  
99 3 has visibility => (
100 is => 'ro', isa => Enum[qw(
101 public unlisted private direct
102 )],
103 required => 1,
104 );
105  
106 3 foreach my $pair (
107 [ fetch => 'get_status' ],
108 [ fetch_context => 'get_status_context' ],
109 [ fetch_card => 'get_status_card' ],
110 [ fetch_reblogs => 'get_status_reblogs' ],
111 [ fetch_favourites => 'get_status_favourites' ],
112 [ delete => 'delete_status' ],
113 [ boost => 'reblog' ],
114 [ unboost => 'unreblog' ],
115 [ favourite => undef ],
116 [ unfavourite => undef ],
117 ) {
118  
119 30 my ($name, $method) = @{$pair};
120 30 ▶ $method //= $name;
Condition66%2/3
$method //= $name
l!l&&r!l&&!r
2460
MC/DC0%0/2
$method //= $name
$method $name
Truth table66%2/3
A //= B
A= $methodB= $name
ABresult
1X1
011
000
121  
122 3 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
123 30 ▶ *{ __PACKAGE__ . '::' . $name } = sub {
Subroutine __ANON__: not called CC=2 SCAR=14.6
124 0 my $self = shift;
125 0 ▶ croak $log->fatal(qq{Cannot call '$name' without client})
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_client 0 0 0
126 unless $self->_client;
127 0 $self->_client->$method($self->id, @_);
128 30 };
129 }
130  
131 3 1;
132  
133 =encoding utf8
134  
135 =head1 NAME
136  
137 Mastodon::Entity::Status - A Mastodon status
138  
139 =head1 DESCRIPTION
140  
141 This object should not be manually created. It is intended to be generated
142 from the data received from a Mastodon server using the coercions in
143 L<Mastodon::Types>.
144  
145 For current information, see the
146 L<Mastodon API documentation|https://github.com/tootsuite/documentation/blob/master/Using-the-API/API.md#status>
147  
148 =head1 ATTRIBUTES
149  
150 =over 4
151  
152 =item B<id>
153  
154 The ID of the status.
155  
156 =item B<uri>
157  
158 A Fediverse-unique resource ID.
159  
160 =item B<url>
161  
162 URL to the status page (can be remote).
163  
164 =item B<account>
165  
166 The L<Mastodon::Entity::Account> which posted the status.
167  
168 =item B<in_reply_to_id>
169  
170 C<undef> or the ID of the status it replies to.
171  
172 =item B<in_reply_to_account_id>
173  
174 C<undef> or the ID of the account it replies to.
175  
176 =item B<reblog>
177  
178 C<undef> or the reblogged L<Mastodon::Entity::Status>.
179  
180 =item B<content>
181  
182 Body of the status; this will contain HTML (remote HTML already sanitized).
183  
184 =item B<created_at>
185  
186 The time the status was created as a L<DateTime> object.
187  
188 =item B<reblogs_count>
189  
190 The number of reblogs for the status.
191  
192 =item B<favourites_count>
193  
194 The number of favourites for the status.
195  
196 =item B<reblogged>
197  
198 Whether the authenticated user has reblogged the status.
199  
200 =item B<favourited>
201  
202 Whether the authenticated user has favourited the status.
203  
204 =item B<sensitive>
205  
206 Whether media attachments should be hidden by default.
207  
208 =item B<spoiler_text>
209  
210 If not empty, warning text that should be displayed before the actual content.
211  
212 =item B<visibility>
213  
214 One of: C<public>, C<unlisted>, C<private>, C<direct>.
215  
216 =item B<media_attachments>
217  
218 An array of L<Mastodon::Entity::Attachment> objects.
219  
220 =item B<mentions>
221  
222 An array of L<Mastodon::Entity::Mention> objects.
223  
224 =item B<tags>
225  
226 An array of L<Mastodon::Entity::Tag> objects.
227  
228 =item B<application>
229  
230 Application from which the status was posted, as a
231 L<Mastodon::Entity::Application> object.
232  
233 =back
234  
235 =head1 METHODS
236  
237 This class provides the following convenience methods. They act as a shortcut,
238 passing the appropriate identifier of the current object as the first argument
239 to the corresponding methods in L<Mastodon::Client>.
240  
241 =over 4
242  
243 =item B<fetch>
244  
245 A shortcut to C<get_status>.
246  
247 =item B<fetch_context>
248  
249 A shortcut to C<get_status_context>.
250  
251 =item B<fetch_card>
252  
253 A shortcut to C<get_status_card>.
254  
255 =item B<fetch_reblogs>
256  
257 A shortcut to C<get_status_reblogs>.
258  
259 =item B<fetch_favourites>
260  
261 A shortcut to C<get_status_favourites>.
262  
263 =item B<delete>
264  
265 A shortcut to C<delete_status>.
266  
267 =item B<boost>
268  
269 A shortcut to C<reblog>.
270  
271 =item B<unboost>
272  
273 A shortcut to C<unreblog>.
274  
275 =item B<favourite>
276  
277 A shortcut to C<favourite>.
278  
279 =item B<unfavourite>
280  
281 A shortcut to C<unfavourite>.
282  
283 =back
284  
285 =head1 AUTHOR
286  
287 =over 4
288  
289 =item *
290  
291 José Joaquín Atria <jjatria@cpan.org>
292  
293 =back
294  
295 =head1 COPYRIGHT AND LICENSE
296  
297 This software is copyright (c) 2017 by José Joaquín Atria.
298  
299 This is free software; you can redistribute it and/or modify it under
300 the same terms as the Perl 5 programming language system itself.
301  
302 =cut
« Entity/Account.pm ↑ Summary Types.pm »