| 1 | package WWW::Noss::FeedConfig; | ||||||||||||||||||||||||||||
| 2 | 6 | ▶ | use 5.016; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 6 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 6 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 6 | our $VERSION = '2.05'; | |||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 6 | ▶ | use parent 'WWW::Noss::BaseConfig'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 6 | ▶ | use List::Util qw(any first min); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 17 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 17 | my ($class, %param) = @_; | |||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 17 | my $self = bless {}, $class; | |||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 17 | $self->initialize(%param); | |||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 17 | return $self; | |||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | } | ||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 17 | ▶ | sub initialize { | ||||||||||||||||||||||||||
|
Subroutine
initialize: called CC=26 SCAR=32.6
Pod
undocumented
| |||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | 17 | my ($self, %param) = @_; | |||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 17 | $self->SUPER::initialize; | |||||||||||||||||||||||||||
| 28 | 17 | $self->set_name($param{ name }); | |||||||||||||||||||||||||||
| 29 | 17 | $self->set_feed($param{ feed }); | |||||||||||||||||||||||||||
| 30 | 17 | $self->set_path($param{ path }); | |||||||||||||||||||||||||||
| 31 | 17 | $self->set_etag($param{ etag }); | |||||||||||||||||||||||||||
| 32 | 17 | $self->set_retry_cache($param{ retry_cache }); | |||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 17 | my $default = $param{ default }; | |||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | # Apply default parameters | ||||||||||||||||||||||||||||
| 37 | 17 | ▶ | if (defined $default) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 38 | 1 | $self->set_limit($default->limit); | |||||||||||||||||||||||||||
| 39 | 1 | $self->set_respect_skip($default->respect_skip); | |||||||||||||||||||||||||||
| 40 | 1 | $self->set_include_title($default->include_title); | |||||||||||||||||||||||||||
| 41 | 1 | $self->set_exclude_title($default->exclude_title); | |||||||||||||||||||||||||||
| 42 | 1 | $self->set_include_content($default->include_content); | |||||||||||||||||||||||||||
| 43 | 1 | $self->set_exclude_content($default->exclude_content); | |||||||||||||||||||||||||||
| 44 | 1 | $self->set_include_tags($default->include_tags); | |||||||||||||||||||||||||||
| 45 | 1 | $self->set_exclude_tags($default->exclude_tags); | |||||||||||||||||||||||||||
| 46 | 1 | $self->set_autoread($default->autoread); | |||||||||||||||||||||||||||
| 47 | 1 | $self->set_default_update($default->default_update); | |||||||||||||||||||||||||||
| 48 | 1 | $self->set_hidden($default->hidden); | |||||||||||||||||||||||||||
| 49 | 1 | $self->set_open_cmd($default->open_cmd); | |||||||||||||||||||||||||||
| 50 | 1 | $self->set_user_agent($default->user_agent); | |||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | 17 | ▶ | $self->set_groups($param{ groups } // []); | ||||||||||||||||||||||||||
|
Condition100%2/2
$param{"groups"} // []
MC/DC100%1/1
$param{"groups"} // []
$param{"groups"}
Truth table100%2/2
A
A= $param{"groups"}
| |||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | 17 | ▶ | if (@{ $self->groups }) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | # Set lowest limit defined by groups if present | ||||||||||||||||||||||||||||
| 58 | 1 | my $limit = min grep { defined } map { $_->limit } @{ $self->groups }; | |||||||||||||||||||||||||||
| 59 | 1 | ▶ | $self->set_limit($limit) if defined $limit; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | # If any group respects skip, we respect skip | ||||||||||||||||||||||||||||
| 62 | 1 | ▶ | my $rs = any { $_->respect_skip } @{ $self->groups }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 63 | 1 | $self->set_respect_skip($rs); | |||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | # Overlay group filters | ||||||||||||||||||||||||||||
| 66 | 1 | push @{ $self->include_title }, | |||||||||||||||||||||||||||
| 67 | 3 | ▶ | map { @{ $_->include_title // [] } } | ||||||||||||||||||||||||||
|
Condition50%1/2
$_->include_title // []
MC/DC0%0/1
$_->include_title // []
$_->include_title
Truth table50%1/2
A
A= $_->include_title
| |||||||||||||||||||||||||||||
| 68 | 1 | @{ $self->groups }; | |||||||||||||||||||||||||||
| 69 | 1 | push @{ $self->exclude_title }, | |||||||||||||||||||||||||||
| 70 | 3 | ▶ | map { @{ $_->exclude_title // [] } } | ||||||||||||||||||||||||||
|
Condition50%1/2
$_->exclude_title // []
MC/DC0%0/1
$_->exclude_title // []
$_->exclude_title
Truth table50%1/2
A
A= $_->exclude_title
| |||||||||||||||||||||||||||||
| 71 | 1 | @{ $self->groups }; | |||||||||||||||||||||||||||
| 72 | 1 | push @{ $self->include_content }, | |||||||||||||||||||||||||||
| 73 | 3 | ▶ | map { @{ $_->include_content // [] } } | ||||||||||||||||||||||||||
|
Condition50%1/2
$_->include_content // []
MC/DC0%0/1
$_->include_content // []
$_->include_content
Truth table50%1/2
A
A= $_->include_content
| |||||||||||||||||||||||||||||
| 74 | 1 | @{ $self->groups }; | |||||||||||||||||||||||||||
| 75 | 1 | push @{ $self->exclude_content }, | |||||||||||||||||||||||||||
| 76 | 3 | ▶ | map { @{ $_->exclude_content // [] } } | ||||||||||||||||||||||||||
|
Condition50%1/2
$_->exclude_content // []
MC/DC0%0/1
$_->exclude_content // []
$_->exclude_content
Truth table50%1/2
A
A= $_->exclude_content
| |||||||||||||||||||||||||||||
| 77 | 1 | @{ $self->groups }; | |||||||||||||||||||||||||||
| 78 | 1 | push @{ $self->include_tags }, | |||||||||||||||||||||||||||
| 79 | 3 | ▶ | map { @{ $_->include_tags // [] } } | ||||||||||||||||||||||||||
|
Condition50%1/2
$_->include_tags // []
MC/DC0%0/1
$_->include_tags // []
$_->include_tags
Truth table50%1/2
A
A= $_->include_tags
| |||||||||||||||||||||||||||||
| 80 | 1 | @{ $self->groups }; | |||||||||||||||||||||||||||
| 81 | 1 | push @{ $self->exclude_tags }, | |||||||||||||||||||||||||||
| 82 | 3 | ▶ | map { @{ $_->exclude_tags // [] } } | ||||||||||||||||||||||||||
|
Condition50%1/2
$_->exclude_tags // []
MC/DC0%0/1
$_->exclude_tags // []
$_->exclude_tags
Truth table50%1/2
A
A= $_->exclude_tags
| |||||||||||||||||||||||||||||
| 83 | 1 | @{ $self->groups }; | |||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | # If any group wants autoread, we'll take autoread | ||||||||||||||||||||||||||||
| 86 | 1 | ▶ | my $ar = any { $_->autoread } @{ $self->groups }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 87 | 1 | $self->set_autoread($ar); | |||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | # If any group does not want default_updates, we'll take no default | ||||||||||||||||||||||||||||
| 90 | # updates | ||||||||||||||||||||||||||||
| 91 | 1 | ▶ | my $ndu = any { !$_->default_update } @{ $self->groups }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 92 | 1 | $self->set_default_update(!$ndu); | |||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | # If any groups wants hidden, take hidden | ||||||||||||||||||||||||||||
| 95 | 1 | ▶ | my $hid = any { $_->hidden } @{ $self->groups }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 96 | 1 | $self->set_hidden($hid); | |||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | 1 | ▶ | my $cmd = first { defined } | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 99 | 3 | map { $_->open_cmd } | |||||||||||||||||||||||||||
| 100 | 3 | sort { $a->name cmp $b->name } | |||||||||||||||||||||||||||
| 101 | 1 | @{ $self->groups }; | |||||||||||||||||||||||||||
| 102 | 1 | ▶ | if (defined $cmd) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 103 | 1 | $self->set_open_cmd($cmd); | |||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | 1 | ▶ | my $ua = first { defined } | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 107 | 3 | map { $_->user_agent } | |||||||||||||||||||||||||||
| 108 | 3 | sort { $a->name cmp $b->name } | |||||||||||||||||||||||||||
| 109 | 1 | @{ $self->groups }; | |||||||||||||||||||||||||||
| 110 | 1 | ▶ | if (defined $ua) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 111 | 1 | $self->set_user_agent($ua); | |||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | 17 | ▶ | if (defined $param{ limit }) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 117 | 2 | $self->set_limit($param{ limit }); | |||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||
| 119 | 17 | ▶ | if (defined $param{ respect_skip }) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 120 | 0 | $self->set_respect_skip($param{ respect_skip }); | |||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||
| 122 | 17 | ▶ | if (defined $param{ include_title }) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 123 | 3 | push @{ $self->include_title }, @{ $param{ include_title } }; | |||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||
| 125 | 17 | ▶ | if (defined $param{ exclude_title }) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 126 | 3 | push @{ $self->exclude_title }, @{ $param{ exclude_title } }; | |||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||
| 128 | 17 | ▶ | if (defined $param{ include_content }) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 129 | 3 | push @{ $self->include_content }, @{ $param{ include_content } }; | |||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||
| 131 | 17 | ▶ | if (defined $param{ exclude_content }) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 132 | 3 | push @{ $self->exclude_content }, @{ $param{ exclude_content } }; | |||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||
| 134 | 17 | ▶ | if (defined $param{ include_tags }) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 135 | 3 | push @{ $self->include_tags }, @{ $param{ include_tags } }; | |||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||
| 137 | 17 | ▶ | if (defined $param{ exclude_tags }) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 138 | 3 | push @{ $self->exclude_tags }, @{ $param{ exclude_tags } }; | |||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||
| 140 | 17 | ▶ | if (defined $param{ autoread }) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 141 | 1 | $self->set_autoread($param{ autoread }); | |||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||
| 143 | 17 | ▶ | if (defined $param{ default_update }) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 144 | 1 | $self->set_default_update($param{ default_update }); | |||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||
| 146 | 17 | ▶ | if (defined $param{ hidden }) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 147 | 1 | $self->set_hidden($param{ hidden }); | |||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||
| 149 | 17 | ▶ | if (defined $param{ open }) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 150 | 1 | $self->set_open_cmd($param{ open }); | |||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||
| 152 | 17 | ▶ | if (defined $param{ user_agent }) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 153 | 1 | $self->set_user_agent($param{ user_agent }); | |||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||
| 156 | 17 | return 1; | |||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||
| 160 | 19 | ▶ | sub name { | ||||||||||||||||||||||||||
|
Subroutine
name: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||
| 162 | 19 | my ($self) = @_; | |||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||
| 164 | 19 | return $self->{ Name }; | |||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||
| 168 | 17 | ▶ | sub set_name { | ||||||||||||||||||||||||||
|
Subroutine
set_name: called CC=3 SCAR=12.7
Pod
documented
| |||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||
| 170 | 17 | my ($self, $name) = @_; | |||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||
| 172 | 17 | ▶ | unless (defined $name) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 173 | 0 | die "name cannot be undefined"; | |||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||
| 176 | # ':' feeds are reserved for internal use | ||||||||||||||||||||||||||||
| 177 | 17 | ▶ | unless ($name =~ /^\:?\w+$/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 178 | 0 | die "name can only contain alphanumeric and underscore characters"; | |||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||
| 181 | 17 | $self->{ Name } = $name; | |||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||
| 185 | 17 | ▶ | sub feed { | ||||||||||||||||||||||||||
|
Subroutine
feed: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||
| 187 | 17 | my ($self) = @_; | |||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||
| 189 | 17 | return $self->{ Feed }; | |||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||
| 193 | 17 | ▶ | sub set_feed { | ||||||||||||||||||||||||||
|
Subroutine
set_feed: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||
| 195 | 17 | my ($self, $feed) = @_; | |||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||
| 197 | 17 | ▶ | unless (defined $feed) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 198 | 0 | die "feed cannot be undefined"; | |||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||
| 201 | 17 | $self->{ Feed } = $feed; | |||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||
| 205 | 34 | ▶ | sub groups { | ||||||||||||||||||||||||||
|
Subroutine
groups: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||
| 207 | 34 | my ($self) = @_; | |||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||
| 209 | 34 | return $self->{ Groups }; | |||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||
| 213 | 17 | ▶ | sub set_groups { | ||||||||||||||||||||||||||
|
Subroutine
set_groups: called CC=4 SCAR=15.2
Pod
documented
| |||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||
| 215 | 17 | my ($self, $new) = @_; | |||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||
| 217 | 17 | ▶ | unless (ref $new eq 'ARRAY') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 218 | 0 | die "groups must be an array ref"; | |||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||
| 221 | 17 | for my $i (0 .. $#$new) { | |||||||||||||||||||||||||||
| 222 | 3 | ▶ | unless (eval { $new->[$i]->isa('WWW::Noss::GroupConfig') }) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 223 | 0 | die "group[$i] is not a WWW::Noss::GroupConfig object"; | |||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||
| 227 | 17 | $self->{ Groups } = $new; | |||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||
| 231 | 3 | ▶ | sub has_group { | ||||||||||||||||||||||||||
|
Subroutine
has_group: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||
| 233 | 3 | my ($self, $grp) = @_; | |||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||
| 235 | 3 | return !! grep { $_->name eq $grp } @{ $self->groups }; | |||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||
| 237 | } | ||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||
| 239 | 17 | ▶ | sub path { | ||||||||||||||||||||||||||
|
Subroutine
path: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||
| 241 | 17 | my ($self) = @_; | |||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||
| 243 | 17 | return $self->{ Path }; | |||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||
| 247 | 17 | ▶ | sub set_path { | ||||||||||||||||||||||||||
|
Subroutine
set_path: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||
| 249 | 17 | my ($self, $path) = @_; | |||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||
| 251 | 17 | ▶ | unless (defined $path) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 252 | 0 | die "path cannot be undefined"; | |||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||
| 255 | 17 | $self->{ Path } = $path; | |||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||
| 257 | } | ||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||
| 259 | 1 | ▶ | sub etag { | ||||||||||||||||||||||||||
|
Subroutine
etag: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||
| 261 | 1 | my ($self) = @_; | |||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||
| 263 | 1 | return $self->{ Etag }; | |||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||
| 265 | } | ||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||
| 267 | 17 | ▶ | sub set_etag { | ||||||||||||||||||||||||||
|
Subroutine
set_etag: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||
| 269 | 17 | my ($self, $etag) = @_; | |||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||
| 271 | 17 | $self->{ Etag } = $etag; | |||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||
| 273 | } | ||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||
| 275 | 0 | ▶ | sub retry_cache { | ||||||||||||||||||||||||||
|
Subroutine
retry_cache: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||
| 277 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||
| 279 | 0 | return $self->{ RetryCache }; | |||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||
| 281 | } | ||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||
| 283 | 17 | ▶ | sub set_retry_cache { | ||||||||||||||||||||||||||
|
Subroutine
set_retry_cache: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||
| 285 | 17 | my ($self, $cache) = @_; | |||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||
| 287 | 17 | $self->{ RetryCache } = $cache; | |||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||
| 291 | 2 | ▶ | sub retry { | ||||||||||||||||||||||||||
|
Subroutine
retry: called CC=5 SCAR=17.8
Pod
documented
| |||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||
| 293 | 2 | my ($self) = @_; | |||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||
| 295 | 2 | ▶ | if (not defined $self->{ RetryCache } or not -f $self->{ RetryCache }) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $self->{"RetryCache"} and -f $self->{"RetryCache"}
MC/DC0%0/2
defined $self->{"RetryCache"} and -f $self->{"RetryCache"}
defined $self->{"RetryCache"}
-f $self->{"RetryCache"}
Truth table33%1/3
A and B
A= defined $self->{"RetryCache"}B= -f $self->{"RetryCache"}
| |||||||||||||||||||||||||||||
| 296 | 0 | return undef; | |||||||||||||||||||||||||||
| 297 | } | ||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||
| 299 | open my $fh, '<', $self->{ RetryCache } | ||||||||||||||||||||||||||||
| 300 | 2 | ▶ | or die "Failed to open $self->{ RetryCache } for reading: $!"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 301 | 2 | my $retry = do { local $/; (readline $fh)[0] }; | |||||||||||||||||||||||||||
| 302 | 2 | close $fh; | |||||||||||||||||||||||||||
| 303 | 2 | chomp $retry; | |||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||
| 305 | 2 | ▶ | if ($retry !~ /^\d+$/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 306 | 0 | die "$self->{ RetryCache }: corrupted retry cache"; | |||||||||||||||||||||||||||
| 307 | } | ||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||
| 309 | 2 | return int $retry; | |||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||
| 311 | } | ||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||
| 313 | 1 | ▶ | sub set_retry { | ||||||||||||||||||||||||||
|
Subroutine
set_retry: called CC=4 SCAR=14.8
Pod
documented
| |||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||
| 315 | 1 | my ($self, $retry) = @_; | |||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||
| 317 | 1 | ▶ | if ($retry !~ /^\d+$/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 318 | 0 | die 'retry time must be an integar'; | |||||||||||||||||||||||||||
| 319 | } | ||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||
| 321 | 1 | ▶ | if (not defined $self->{ RetryCache }) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 322 | 0 | die 'retry_cache must be set before setting retry'; | |||||||||||||||||||||||||||
| 323 | } | ||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||
| 325 | 1 | $retry = int $retry; | |||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||
| 327 | open my $fh, '>', $self->{ RetryCache } | ||||||||||||||||||||||||||||
| 328 | 1 | ▶ | or die "Failed to open $self->{ RetryCache } for writing: $!"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 329 | 1 | print { $fh } $retry, "\n"; | |||||||||||||||||||||||||||
| 330 | 1 | close $fh; | |||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||
| 332 | 1 | return $retry; | |||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||
| 334 | } | ||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||
| 336 | 1 | ▶ | sub can_we_retry { | ||||||||||||||||||||||||||
|
Subroutine
can_we_retry: called CC=3 SCAR=11.8
Pod
documented
| |||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||
| 338 | 1 | my ($self, $time) = @_; | |||||||||||||||||||||||||||
| 339 | 1 | ▶ | $time //= time; | ||||||||||||||||||||||||||
|
Condition50%1/2
$time //= time
MC/DC0%0/1
$time //= time
$time
Truth table50%1/2
A
A= $time
| |||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||
| 341 | 1 | my $retry = $self->retry; | |||||||||||||||||||||||||||
| 342 | 1 | ▶ | if (not defined $retry) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 343 | 0 | return 1; | |||||||||||||||||||||||||||
| 344 | } | ||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||
| 346 | 1 | return $time >= $retry; | |||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||
| 348 | } | ||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||
| 350 | 6 | 1; | |||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||
| 352 | =head1 NAME | ||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||
| 354 | WWW::Noss::FeedConfig - Class for storing feed configurations | ||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||
| 356 | =head1 USAGE | ||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||
| 358 | use WWW::Noss::FeedConfig; | ||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||
| 360 | my $feed = WWW::Noss::FeedConfig->new( | ||||||||||||||||||||||||||||
| 361 | name => 'feed', | ||||||||||||||||||||||||||||
| 362 | feed => 'https://feed.xml', | ||||||||||||||||||||||||||||
| 363 | path => 'feed.xml', | ||||||||||||||||||||||||||||
| 364 | ); | ||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||
| 366 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||
| 368 | B<WWW::Noss::FeedConfig> is a module that provides a class for storing L<noss> | ||||||||||||||||||||||||||||
| 369 | feed configurations. This is a private module, please consult the L<noss> | ||||||||||||||||||||||||||||
| 370 | manual for user documentation. | ||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||
| 372 | =head1 METHODS | ||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||
| 374 | Not all methods are documented here, as this class is derived from the | ||||||||||||||||||||||||||||
| 375 | L<WWW::Noss::BaseConfig> module. Consult its documentation for additional | ||||||||||||||||||||||||||||
| 376 | methods. | ||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||
| 378 | =over 4 | ||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||
| 380 | =item $feed = WWW::Noss::FeedConfig->new(%param) | ||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||
| 382 | Returns a blessed B<WWW::Noss::FeedConfig> object based on the parameters | ||||||||||||||||||||||||||||
| 383 | provided in the C<%param> hash. | ||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||
| 385 | The following are valid fields for the C<%param> hash. The C<name>, C<feed>, | ||||||||||||||||||||||||||||
| 386 | and C<path> fields are the only required fields. | ||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||
| 388 | =over 4 | ||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||
| 390 | =item name | ||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||
| 392 | The name of feed. Can only only contain alphanumeric and underscore | ||||||||||||||||||||||||||||
| 393 | characters. | ||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||
| 395 | =item feed | ||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||
| 397 | The feed URL. | ||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||
| 399 | =item path | ||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||
| 401 | Path to the location to store the feed. | ||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||
| 403 | =item etag | ||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||
| 405 | Path to store the feed's etag. | ||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||
| 407 | =item groups | ||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||
| 409 | Array ref of L<WWW::Noss::GroupConfig> groups that the feed is a part of. | ||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||
| 411 | =item default | ||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||
| 413 | L<WWW::Noss::GroupConfig> object representing the default feed group. | ||||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||
| 415 | =back | ||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||
| 417 | The following fields from L<WWW::Noss::BaseConfig> are also available: | ||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||
| 419 | =over 4 | ||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||
| 421 | =item limit | ||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||
| 423 | =item respect_skip | ||||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||
| 425 | =item include_title | ||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||
| 427 | =item exclude_title | ||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||
| 429 | =item include_content | ||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||
| 431 | =item exclude_content | ||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||
| 433 | =item include_tags | ||||||||||||||||||||||||||||
| 434 | |||||||||||||||||||||||||||||
| 435 | =item exclude_tags | ||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||
| 437 | =item autoread | ||||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||
| 439 | =item default_update | ||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||
| 441 | =item hidden | ||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||
| 443 | =item open | ||||||||||||||||||||||||||||
| 444 | |||||||||||||||||||||||||||||
| 445 | =item user_agent | ||||||||||||||||||||||||||||
| 446 | |||||||||||||||||||||||||||||
| 447 | =back | ||||||||||||||||||||||||||||
| 448 | |||||||||||||||||||||||||||||
| 449 | =item $name = $feed->name() | ||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||
| 451 | =item $feed->set_name($name) | ||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||
| 453 | Getter/setter for the feed's name attribute. | ||||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||
| 455 | =item $url = $feed->feed() | ||||||||||||||||||||||||||||
| 456 | |||||||||||||||||||||||||||||
| 457 | =item $feed->set_feed($url) | ||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||
| 459 | Getter/setter for the feed's feed attribute. | ||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||
| 461 | =item \@groups = $feed->groups() | ||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||
| 463 | =item $feed->set_groups(\@groups) | ||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||
| 465 | Getter/setter for the feed's groups attribute. Do note that modifying the | ||||||||||||||||||||||||||||
| 466 | groups attribute does not affect the feed's configuration like it does during | ||||||||||||||||||||||||||||
| 467 | initialization. | ||||||||||||||||||||||||||||
| 468 | |||||||||||||||||||||||||||||
| 469 | =item $ok = $feed->has_group($group) | ||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||
| 471 | Returns true if C<$feed> is a part of the group C<$group>. | ||||||||||||||||||||||||||||
| 472 | |||||||||||||||||||||||||||||
| 473 | =item $path = $feed->path() | ||||||||||||||||||||||||||||
| 474 | |||||||||||||||||||||||||||||
| 475 | =item $feed->set_path($path) | ||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||
| 477 | Getter/setter for the feed's path attribute. | ||||||||||||||||||||||||||||
| 478 | |||||||||||||||||||||||||||||
| 479 | =item $etag = $feed->etag() | ||||||||||||||||||||||||||||
| 480 | |||||||||||||||||||||||||||||
| 481 | =item $feed->set_etag($etag) | ||||||||||||||||||||||||||||
| 482 | |||||||||||||||||||||||||||||
| 483 | Getter/setter for the feed's etag attribute. | ||||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||
| 485 | =item $file = $feed->retry_cache() | ||||||||||||||||||||||||||||
| 486 | |||||||||||||||||||||||||||||
| 487 | =item $feed->set_retry_cache($file) | ||||||||||||||||||||||||||||
| 488 | |||||||||||||||||||||||||||||
| 489 | Getter/setter for the feed's retry cache file. | ||||||||||||||||||||||||||||
| 490 | |||||||||||||||||||||||||||||
| 491 | =item $retry = $feed->retry() | ||||||||||||||||||||||||||||
| 492 | |||||||||||||||||||||||||||||
| 493 | =item $feed->set_retry($retry) | ||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||
| 495 | =item $ok = $feed->can_we_retry([ $time ]) | ||||||||||||||||||||||||||||
| 496 | |||||||||||||||||||||||||||||
| 497 | Getter/setter for the feed's retry time. | ||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||
| 499 | =back | ||||||||||||||||||||||||||||
| 500 | |||||||||||||||||||||||||||||
| 501 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 502 | |||||||||||||||||||||||||||||
| 503 | Written by Samuel Young, E<lt>samyoung@posteo.comE<gt>. | ||||||||||||||||||||||||||||
| 504 | |||||||||||||||||||||||||||||
| 505 | This project's source can be found on its | ||||||||||||||||||||||||||||
| 506 | L<Codeberg page|https://codeberg.org/1-1sam/noss.git>. Comments and pull | ||||||||||||||||||||||||||||
| 507 | requests are welcome! | ||||||||||||||||||||||||||||
| 508 | |||||||||||||||||||||||||||||
| 509 | =head1 COPYRIGHT | ||||||||||||||||||||||||||||
| 510 | |||||||||||||||||||||||||||||
| 511 | Copyright (C) 2025-2026 Samuel Young | ||||||||||||||||||||||||||||
| 512 | |||||||||||||||||||||||||||||
| 513 | This program is free software: you can redistribute it and/or modify | ||||||||||||||||||||||||||||
| 514 | it under the terms of the GNU General Public License as published by | ||||||||||||||||||||||||||||
| 515 | the Free Software Foundation, either version 3 of the License, or | ||||||||||||||||||||||||||||
| 516 | (at your option) any later version. | ||||||||||||||||||||||||||||
| 517 | |||||||||||||||||||||||||||||
| 518 | =head1 SEE ALSO | ||||||||||||||||||||||||||||
| 519 | |||||||||||||||||||||||||||||
| 520 | L<WWW::Noss::BaseConfig>, L<WWW::Noss::GroupConfig>, L<noss> | ||||||||||||||||||||||||||||
| 521 | |||||||||||||||||||||||||||||
| 522 | =cut | ||||||||||||||||||||||||||||
| 523 | |||||||||||||||||||||||||||||
| 524 | # vim: expandtab shiftwidth=4 | ||||||||||||||||||||||||||||