blib/lib/Mail/LMLM.pm

filter: Statementstmt 48.1% 52 / 108 Branchbran 0.0% 0 / 20 Conditioncond 0.0% 0 / 5 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 84.2% 16 / 19 Podpod 100% 2 / 2 totaltotal 44.8% 70 / 156 SCAR 41.9
CC
15
Cov
39%
initialize
90.0
render
56.0
BEGIN
1.0
CRAP 65.8
« blib/lib/Mail/LMLM/Render/HTML.pm ↑ Summary blib/lib/Mail/LMLM/Types/GoogleGroups.pm »
1 package Mail::LMLM;
2 2 $Mail::LMLM::VERSION = '0.6806';
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 ▶use 5.008;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 2 ▶use Mail::LMLM::Object;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 2 ▶use vars qw(@ISA);
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 2 @ISA = qw(Mail::LMLM::Object);
13  
14 2 ▶use Mail::LMLM::Render::HTML;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 2 ▶use Mail::LMLM::Types::Ezmlm;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 2 ▶use Mail::LMLM::Types::Egroups;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 2 ▶use Mail::LMLM::Types::Listar;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 2 ▶use Mail::LMLM::Types::Majordomo;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 2 ▶use Mail::LMLM::Types::Listserv;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 2 ▶use Mail::LMLM::Types::Mailman;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 2 ▶use Mail::LMLM::Types::GoogleGroups;
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24 2 ▶use vars qw(%mailing_list_classes);
Subroutine BEGIN: called CC=1 SCAR=0.0
25  
26 2 my $prefix = "Mail::LMLM::Types::";
27  
28 sub _pref
29 {
30 14 ▶ my $name = shift;
Subroutine _pref: called CC=1 SCAR=0.0
31  
32 14 return $prefix . $name;
33 }
34  
35 %mailing_list_classes = (
36 (
37 2 map { $_ => _pref( ucfirst($_) ) } (
38 'egroups', 'ezmlm', 'listar', 'majordomo', 'listserv', 'mailman'
39 )
40 ),
41 "google" => _pref("GoogleGroups"),
42 );
43  
44 2 ▶use vars qw(@render_what);
Subroutine BEGIN: called CC=1 SCAR=0.0
45  
46 2 @render_what = (
47 {
48 'title' => "Description",
49 'func' => "render_description",
50 'id' => "desc",
51 },
52 {
53 'title' => "Posting Guidelines",
54 'func' => "render_guidelines",
55 'id' => "post_guidelines",
56 },
57 {
58 'title' => "Subscribing to the Mailing-List",
59 'func' => "render_subscribe",
60 'id' => "subscribe",
61 },
62 {
63 'title' => "Unsubscribing from the Mailing-List",
64 'func' => "render_unsubscribe",
65 'id' => "unsubscribe",
66 },
67 {
68 'title' => "Posting Messages to the Mailing-List",
69 'func' => "render_post",
70 'id' => "posting",
71 },
72 {
73 'title' => "Contacting the Mailing-List's Owner",
74 'func' => "render_owner",
75 'id' => "owner",
76 },
77 {
78 'title' => "The Mailing-List's Homepage",
79 'func' => "render_homepage",
80 'id' => "homepage",
81 },
82 {
83 'title' => "Online Messages Archive",
84 'func' => "render_online_archive",
85 'id' => "archive",
86 },
87 );
88  
89 sub _do_nothing
90 ▶{
Subroutine _do_nothing: not called CC=1 SCAR=0.0
91 }
92  
93 sub initialize
94 {
95 0 ▶ my $self = shift;
Subroutine initialize: not called CC=9 SCAR=45.0
Pod documented
96  
97 0 my ( $key, $value );
98 0 $self->{'title'} = "List of Mailing Lists";
99 0 $self->{'headline'} = "List of Mailing Lists";
100 0 $self->{'prolog'} = $self->{'epilog'} = \&_do_nothing;
101 0 $self->{'extra_classes'} = {};
102 0 ▶ while ( scalar(@_) )
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @_) 0 0 0
103 {
104 0 $key = shift;
105 0 $value = shift;
106 0 ▶ if ( $key =~ /^-?lists$/ )
Branch: 6 branches
BranchTrueFalseTotal
if ($key =~ /^-?lists$/) { } 0 0 0
elsif ($key =~ /^-?title$/) { } 0 0 0
elsif ($key =~ /^-?headline$/) { } 0 0 0
elsif ($key =~ /^-?extra-classes$/) { } 0 0 0
elsif ($key =~ /^-?prolog$/) { } 0 0 0
elsif ($key =~ /^-?epilog$/) { } 0 0 0
107 {
108 0 $self->{'lists'} = $value;
109 }
110 elsif ( $key =~ /^-?title$/ )
111 {
112 0 $self->{'title'} = $value;
113 }
114 elsif ( $key =~ /^-?headline$/ )
115 {
116 0 $self->{'headline'} = $value;
117 }
118 elsif ( $key =~ /^-?extra-classes$/ )
119 {
120 0 $self->{'extra_classes'} = $value;
121 }
122 elsif ( $key =~ /^-?prolog$/ )
123 {
124 0 $self->{'prolog'} = $value;
125 }
126 elsif ( $key =~ /^-?epilog$/ )
127 {
128 0 $self->{'epilog'} = $value;
129 }
130 }
131  
132 0 ▶ if ( !exists( $self->{'lists'} ) )
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $self->{"lists"}) 0 0 0
133 {
134 0 die "The lists were not defined for Mail::LMLM!";
135 }
136 0 return 0;
137 }
138  
139 sub render
140 {
141 0 ▶ my $self = shift;
Subroutine render: not called CC=7 SCAR=40.3
Pod documented
142  
143 0 my ( $mail_lister, $mailing_list, $o, $r, $main_o, $main_r, $filename );
144  
145 0 local (*INDEX);
146  
147 0 open INDEX, ">index.html";
148 0 $main_r = Mail::LMLM::Render::HTML->new( \*INDEX );
149  
150 0 $main_r->start_document( $self->{'title'}, $self->{'headline'}, );
151  
152 0 $self->{'prolog'}->( $self, $main_r );
153  
154 0 local (*O);
155  
156 0 foreach $mailing_list ( @{ $self->{'lists'} } )
157 {
158 0 $filename = $mailing_list->{'id'} . ".html";
159 0 open O, ">" . $filename;
160 0 $r = Mail::LMLM::Render::HTML->new( \*O );
161  
162 0 my $class_name = $mailing_list->{'class'};
163 my $class =
164 $mailing_list_classes{$class_name}
165 0 ▶ || $self->{'extra_classes'}->{$class_name}
Condition0%0/5
$Mail::LMLM::mailing_list_classes{$class_name} || $self->{'extra_classes'}{$class_name} || die(qq[Mail::LMLM: Unknown Class "$class_name"])
l!l
00
$Mail::LMLM::mailing_list_classes{$class_name} or $self->{"extra_classes"}{$class_name}
l!l&&r!l&&!r
000
MC/DC0%0/2
$Mail::LMLM::mailing_list_classes{$class_name} || $self->{'extra_classes'}{$class_name} || die(qq[Mail::LMLM: Unknown Class "$class_name"])
$Mail::LMLM::mailing_list_classes{$class_name} $self->{"extra_classes"}{$class_name}
Truth table0%0/3
A or B
A= $Mail::LMLM::mailing_list_classes{$class_name}B= $self->{"extra_classes"}{$class_name}
ABresult
1X1
011
000
166 || die "Mail::LMLM: Unknown Class \"$class_name\"";
167 0 ▶ if ( ref($class) eq "CODE" )
Branch: 1 branch
BranchTrueFalseTotal
if (ref $class eq 'CODE') { } 0 0 0
168 {
169 0 $mail_lister = $class->(%$mailing_list);
170 }
171 else
172 {
173 0 $mail_lister = $class->new(%$mailing_list);
174 }
175  
176 my $title =
177 exists( $mailing_list->{'title'} )
178 ? $mailing_list->{'title'}
179 0 ▶ : $mailing_list->{'id'};
Branch: 1 branch
BranchTrueFalseTotal
exists $mailing_list->{'title'} ? : 0 0 0
180  
181 0 $r->start_document( $title, $title );
182  
183 0 foreach my $what (@render_what)
184 {
185 0 my $func = $what->{'func'};
186 0 $r->start_section( $what->{'title'}, +{ 'id' => $what->{'id'} } );
187 0 $mail_lister->$func($r);
188 0 $r->end_section();
189 }
190  
191 0 $main_r->start_section( $title, { 'title_url' => $filename } );
192 0 $mail_lister->render_description($main_r);
193 0 $main_r->end_section();
194  
195 0 $r->end_document();
196  
197 0 close(O);
198 }
199  
200 0 $self->{'epilog'}->( $self, $main_r );
201  
202 0 $main_r->end_document();
203 0 close(INDEX);
204  
205 0 local (*STYLE);
206 0 open STYLE, ">style.css";
207 0 print STYLE <<"EOF";
208 a:hover { background-color : LightGreen }
209 div.indent { margin-left : 3em }
210 EOF
211  
212 0 close(STYLE);
213 }
214  
215 #### Documentation
216  
217 __END__
« blib/lib/Mail/LMLM/Render/HTML.pm ↑ Summary blib/lib/Mail/LMLM/Types/GoogleGroups.pm »