| 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
MC/DC0%0/2
ref $class || $class
ref $class
$class
Truth table33%1/3
A || B
A= ref $classB= $class
| |||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||
| 20 | 25 | ▶ | $newsrc->load($file) or $options{create} or die "Can't load $file: $!\n" if $file; | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%7/7
$file && ($newsrc->load($file) || $options{'create'} || die("Can't load ${file}: $!\n"))
$newsrc->load($file) or $options{"create"} or die "Can't load ${file}: $!\n"
$newsrc->load($file) or $options{"create"}
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"}
| |||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||
| 31 | 15 | $newsrc->{file } = $file; | |||||||||||||||||||||||||||||||||||||||||||
| 32 | 15 | $newsrc->{group} = { }; | |||||||||||||||||||||||||||||||||||||||||||
| 33 | 15 | $newsrc->{list } = [ ]; | |||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||
| 35 | 15 | ▶ | open(NEWSRC, $file) or return ''; | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||
| 79 | 44 | $line =~ s/\s//g; | |||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||||
| 81 | 44 | ▶ | $line =~ /^ ([^!:]+) ([!:]) (.*) $/x or | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||
| 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
Condition60%3/5
-e $file && (rename($file, "$file.bak") || die("News::Newsrc::save_as: Can't rename $file, $file.bak: $!\n"))
rename $file, "$file.bak" or die "News::Newsrc::save_as: Can't rename $file, $file.bak: $!\n"
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"
| |||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||
| 133 | 1 | my $articles = $group->{articles}->run_list; | |||||||||||||||||||||||||||||||||||||||||||
| 134 | 1 | ▶ | my $space = $articles ? ' ' : ''; | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 135 | 1 | ▶ | print NEWSRC "$name$sub$space$articles\n" or | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||
| 148 | 6 | my $articles = $group->{articles}->run_list; | |||||||||||||||||||||||||||||||||||||||||||
| 149 | 6 | ▶ | my $space = $articles ? ' ' : ''; | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 150 | 2 | "$name$sub$space$articles\n" } @{$newsrc->{list}}; | |||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||||
| 152 | 2 | ▶ | wantarray ? @lines : \@lines | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||
| 165 | 267 | my $articles = $group->{articles}->run_list; | |||||||||||||||||||||||||||||||||||||||||||
| 166 | 267 | ▶ | $articles = ' ' . $articles if $articles =~ /^\d/; | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||
| 179 | { | ||||||||||||||||||||||||||||||||||||||||||||
| 180 | 2 | ▶ | $options{replace} or return 0; | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||
| 212 | 6 | ▶ | $offset < -@$array and $offset = -@$array; | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||
| 225 | 71 | ▶ | ref $where and ($where, $arg) = @$where; | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||||
| 227 | 71 | for ($where) | |||||||||||||||||||||||||||||||||||||||||||
| 228 | { | ||||||||||||||||||||||||||||||||||||||||||||
| 229 | 71 | ▶ | /first/ and unshift @$list, $group; | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 230 | 71 | ▶ | /last/ and push @$list, $group; | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 231 | 71 | ▶ | /^$/ and push @$list, $group; # default | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 232 | 71 | ▶ | /alpha/ and Alpha ($list, $group); | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 233 | 71 | ▶ | /before/ and Before ($list, $group, $arg); | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 234 | 71 | ▶ | /after/ and After ($list, $group, $arg); | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 235 | 71 | ▶ | /number/ and Splice @$list, $arg, 0, $group; | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||
| 443 | 5 | my @marked = elements { $newsrc->{group}{$name}{articles} }; | |||||||||||||||||||||||||||||||||||||||||||
| 444 | 5 | ▶ | wantarray ? @marked : \@marked | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||
| 471 | 6 | my $set = new Set::IntSpan $articles; | |||||||||||||||||||||||||||||||||||||||||||
| 472 | 6 | ▶ | finite $set or return 0; | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 473 | 6 | my $min = $set->min; | |||||||||||||||||||||||||||||||||||||||||||
| 474 | 6 | ▶ | defined $min and $min < 0 and return 0; | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $min and $min < 0
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
| |||||||||||||||||||||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||||||||||||||||||
| 476 | 6 | ▶ | $newsrc->{group}{$name} or $newsrc->add_group($name, %options); | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 477 | 6 | $newsrc->{group}{$name}{articles} = $set; | |||||||||||||||||||||||||||||||||||||||||||
| 478 | 6 | 1 | |||||||||||||||||||||||||||||||||||||||||||
| 479 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 480 | |||||||||||||||||||||||||||||||||||||||||||||
| 481 | 3 | 1 | |||||||||||||||||||||||||||||||||||||||||||
| 482 | |||||||||||||||||||||||||||||||||||||||||||||
| 483 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||