SpreadRevolutionaryDate/Target.pm

filter: Statementstmt 97.3% 37 / 38 Branchbran 66.6% 4 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 8 / 8 Podpod n/a totaltotal 94.2% 49 / 52 CC 4 SCAR 7.5
CC
4
Cov
93%
_split_msg
4.1
BEGIN
1.0
BEGIN
1.0
CRAP 2.1
« SpreadRevolutionaryDate/Target/Twitter.pm ↑ Summary SpreadRevolutionaryDate/MsgMaker/RevolutionaryDate/Locale.pm »
1 #
2 # This file is part of App-SpreadRevolutionaryDate
3 #
4 # This software is Copyright (c) 2019-2026 by Gérald Sédrati.
5 #
6 # This is free software, licensed under:
7 #
8 # The GNU General Public License, Version 3, June 2007
9 #
10 17 ▶use 5.014;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 17 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 package App::SpreadRevolutionaryDate::Target;
13 17 $App::SpreadRevolutionaryDate::Target::VERSION = '0.54';
14 # ABSTRACT: Role providing interface for targets of L<App::SpreadRevolutionaryDate>.
15  
16 17 ▶use MooseX::Role::Parameterized;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 17 ▶use LWP::Protocol::https;
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 17 ▶use Locale::TextDomain 'App-SpreadRevolutionaryDate';
Subroutine BEGIN: called CC=1 SCAR=0.0
20 17 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 17 parameter worker => (
23 isa => 'Str',
24 default => 'Any',
25 );
26  
27 28 ▶role {
Subroutine __ANON__: called CC=1 SCAR=0.0
28 28 my $p = shift;
29  
30 28 has obj => (
31 is => 'ro',
32 isa => $p->worker,
33 required => 1,
34 );
35  
36 28 requires 'spread';
37 17 };
38  
39 3 ▶sub _split_msg {
Subroutine _split_msg: called CC=4 SCAR=14.0
40 3 my ($self, $text, $max_len) = @_;
41 3 my @msgs;
42 3 ▶ while ($text) {
Branch: 1 branch
BranchTrueFalseTotal
if ($text) 4 0 4
43 4 ▶ if (length $text <= $max_len) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $text <= $max_len) 3 1 4
44 3 push @msgs, $text;
45 3 last;
46 }
47 1 my $prefix = substr $text, 0, $max_len;
48 1 my $loc = rindex $prefix, ' ';
49  
50 1 ▶ if ($loc == -1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($loc == -1) 0 1 1
51 0 die "We found a word which is longer than $max_len\n";
52 }
53 1 my $str = substr $text, 0, $loc, '';
54 1 push @msgs, $str;
55 1 substr $text, 0, 1, '';
56 }
57 3 return @msgs;
58 }
59  
60  
61 # A module must return a true value. Traditionally, a module returns 1.
62 # But this module is a revolutionary one, so it discards all old traditions.
63 # Idea borrowed from Jean Forget's DateTime::Calendar::FrenchRevolutionary.
64 17 "Quand le gouvernement viole les droits du peuple,
65 l'insurrection est pour le peuple le plus sacré
66 et le plus indispensable des devoirs";
67  
68 __END__
« SpreadRevolutionaryDate/Target/Twitter.pm ↑ Summary SpreadRevolutionaryDate/MsgMaker/RevolutionaryDate/Locale.pm »