SpreadRevolutionaryDate.pm

filter: Statementstmt 88.4% 61 / 69 Branchbran 18.7% 3 / 16 Conditioncond 33.3% 2 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 100% 14 / 14 Podpod 100% 2 / 2 totaltotal 74.5% 82 / 110 CC 13 SCAR 26.7
CC
13
Cov
73%
__ANON__
35.2
BUILD
3.0
spread
2.0
CRAP 14.5
« SpreadRevolutionaryDate/MsgMaker/RevolutionaryDate.pm ↑ Summary SpreadRevolutionaryDate/MsgMaker/PromptUser.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 13 ▶use 5.014;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 13 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 package App::SpreadRevolutionaryDate;
13 13 $App::SpreadRevolutionaryDate::VERSION = '0.54';
14 # ABSTRACT: Spread date and time from Revolutionary (Republican) Calendar on Bluesky, Twitter, Mastodon, Freenode and Liberachat.
15  
16 13 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 13 ▶use App::SpreadRevolutionaryDate::Config;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 13 ▶use Class::Load ':all';
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 13 ▶use Locale::TextDomain 'App-SpreadRevolutionaryDate';
Subroutine BEGIN: called CC=1 SCAR=0.0
21 13 ▶use Locale::Messages qw(bind_textdomain_filter);
Subroutine BEGIN: called CC=1 SCAR=0.0
22 13 ▶use Encode;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 13 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
24 13 $ENV{OUTPUT_CHARSET} = 'UTF-8';
25 13 bind_textdomain_filter 'App-SpreadRevolutionaryDate' => \&Encode::decode_utf8, Encode::FB_DEFAULT;
26 }
27 13 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
28  
29 13 has 'config' => (
30 is => 'ro',
31 isa => 'App::SpreadRevolutionaryDate::Config',
32 required => 1,
33 );
34  
35 13 has 'targets' => (
36 is => 'rw',
37 isa => 'HashRef[Object]',
38 required => 1,
39 );
40  
41 13 has 'msgmaker' => (
42 is => 'rw',
43 isa => 'Object',
44 required => 1,
45 );
46  
47  
48 28 ▶around BUILDARGS => sub {
Subroutine __ANON__: called CC=10 SCAR=35.6
49 28 my ($orig, $class, $filename) = @_;
50  
51 28 my $config = App::SpreadRevolutionaryDate::Config->new($filename);
52  
53 26 my $msgmaker_class = 'App::SpreadRevolutionaryDate::MsgMaker::' . $config->msgmaker;
54 26 ▶ try_load_class($msgmaker_class)
Branch: 1 branch
BranchTrueFalseTotal
try_load_class($msgmaker_class) or die "Cannot import msgmaker class $msgmaker_class\n" 26 0 26
55 or die "Cannot import msgmaker class $msgmaker_class\n";
56 26 load_class($msgmaker_class);
57 26 my %msgmaker_args = $config->get_msgmaker_arguments($config->msgmaker);
58 26 my %special_birthday_args = ();
59 26 ▶ if ($config->special_birthday_name && $config->special_birthday_day && $config->special_birthday_month) {
Branch: 1 branch
BranchTrueFalseTotal
if ($config->special_birthday_name and $config->special_birthday_day and $config->special_birthday_month) 0 26 26
Condition33%2/6
$config->special_birthday_name and $config->special_birthday_day and $config->special_birthday_month
!ll&&!rl&&r
2600
$config->special_birthday_name and $config->special_birthday_day
!ll&&!rl&&r
2600
MC/DC0%0/3
$config->special_birthday_name and $config->special_birthday_day and $config->special_birthday_month
$config->special_birthday_name $config->special_birthday_day $config->special_birthday_month
Truth table25%1/4
A and B and C
A= $config->special_birthday_nameB= $config->special_birthday_dayC= $config->special_birthday_month
ABCresult
0XX0
10X0
1100
1111
60 0 $special_birthday_args{special_birthday_name} = $config->special_birthday_name;
61 0 $special_birthday_args{special_birthday_day} = $config->special_birthday_day;
62 0 $special_birthday_args{special_birthday_month} = $config->special_birthday_month;
63 0 ▶ $special_birthday_args{special_birthday_url} = $config->special_birthday_url if $config->special_birthday_url;
Branch: 1 branch
BranchTrueFalseTotal
if $config->special_birthday_url 0 0 0
64 0 ▶ $special_birthday_args{special_birthday_gemini} = $config->special_birthday_gemini if $config->special_birthday_gemini;
Branch: 1 branch
BranchTrueFalseTotal
if $config->special_birthday_gemini 0 0 0
65 0 ▶ $special_birthday_args{special_birthday_prefix} = $config->special_birthday_prefix if $config->special_birthday_prefix;
Branch: 1 branch
BranchTrueFalseTotal
if $config->special_birthday_prefix 0 0 0
66 0 ▶ $special_birthday_args{special_birthday_plural} = $config->special_birthday_plural if $config->special_birthday_plural;
Branch: 1 branch
BranchTrueFalseTotal
if $config->special_birthday_plural 0 0 0
67 0 ▶ $special_birthday_args{special_birthday_gender} = $config->special_birthday_gender if $config->special_birthday_gender;
Branch: 1 branch
BranchTrueFalseTotal
if $config->special_birthday_gender 0 0 0
68 }
69 26 my $msgmaker = $msgmaker_class->new(locale => $config->locale, %msgmaker_args, %special_birthday_args);
70  
71 24 return $class->$orig(config => $config, targets => {}, msgmaker => $msgmaker);
72 13 };
73  
74  
75 24 ▶sub BUILD {
Subroutine BUILD: called CC=3 SCAR=11.0
Pod documented
76 24 my $self = shift;
77  
78 24 foreach my $target (@{$self->config->targets}) {
79 40 my $target_class = 'App::SpreadRevolutionaryDate::Target::' . ucfirst(lc($target));
80 40 ▶ try_load_class($target_class)
Branch: 1 branch
BranchTrueFalseTotal
try_load_class($target_class) or die "Cannot import target class $target_class for target $target\n" 40 0 40
81 or die "Cannot import target class $target_class for target $target\n";
82 40 load_class($target_class);
83 40 my %target_args = $self->config->get_target_arguments($target);
84 40 $self->targets->{$target} = $target_class->new(%target_args);
85 }
86 }
87  
88  
89 18 ▶sub spread {
Subroutine spread: called CC=2 SCAR=6.9
Pod documented
90 18 my $self = shift;
91  
92 18 my ($msg, $img) = $self->msgmaker->compute();
93 18 foreach my $target (@{$self->config->targets}) {
94 18 $self->targets->{$target}->spread($msg, $self->config->test, $img);
95 }
96 }
97  
98  
99 13 ▶no Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
100 13 __PACKAGE__->meta->make_immutable;
101  
102 # A module must return a true value. Traditionally, a module returns 1.
103 # But this module is a revolutionary one, so it discards all old traditions.
104 # Idea borrowed from Jean Forget's DateTime::Calendar::FrenchRevolutionary.
105 13 "Quand le gouvernement viole les droits du peuple,
106 l'insurrection est pour le peuple le plus sacré
107 et le plus indispensable des devoirs";
108  
109 __END__
« SpreadRevolutionaryDate/MsgMaker/RevolutionaryDate.pm ↑ Summary SpreadRevolutionaryDate/MsgMaker/PromptUser.pm »