blib/lib/News/Newsrc.pm

filter: Statementstmt 100% 239 / 239 Branchbran 92.7% 115 / 124 Conditioncond 72.2% 13 / 18 MC/DCmcdc 0.0% 0 / 9 Subroutinesub 100% 40 / 40 Podpod 85.2% 29 / 34 totaltotal 93.9% 436 / 464 CC 75 SCAR 13.8
CC
75
Cov
96%
_insert
11.0
set_articles
6.1
format
5.2
CRAP 4.0
↑ Summary
1 package News::Newsrc;
2  
3 3 ▶use 5;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 ▶use Set::IntSpan;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 3 $News::Newsrc::VERSION = '1.11';
8 3 $Set::IntSpan::Empty_String = '';
9  
10  
11 sub new
12 25 ▶{
Subroutine new: called CC=5 SCAR=16.2
Pod documented
13 25 my ($class, $file, %options) = @_;
14  
15 25 my $newsrc = { group => {},
16 list => [] };
17  
18 25 ▶ bless $newsrc, ref $class || $class;
Condition33%1/3
ref $class || $class
l!l&&r!l&&!r
0250
MC/DC0%0/2
ref $class || $class
ref $class $class
Truth table33%1/3
A || B
A= ref $classB= $class
ABresult
1X1
011
000
19  
20 25 ▶ $newsrc->load($file) or $options{create} or die "Can't load $file: $!\n" if $file;
Branch: 1 branch
BranchTrueFalseTotal
if $file 4 21 25
Condition100%7/7
$file && ($newsrc->load($file) || $options{'create'} || die("Can't load ${file}: $!\n"))
!ll
214
$newsrc->load($file) or $options{"create"} or die "Can't load ${file}: $!\n"
l!l
31
$newsrc->load($file) or $options{"create"}
l!l&&r!l&&!r
211
MC/DC0%0/3
$file && ($newsrc->load($file) || $options{'create'} || die("Can't load ${file}: $!\n"))
$file $newsrc->load($file) $options{"create"}
Truth table0%0/4
A && B or C
A= $fileB= $newsrc->load($file)C= $options{"create"}
ABCresult
0XX0
1000
11X1
1011
21  
22 24 return $newsrc;
23 }
24  
25  
26 sub load
27 15 ▶{
Subroutine load: called CC=4 SCAR=13.9
Pod documented
28 15 my($newsrc, $file) = @_;
29  
30 15 ▶ $file or $file = "$ENV{HOME}/.newsrc";
Branch: 1 branch
BranchTrueFalseTotal
$file or $file = qq[$ENV{"HOME"}/.newsrc] 12 3 15
31 15 $newsrc->{file } = $file;
32 15 $newsrc->{group} = { };
33 15 $newsrc->{list } = [ ];
34  
35 15 ▶ open(NEWSRC, $file) or return '';
Branch: 1 branch
BranchTrueFalseTotal
open NEWSRC, $file or return "" 12 3 15
36 12 my $lines = [ <NEWSRC> ]; # whole file
37 12 close(NEWSRC);
38  
39 12 eval { $newsrc->import_rc($lines) };
40 12 ▶ $@ and die "News::Newsrc::load: file $file: $@";
Branch: 1 branch
BranchTrueFalseTotal
$@ and die "News::Newsrc::load: file ${file}: $@" 2 10 12
41  
42 10 1
43 }
44  
45  
46 sub _scan # Initializes a Newsrc object from a string. Used for testing.
47 2 ▶{
Subroutine _scan: called CC=1 SCAR=0.0
48 2 my($newsrc, $lines) = @_;
49  
50 2 my @lines = split /\n/, $lines;
51 2 $newsrc->import_rc(@lines);
52 }
53  
54  
55 sub import_rc
56 16 ▶{
Subroutine import_rc: called CC=4 SCAR=13.9
Pod documented
57 16 my $newsrc = shift;
58 16 ▶ my $lines = ref $_[0] ? $_[0] : [ @_ ];
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] ? : 13 3 16
59  
60 16 $newsrc->{group} = { };
61 16 $newsrc->{list } = [ ];
62  
63 16 my $line_number = 1;
64 16 for my $line (@$lines)
65 {
66 46 eval { $newsrc->parse($line) };
67 46 ▶ $@ and die "News::Newsrc::import_rc: line $line_number: $@";
Branch: 1 branch
BranchTrueFalseTotal
$@ and die "News::Newsrc::import_rc: line ${line_number}: $@" 2 44 46
68  
69 44 $line_number++;
70 }
71 }
72  
73  
74 sub parse # parses a single line from a newsrc file
75 46 ▶{
Subroutine parse: called CC=4 SCAR=13.9
Pod undocumented
76 46 my($newsrc, $line) = @_;
77  
78 46 ▶ $line =~ /\S/ or return;
Branch: 1 branch
BranchTrueFalseTotal
$line =~ /\S/ or return 44 2 46
79 44 $line =~ s/\s//g;
80  
81 44 ▶ $line =~ /^ ([^!:]+) ([!:]) (.*) $/x or
Branch: 1 branch
BranchTrueFalseTotal
$line =~ /^ ([^!:]+) ([!:]) (.*) $/x or die "News::Newsrc::parse: Bad newsrc line: $line" 43 1 44
82 die "News::Newsrc::parse: Bad newsrc line: $line";
83  
84 43 my($name, $mark, $articles) = ($1, $2, $3);
85  
86 43 ▶ valid Set::IntSpan $articles or
Branch: 1 branch
BranchTrueFalseTotal
"Set::IntSpan"->valid($articles) or die "News::Newsrc::parse: Bad article list: $line" 42 1 43
87 die "News::Newsrc::parse: Bad article list: $line";
88  
89 42 my $group = { name => $name,
90 subscribed => $mark eq ':',
91 articles => Set::IntSpan->new($articles) };
92  
93 42 $newsrc->{group}{$name} = $group;
94 42 push(@{$newsrc->{list}}, $group);
95 }
96  
97  
98 sub save
99 6 ▶{
Subroutine save: called CC=2 SCAR=6.9
Pod documented
100 6 my $newsrc = shift;
101  
102 6 ▶ $newsrc->{file} or $newsrc->{file} = "$ENV{HOME}/.newsrc";
Branch: 1 branch
BranchTrueFalseTotal
$newsrc->{"file"} or $newsrc->{"file"} = qq[$ENV{"HOME"}/.newsrc] 4 2 6
103 6 $newsrc->save_as($newsrc->{file});
104 }
105  
106  
107 sub save_as
108 7 ▶{
Subroutine save_as: called CC=5 SCAR=16.6
Pod documented
109 7 my($newsrc, $file) = @_;
110  
111 7 ▶ -e $file and
Branch: 1 branch
BranchTrueFalseTotal
-e $file and rename($file, "$file.bak") || die("News::Newsrc::save_as: Can't rename $file, $file.bak: $!\n") 1 6 7
Condition60%3/5
-e $file && (rename($file, "$file.bak") || die("News::Newsrc::save_as: Can't rename $file, $file.bak: $!\n"))
!ll
610
rename $file, "$file.bak" or die "News::Newsrc::save_as: Can't rename $file, $file.bak: $!\n"
l!l
10
MC/DC0%0/2
-e $file && (rename($file, "$file.bak") || die("News::Newsrc::save_as: Can't rename $file, $file.bak: $!\n"))
-e $file rename $file, "$file.bak"
Truth table33%1/3
A && B
A= -e $fileB= rename $file, "$file.bak"
ABresult
0X0
100
111
112 (rename($file, "$file.bak") or
113 die "News::Newsrc::save_as: Can't rename $file, $file.bak: $!\n");
114  
115 7 ▶ open(NEWSRC, "> $file") or
Branch: 1 branch
BranchTrueFalseTotal
open NEWSRC, "> $file" or die "News::Newsrc::save_as: Can't open ${file}: $!\n" 7 0 7
116 die "News::Newsrc::save_as: Can't open $file: $!\n";
117  
118 7 $newsrc->{file} = $file;
119 7 eval { $newsrc->format($file) };
120 7 close NEWSRC;
121 7 ▶ die $@ if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 7 7
122 }
123  
124  
125 sub format
126 7 ▶{
Subroutine format: called CC=5 SCAR=16.6
Pod documented
127 7 my($newsrc, $file) = @_;
128  
129 7 for my $group (@{$newsrc->{list}})
130 {
131 1 my $name = $group->{name};
132 1 ▶ my $sub = $group->{subscribed} ? ':' : '!';
Branch: 1 branch
BranchTrueFalseTotal
$group->{'subscribed'} ? : 1 0 1
133 1 my $articles = $group->{articles}->run_list;
134 1 ▶ my $space = $articles ? ' ' : '';
Branch: 1 branch
BranchTrueFalseTotal
$articles ? : 1 0 1
135 1 ▶ print NEWSRC "$name$sub$space$articles\n" or
Branch: 1 branch
BranchTrueFalseTotal
print NEWSRC "$name$sub$space$articles\n" or die "News::Newsrc::format: Can't write ${file}: $!\n" 1 0 1
136 die "News::Newsrc::format: Can't write $file: $!\n";
137 }
138 }
139  
140  
141 sub export_rc
142 2 ▶{
Subroutine export_rc: called CC=4 SCAR=13.9
Pod documented
143 2 my $newsrc = shift;
144  
145 6 my @lines = map { my $group = $_;
146 6 my $name = $group->{name};
147 6 ▶ my $sub = $group->{subscribed} ? ':' : '!';
Branch: 1 branch
BranchTrueFalseTotal
$group->{'subscribed'} ? : 4 2 6
148 6 my $articles = $group->{articles}->run_list;
149 6 ▶ my $space = $articles ? ' ' : '';
Branch: 1 branch
BranchTrueFalseTotal
$articles ? : 6 0 6
150 2 "$name$sub$space$articles\n" } @{$newsrc->{list}};
151  
152 2 ▶ wantarray ? @lines : \@lines
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 1 1 2
153 }
154  
155  
156 sub _dump # Formats a Newsrc object to a string. Used for testing
157 55 ▶{
Subroutine _dump: called CC=4 SCAR=13.9
158 55 my $newsrc = shift;
159  
160 55 my $dump = '';
161 55 for my $group (@{$newsrc->{list}})
162 {
163 267 my $name = $group->{name};
164 267 ▶ my $sub = $group->{subscribed} ? ':' : '!';
Branch: 1 branch
BranchTrueFalseTotal
$group->{'subscribed'} ? : 262 5 267
165 267 my $articles = $group->{articles}->run_list;
166 267 ▶ $articles = ' ' . $articles if $articles =~ /^\d/;
Branch: 1 branch
BranchTrueFalseTotal
if $articles =~ /^\d/ 62 205 267
167 267 $dump .= "$name$sub$articles\n";
168 }
169  
170 $dump
171 55 }
172  
173  
174 sub add_group
175 59 ▶{
Subroutine add_group: called CC=3 SCAR=11.0
Pod documented
176 59 my($newsrc, $name, %options) = @_;
177  
178 59 ▶ if ($newsrc->{group}{$name})
Branch: 1 branch
BranchTrueFalseTotal
if ($newsrc->{"group"}{$name}) 2 57 59
179 {
180 2 ▶ $options{replace} or return 0;
Branch: 1 branch
BranchTrueFalseTotal
$options{"replace"} or return 0 1 1 2
181 1 $newsrc->del_group($name);
182 }
183  
184 58 my $group = { name => $name,
185 subscribed => 1,
186 articles => Set::IntSpan->new };
187  
188 58 $newsrc->{group}{$name} = $group;
189 58 $newsrc->_insert($group, %options);
190  
191 58 1
192 }
193  
194  
195 sub move_group
196 13 ▶{
Subroutine move_group: called CC=2 SCAR=7.0
Pod documented
197 13 my($newsrc, $name, %options) = @_;
198 13 my $group = $newsrc->{group}{$name};
199 13 ▶ $group or return 0;
Branch: 1 branch
BranchTrueFalseTotal
$group or return 0 13 0 13
200  
201 13 $newsrc->{list} = [ grep { $_->{name} ne $name } @{$newsrc->{list}} ];
202 13 $newsrc->_insert($group, %options);
203 13 1
204 }
205  
206  
207 sub Splice(\@$$@)
208 6 ▶{
Subroutine Splice: called CC=3 SCAR=11.0
Pod undocumented
209 6 my($array, $offset, $length, @list) = @_;
210  
211 6 ▶ $offset > @$array and $offset = @$array;
Branch: 1 branch
BranchTrueFalseTotal
$offset > @$array and $offset = @$array 1 5 6
212 6 ▶ $offset < -@$array and $offset = -@$array;
Branch: 1 branch
BranchTrueFalseTotal
$offset < -@$array and $offset = -@$array 1 5 6
213 6 splice @$array, $offset, $length, @list;
214 }
215  
216  
217 sub _insert
218 71 ▶{
Subroutine _insert: called CC=11 SCAR=24.0
219 71 my($newsrc, $group, %options) = @_;
220  
221 71 my $list = $newsrc->{list};
222  
223 71 my($where, $arg) = ('', '');
224 71 ▶ $options{where} and $where = $options{where};
Branch: 1 branch
BranchTrueFalseTotal
$options{"where"} and $where = $options{"where"} 35 36 71
225 71 ▶ ref $where and ($where, $arg) = @$where;
Branch: 1 branch
BranchTrueFalseTotal
ref $where and () = @$where 14 57 71
226  
227 71 for ($where)
228 {
229 71 ▶ /first/ and unshift @$list, $group;
Branch: 1 branch
BranchTrueFalseTotal
/first/ and unshift @$list, $group 15 56 71
230 71 ▶ /last/ and push @$list, $group;
Branch: 1 branch
BranchTrueFalseTotal
/last/ and push @$list, $group 2 69 71
231 71 ▶ /^$/ and push @$list, $group; # default
Branch: 1 branch
BranchTrueFalseTotal
/^$/ and push @$list, $group 36 35 71
232 71 ▶ /alpha/ and Alpha ($list, $group);
Branch: 1 branch
BranchTrueFalseTotal
/alpha/ and Alpha($list, $group) 4 67 71
233 71 ▶ /before/ and Before ($list, $group, $arg);
Branch: 1 branch
BranchTrueFalseTotal
/before/ and Before($list, $group, $arg) 4 67 71
234 71 ▶ /after/ and After ($list, $group, $arg);
Branch: 1 branch
BranchTrueFalseTotal
/after/ and After($list, $group, $arg) 4 67 71
235 71 ▶ /number/ and Splice @$list, $arg, 0, $group;
Branch: 1 branch
BranchTrueFalseTotal
/number/ and &Splice(\@$list, $arg, 0, $group) 6 65 71
236 }
237 }
238  
239  
240 sub Alpha
241 4 ▶{
Subroutine Alpha: called CC=3 SCAR=11.0
Pod undocumented
242 4 my($list, $group, $before) = @_;
243 4 my $name = $group->{name};
244  
245 4 for my $i (0..$#$list)
246 {
247 13 ▶ if ($name lt $list->[$i]{name})
Branch: 1 branch
BranchTrueFalseTotal
if ($name lt $list->[$i]{"name"}) 3 10 13
248 {
249 3 splice @$list, $i, 0, $group;
250 3 return;
251 }
252 }
253  
254 1 push @$list, $group;
255 }
256  
257  
258 sub Before
259 4 ▶{
Subroutine Before: called CC=3 SCAR=11.0
Pod undocumented
260 4 my($list, $group, $before) = @_;
261 4 my $name = $group->{name};
262  
263 4 for my $i (0..$#$list)
264 {
265 27 ▶ if ($list->[$i]{name} eq $before)
Branch: 1 branch
BranchTrueFalseTotal
if ($list->[$i]{"name"} eq $before) 2 25 27
266 {
267 2 splice @$list, $i, 0, $group;
268 2 return;
269 }
270 }
271  
272 2 push @$list, $group;
273 }
274  
275  
276 sub After
277 4 ▶{
Subroutine After: called CC=3 SCAR=11.0
Pod undocumented
278 4 my($list, $group, $after) = @_;
279 4 my $name = $group->{name};
280  
281 4 for my $i (0..$#$list)
282 {
283 27 ▶ if ($list->[$i]{name} eq $after)
Branch: 1 branch
BranchTrueFalseTotal
if ($list->[$i]{"name"} eq $after) 2 25 27
284 {
285 2 splice @$list, $i+1, 0, $group;
286 2 return;
287 }
288 }
289  
290 2 push @$list, $group;
291 }
292  
293  
294 sub del_group
295 3 ▶{
Subroutine del_group: called CC=2 SCAR=6.9
Pod documented
296 3 my($newsrc, $name) = @_;
297  
298 3 ▶ $newsrc->{group}{$name} or return 0;
Branch: 1 branch
BranchTrueFalseTotal
$newsrc->{"group"}{$name} or return 0 2 1 3
299  
300 2 delete $newsrc->{group}{$name};
301 2 $newsrc->{list} = [ grep { $_->{name} ne $name } @{$newsrc->{list}} ];
302  
303 2 1
304 }
305  
306  
307 sub subscribe
308 3 ▶{
Subroutine subscribe: called CC=2 SCAR=6.9
Pod documented
309 3 my($newsrc, $name, %options) = @_;
310 3 ▶ $newsrc->{group}{$name} or $newsrc->add_group($name, %options);
Branch: 1 branch
BranchTrueFalseTotal
$newsrc->{"group"}{$name} or $newsrc->add_group($name, %options) 1 2 3
311 3 $newsrc->{group}{$name}{subscribed} = 1;
312 }
313  
314  
315 sub unsubscribe
316 3 ▶{
Subroutine unsubscribe: called CC=2 SCAR=6.9
Pod documented
317 3 my($newsrc, $name, %options) = @_;
318 3 ▶ $newsrc->{group}{$name} or $newsrc->add_group($name, %options);
Branch: 1 branch
BranchTrueFalseTotal
$newsrc->{"group"}{$name} or $newsrc->add_group($name, %options) 1 2 3
319 3 $newsrc->{group}{$name}{subscribed} = 0;
320 }
321  
322  
323 sub mark
324 206 ▶{
Subroutine mark: called CC=2 SCAR=6.9
Pod documented
325 206 my($newsrc, $name, $article, %options) = @_;
326 206 ▶ $newsrc->{group}{$name} or $newsrc->add_group($name, %options);
Branch: 1 branch
BranchTrueFalseTotal
$newsrc->{"group"}{$name} or $newsrc->add_group($name, %options) 204 2 206
327 206 $newsrc->{group}{$name}{articles}->insert($article);
328 }
329  
330  
331 sub mark_list
332 4 ▶{
Subroutine mark_list: called CC=2 SCAR=6.9
Pod documented
333 4 my($newsrc, $name, $list, %options) = @_;
334 4 ▶ $newsrc->{group}{$name} or $newsrc->add_group($name, %options);
Branch: 1 branch
BranchTrueFalseTotal
$newsrc->{"group"}{$name} or $newsrc->add_group($name, %options) 2 2 4
335 4 my $group = $newsrc->{group}{$name};
336 4 my $articles = union { $group->{articles} } $list;
337 4 $group->{articles} = $articles;
338 }
339  
340  
341 sub mark_range
342 5 ▶{
Subroutine mark_range: called CC=2 SCAR=6.9
Pod documented
343 5 my($newsrc, $name, $from, $to, %options) = @_;
344 5 ▶ $newsrc->{group}{$name} or $newsrc->add_group($name, %options);
Branch: 1 branch
BranchTrueFalseTotal
$newsrc->{"group"}{$name} or $newsrc->add_group($name, %options) 1 4 5
345 5 my $group = $newsrc->{group}{$name};
346 5 my $range = new Set::IntSpan "$from-$to";
347 5 my $articles = union { $group->{articles} } $range;
348 5 $group->{articles} = $articles;
349 }
350  
351  
352 sub unmark
353 3 ▶{
Subroutine unmark: called CC=2 SCAR=6.9
Pod documented
354 3 my($newsrc, $name, $article, %options) = @_;
355 3 ▶ $newsrc->{group}{$name} or $newsrc->add_group($name, %options);
Branch: 1 branch
BranchTrueFalseTotal
$newsrc->{"group"}{$name} or $newsrc->add_group($name, %options) 1 2 3
356 3 $newsrc->{group}{$name}{articles}->remove($article);
357 }
358  
359  
360 sub unmark_list
361 3 ▶{
Subroutine unmark_list: called CC=2 SCAR=6.9
Pod documented
362 3 my($newsrc, $name, $list, %options) = @_;
363 3 ▶ $newsrc->{group}{$name} or $newsrc->add_group($name, %options);
Branch: 1 branch
BranchTrueFalseTotal
$newsrc->{"group"}{$name} or $newsrc->add_group($name, %options) 1 2 3
364 3 my $group = $newsrc->{group}{$name};
365 3 my $articles = diff { $group->{articles} } $list;
366 3 $group->{articles} = $articles;
367 }
368  
369  
370 sub unmark_range
371 3 ▶{
Subroutine unmark_range: called CC=2 SCAR=6.9
Pod documented
372 3 my($newsrc, $name, $from, $to, %options) = @_;
373 3 ▶ $newsrc->{group}{$name} or $newsrc->add_group($name, %options);
Branch: 1 branch
BranchTrueFalseTotal
$newsrc->{"group"}{$name} or $newsrc->add_group($name, %options) 1 2 3
374 3 my $group = $newsrc->{group}{$name};
375 3 my $range = new Set::IntSpan "$from-$to";
376 3 my $articles = diff { $group->{articles} } $range;
377 3 $group->{articles} = $articles;
378 }
379  
380  
381 sub exists
382 12 ▶{
Subroutine exists: called CC=2 SCAR=6.9
Pod documented
383 12 my($newsrc, $name) = @_;
384 12 ▶ $newsrc->{group}{$name} ? 1 : ''
Branch: 1 branch
BranchTrueFalseTotal
$newsrc->{'group'}{$name} ? : 8 4 12
385 }
386  
387  
388 sub subscribed
389 3 ▶{
Subroutine subscribed: called CC=2 SCAR=6.9
Pod documented
390 3 my($newsrc, $name) = @_;
391 $newsrc->exists($name) and $newsrc->{group}{$name}{subscribed}
392 3 ▶}
Branch: 1 branch
BranchTrueFalseTotal
$newsrc->exists($name) and $newsrc->{"group"}{$name}{"subscribed"} 2 1 3
393  
394  
395 sub marked
396 5 ▶{
Subroutine marked: called CC=2 SCAR=6.9
Pod documented
397 5 my($newsrc, $name, $article) = @_;
398  
399 $newsrc->exists($name) and
400 5 ▶ member { $newsrc->{group}{$name}{articles} } $article
Branch: 1 branch
BranchTrueFalseTotal
$newsrc->exists($name) and do { $newsrc->{"group"}{$name}{"articles"} }->member($article) 4 1 5
401 }
402  
403  
404 sub num_groups
405 1 ▶{
Subroutine num_groups: called CC=1 SCAR=0.0
Pod documented
406 1 my $newsrc = shift;
407 1 my $list = $newsrc->{list};
408 1 scalar @$list
409 }
410  
411  
412 sub groups
413 3 ▶{
Subroutine groups: called CC=2 SCAR=6.9
Pod documented
414 3 my $newsrc = shift;
415 3 my $list = $newsrc->{list};
416 3 my @list = map { $_->{name} } @$list;
417 3 ▶ wantarray ? @list : \@list;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 2 1 3
418 }
419  
420  
421 sub sub_groups
422 2 ▶{
Subroutine sub_groups: called CC=2 SCAR=6.9
Pod documented
423 2 my $newsrc = shift;
424 2 my $list = $newsrc->{list};
425 2 my @list = map { $_->{name} } grep { $_->{'subscribed'} } @$list;
426 2 ▶ wantarray ? @list : \@list;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 1 1 2
427 }
428  
429  
430 sub unsub_groups
431 2 ▶{
Subroutine unsub_groups: called CC=2 SCAR=6.9
Pod documented
432 2 my $newsrc = shift;
433 2 my $list = $newsrc->{list};
434 2 my @list = map { $_->{name} } grep { not $_->{'subscribed'} } @$list;
435 2 ▶ wantarray ? @list : \@list;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 1 1 2
436 }
437  
438  
439 sub marked_articles
440 5 ▶{
Subroutine marked_articles: called CC=3 SCAR=11.0
Pod documented
441 5 my($newsrc, $name, %options) = @_;
442 5 ▶ $newsrc->{group}{$name} or $newsrc->add_group($name, %options);
Branch: 1 branch
BranchTrueFalseTotal
$newsrc->{"group"}{$name} or $newsrc->add_group($name, %options) 2 3 5
443 5 my @marked = elements { $newsrc->{group}{$name}{articles} };
444 5 ▶ wantarray ? @marked : \@marked
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 2 3 5
445 }
446  
447  
448 sub unmarked_articles
449 5 ▶{
Subroutine unmarked_articles: called CC=3 SCAR=11.0
Pod documented
450 5 my($newsrc, $name, $from, $to, %options) = @_;
451 5 ▶ $newsrc->{group}{$name} or $newsrc->add_group($name, %options);
Branch: 1 branch
BranchTrueFalseTotal
$newsrc->{"group"}{$name} or $newsrc->add_group($name, %options) 2 3 5
452 5 my $range = new Set::IntSpan "$from-$to";
453 5 my $unmarked = diff $range $newsrc->{group}{$name}{articles};
454 5 my @unmarked = elements $unmarked;
455 5 ▶ wantarray ? @unmarked : \@unmarked
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 2 3 5
456 }
457  
458 sub get_articles
459 18 ▶{
Subroutine get_articles: called CC=2 SCAR=6.9
Pod documented
460 18 my($newsrc, $name, %options) = @_;
461 18 ▶ $newsrc->{group}{$name} or $newsrc->add_group($name, %options);
Branch: 1 branch
BranchTrueFalseTotal
$newsrc->{"group"}{$name} or $newsrc->add_group($name, %options) 16 2 18
462 18 $newsrc->{group}{$name}{articles}->run_list;
463 }
464  
465  
466 sub set_articles
467 11 ▶{
Subroutine set_articles: called CC=6 SCAR=18.1
Pod documented
468 11 my($newsrc, $name, $articles, %options) = @_;
469  
470 11 ▶ valid Set::IntSpan $articles or return 0;
Branch: 1 branch
BranchTrueFalseTotal
"Set::IntSpan"->valid($articles) or return 0 6 5 11
471 6 my $set = new Set::IntSpan $articles;
472 6 ▶ finite $set or return 0;
Branch: 1 branch
BranchTrueFalseTotal
$set->finite or return 0 6 0 6
473 6 my $min = $set->min;
474 6 ▶ defined $min and $min < 0 and return 0;
Branch: 1 branch
BranchTrueFalseTotal
defined $min and $min < 0 and return 0 0 6 6
Condition66%2/3
defined $min and $min < 0
!ll&&!rl&&r
240
MC/DC0%0/2
defined $min and $min < 0
defined $min $min < 0
Truth table66%2/3
A and B
A= defined $minB= $min < 0
ABresult
0X0
100
111
475  
476 6 ▶ $newsrc->{group}{$name} or $newsrc->add_group($name, %options);
Branch: 1 branch
BranchTrueFalseTotal
$newsrc->{"group"}{$name} or $newsrc->add_group($name, %options) 3 3 6
477 6 $newsrc->{group}{$name}{articles} = $set;
478 6 1
479 }
480  
481 3 1
482  
483 __END__
↑ Summary