| 1 | package WWW::Noss; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | 1 | ▶ | use 5.016; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 1 | our $VERSION = '2.04'; | |||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use Cwd; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use Getopt::Long qw(GetOptionsFromArray); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use File::Basename; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use File::Copy; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use File::Spec; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | 1 | ▶ | use File::Temp qw(tempfile); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | 1 | ▶ | use List::Util qw(max uniq); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | 1 | ▶ | use POSIX qw(strftime); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | 1 | ▶ | use Pod::Usage; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | 1 | ▶ | use Term::ANSIColor; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | 1 | ▶ | use JSON; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||
| 20 | 1 | ▶ | use WWW::Noss::Curl qw(curl curl_error http_status_string); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 21 | 1 | ▶ | use WWW::Noss::DB; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | 1 | ▶ | use WWW::Noss::FeedConfig; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 23 | 1 | ▶ | use WWW::Noss::FeedReader qw(discover_feeds); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 24 | 1 | ▶ | use WWW::Noss::Forker; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | 1 | ▶ | use WWW::Noss::GroupConfig; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 26 | 1 | ▶ | use WWW::Noss::Home qw(home); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 27 | 1 | ▶ | use WWW::Noss::Lynx qw(lynx_dump); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 28 | 1 | ▶ | use WWW::Noss::OPML; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 29 | 1 | ▶ | use WWW::Noss::TextToHtml qw(escape_html); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 30 | 1 | ▶ | use WWW::Noss::Util qw(dir resolve_url); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||
| 32 | 1 | my $PRGNAM = 'noss'; | |||||||||||||||||||||||||||||||||||||||||
| 33 | 1 | my $PRGVER = $VERSION; | |||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||
| 35 | # TODO: Command aliases? | ||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||
| 37 | 1 | my %COMMANDS = ( | |||||||||||||||||||||||||||||||||||||||||
| 38 | 'update' => \&update, | ||||||||||||||||||||||||||||||||||||||||||
| 39 | 'reload' => \&reload, | ||||||||||||||||||||||||||||||||||||||||||
| 40 | 'read' => \&read_post, | ||||||||||||||||||||||||||||||||||||||||||
| 41 | 'open' => \&open_post, | ||||||||||||||||||||||||||||||||||||||||||
| 42 | 'cat' => \&cat, | ||||||||||||||||||||||||||||||||||||||||||
| 43 | 'list' => \&look, | ||||||||||||||||||||||||||||||||||||||||||
| 44 | 'unread' => \&unread, | ||||||||||||||||||||||||||||||||||||||||||
| 45 | 'mark' => \&mark, | ||||||||||||||||||||||||||||||||||||||||||
| 46 | 'post' => \&post, | ||||||||||||||||||||||||||||||||||||||||||
| 47 | 'feeds' => \&feeds, | ||||||||||||||||||||||||||||||||||||||||||
| 48 | 'groups' => \&groups, | ||||||||||||||||||||||||||||||||||||||||||
| 49 | 'clean' => \&clean, | ||||||||||||||||||||||||||||||||||||||||||
| 50 | 'discover' => \&discover, | ||||||||||||||||||||||||||||||||||||||||||
| 51 | 'export' => \&export_opml, | ||||||||||||||||||||||||||||||||||||||||||
| 52 | 'import' => \&import_opml, | ||||||||||||||||||||||||||||||||||||||||||
| 53 | 'help' => \&help, | ||||||||||||||||||||||||||||||||||||||||||
| 54 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||
| 56 | 1 | my $DOT_LOCAL = File::Spec->catfile(home, '.local/share'); | |||||||||||||||||||||||||||||||||||||||||
| 57 | 1 | my $DOT_CONFIG = File::Spec->catfile(home, '.config'); | |||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||
| 59 | 1 | my $DEFAULT_AGENT = "$PRGNAM/$PRGVER ($^O; perl $^V)"; | |||||||||||||||||||||||||||||||||||||||||
| 60 | 1 | ▶ | my $DEFAULT_PAGER = $^O eq 'MSWin32' ? 'more' : 'less'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 61 | 1 | my $DEFAULT_FORKS = 10; | |||||||||||||||||||||||||||||||||||||||||
| 62 | 1 | my $DEFAULT_WIDTH = 80; | |||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||
| 64 | 1 | my %VALID_SORTS = map { $_ => 1 } qw( | |||||||||||||||||||||||||||||||||||||||||
| 65 | feed | ||||||||||||||||||||||||||||||||||||||||||
| 66 | title | ||||||||||||||||||||||||||||||||||||||||||
| 67 | date | ||||||||||||||||||||||||||||||||||||||||||
| 68 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||
| 70 | 1 | my $Z_FMT = '%c'; | |||||||||||||||||||||||||||||||||||||||||
| 71 | 1 | my $Z_UNK = strftime($Z_FMT, localtime 0) =~ s/\w/?/gr; | |||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||
| 73 | 1 | my $RATE_RX = qr/^\d+[kmg]?$/i; | |||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||
| 75 | my %POST_FMT_CODES = ( | ||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | ▶ | '%' => sub { '%' }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | ▶ | 'f' => sub { $_[0]->{ feed } }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | ▶ | 'i' => sub { $_[0]->{ nossid } }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | ▶ | 't' => sub { $_[0]->{ displaytitle } // ''}, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Condition0%0/2
$_[0]{"displaytitle"} // ""
MC/DC0%0/1
$_[0]{"displaytitle"} // ""
$_[0]{"displaytitle"}
Truth table0%0/2
A
A= $_[0]{"displaytitle"}
| |||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | ▶ | 'u' => sub { $_[0]->{ link } // 'N/A' }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Condition0%0/2
$_[0]{"link"} // "N/A"
MC/DC0%0/1
$_[0]{"link"} // "N/A"
$_[0]{"link"}
Truth table0%0/2
A
A= $_[0]{"link"}
| |||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | ▶ | 'a' => sub { $_[0]->{ author } // 'N/A' }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Condition0%0/2
$_[0]{"author"} // "N/A"
MC/DC0%0/1
$_[0]{"author"} // "N/A"
$_[0]{"author"}
Truth table0%0/2
A
A= $_[0]{"author"}
| |||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | ▶ | 'c' => sub { join ', ', @{ $_[0]->{ category } } }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | ▶ | 's' => sub { $_[0]->{ status } eq 'read' ? 'r' : 'U' }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | ▶ | 'S' => sub { $_[0]->{ status } eq 'read' ? 'read' : 'unread' }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | ▶ | 'P' => sub { $_[0]->{ summary } // '' }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Condition0%0/2
$_[0]{"summary"} // ""
MC/DC0%0/1
$_[0]{"summary"} // ""
$_[0]{"summary"}
Truth table0%0/2
A
A= $_[0]{"summary"}
| |||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | ▶ | 'C' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | ▶ | strftime('%c', localtime($_[0]->{ updated } // $_[0]->{ published } // return 'N/A')) | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/5
($_[0]{"updated"} // $_[0]{"published"}) // (return "N/A")
$_[0]{"updated"} // $_[0]{"published"}
MC/DC0%0/2
($_[0]{"updated"} // $_[0]{"published"}) // (return "N/A")
$_[0]{"updated"}
$_[0]{"published"}
Truth table0%0/3
A // B
A= $_[0]{"updated"}B= $_[0]{"published"}
| |||||||||||||||||||||||||||||||||||||||||||
| 88 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | ▶ | 'd' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | ▶ | strftime('%d', localtime($_[0]->{ updated } // $_[0]->{ published } // return '??')) | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/5
($_[0]{"updated"} // $_[0]{"published"}) // (return "??")
$_[0]{"updated"} // $_[0]{"published"}
MC/DC0%0/2
($_[0]{"updated"} // $_[0]{"published"}) // (return "??")
$_[0]{"updated"}
$_[0]{"published"}
Truth table0%0/3
A // B
A= $_[0]{"updated"}B= $_[0]{"published"}
| |||||||||||||||||||||||||||||||||||||||||||
| 91 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | ▶ | 'w' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | ▶ | strftime('%a', localtime($_[0]->{ updated } // $_[0]->{ published } // return '???')) | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/5
($_[0]{"updated"} // $_[0]{"published"}) // (return "???")
$_[0]{"updated"} // $_[0]{"published"}
MC/DC0%0/2
($_[0]{"updated"} // $_[0]{"published"}) // (return "???")
$_[0]{"updated"}
$_[0]{"published"}
Truth table0%0/3
A // B
A= $_[0]{"updated"}B= $_[0]{"published"}
| |||||||||||||||||||||||||||||||||||||||||||
| 94 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | ▶ | 'W' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | ▶ | strftime('%A', localtime($_[0]->{ updated } // $_[0]->{ published } // return '???')) | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/5
($_[0]{"updated"} // $_[0]{"published"}) // (return "???")
$_[0]{"updated"} // $_[0]{"published"}
MC/DC0%0/2
($_[0]{"updated"} // $_[0]{"published"}) // (return "???")
$_[0]{"updated"}
$_[0]{"published"}
Truth table0%0/3
A // B
A= $_[0]{"updated"}B= $_[0]{"published"}
| |||||||||||||||||||||||||||||||||||||||||||
| 97 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | ▶ | 'm' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | ▶ | strftime('%b', localtime($_[0]->{ updated } // $_[0]->{ published } // return '???')) | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/5
($_[0]{"updated"} // $_[0]{"published"}) // (return "???")
$_[0]{"updated"} // $_[0]{"published"}
MC/DC0%0/2
($_[0]{"updated"} // $_[0]{"published"}) // (return "???")
$_[0]{"updated"}
$_[0]{"published"}
Truth table0%0/3
A // B
A= $_[0]{"updated"}B= $_[0]{"published"}
| |||||||||||||||||||||||||||||||||||||||||||
| 100 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | ▶ | 'M' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | ▶ | strftime('%B', localtime($_[0]->{ updated } // $_[0]->{ published } // return '???')) | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/5
($_[0]{"updated"} // $_[0]{"published"}) // (return "???")
$_[0]{"updated"} // $_[0]{"published"}
MC/DC0%0/2
($_[0]{"updated"} // $_[0]{"published"}) // (return "???")
$_[0]{"updated"}
$_[0]{"published"}
Truth table0%0/3
A // B
A= $_[0]{"updated"}B= $_[0]{"published"}
| |||||||||||||||||||||||||||||||||||||||||||
| 103 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | ▶ | 'n' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | ▶ | strftime('%m', localtime($_[0]->{ updated } // $_[0]->{ published } // return '??')) | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/5
($_[0]{"updated"} // $_[0]{"published"}) // (return "??")
$_[0]{"updated"} // $_[0]{"published"}
MC/DC0%0/2
($_[0]{"updated"} // $_[0]{"published"}) // (return "??")
$_[0]{"updated"}
$_[0]{"published"}
Truth table0%0/3
A // B
A= $_[0]{"updated"}B= $_[0]{"published"}
| |||||||||||||||||||||||||||||||||||||||||||
| 106 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | ▶ | 'y' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | ▶ | strftime('%g', localtime($_[0]->{ updated } // $_[0]->{ published } // return '??')) | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/5
($_[0]{"updated"} // $_[0]{"published"}) // (return "??")
$_[0]{"updated"} // $_[0]{"published"}
MC/DC0%0/2
($_[0]{"updated"} // $_[0]{"published"}) // (return "??")
$_[0]{"updated"}
$_[0]{"published"}
Truth table0%0/3
A // B
A= $_[0]{"updated"}B= $_[0]{"published"}
| |||||||||||||||||||||||||||||||||||||||||||
| 109 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | ▶ | 'Y' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | ▶ | strftime('%G', localtime($_[0]->{ updated } // $_[0]->{ published } // return '????')) | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/5
($_[0]{"updated"} // $_[0]{"published"}) // (return "????")
$_[0]{"updated"} // $_[0]{"published"}
MC/DC0%0/2
($_[0]{"updated"} // $_[0]{"published"}) // (return "????")
$_[0]{"updated"}
$_[0]{"published"}
Truth table0%0/3
A // B
A= $_[0]{"updated"}B= $_[0]{"published"}
| |||||||||||||||||||||||||||||||||||||||||||
| 112 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | ▶ | 'z' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | ▶ | my $t = $_[0]->{ updated } // $_[0]->{ published }; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$_[0]{"updated"} // $_[0]{"published"}
MC/DC0%0/2
$_[0]{"updated"} // $_[0]{"published"}
$_[0]{"updated"}
$_[0]{"published"}
Truth table0%0/3
A // B
A= $_[0]{"updated"}B= $_[0]{"published"}
| |||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | ▶ | if (defined $t) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | return strftime($Z_FMT, localtime $t); | |||||||||||||||||||||||||||||||||||||||||
| 117 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | return $Z_UNK; | |||||||||||||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||||||||||||
| 120 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 121 | 1 | ); | |||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||
| 123 | my %FEED_FMT_CODES = ( | ||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | ▶ | '%' => sub { '%' }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | ▶ | 'f' => sub { $_[0]->{ nossname } }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | ▶ | 'l' => sub { $_[0]->{ nosslink } }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | ▶ | 't' => sub { $_[0]->{ title } // '' }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Condition0%0/2
$_[0]{"title"} // ""
MC/DC0%0/1
$_[0]{"title"} // ""
$_[0]{"title"}
Truth table0%0/2
A
A= $_[0]{"title"}
| |||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | ▶ | 'u' => sub { $_[0]->{ link } // 'N/A' }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Condition0%0/2
$_[0]{"link"} // "N/A"
MC/DC0%0/1
$_[0]{"link"} // "N/A"
$_[0]{"link"}
Truth table0%0/2
A
A= $_[0]{"link"}
| |||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | ▶ | 'e' => sub { $_[0]->{ description } // '' }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Condition0%0/2
$_[0]{"description"} // ""
MC/DC0%0/1
$_[0]{"description"} // ""
$_[0]{"description"}
Truth table0%0/2
A
A= $_[0]{"description"}
| |||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | ▶ | 'a' => sub { $_[0]->{ author } // 'N/A' }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Condition0%0/2
$_[0]{"author"} // "N/A"
MC/DC0%0/1
$_[0]{"author"} // "N/A"
$_[0]{"author"}
Truth table0%0/2
A
A= $_[0]{"author"}
| |||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | ▶ | 'c' => sub { join ', ', @{ $_[0]->{ category } // [] } }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Condition0%0/2
$_[0]{"category"} // []
MC/DC0%0/1
$_[0]{"category"} // []
$_[0]{"category"}
Truth table0%0/2
A
A= $_[0]{"category"}
| |||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | ▶ | 'p' => sub { $_[0]->{ posts } // 0}, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Condition0%0/2
$_[0]{"posts"} // 0
MC/DC0%0/1
$_[0]{"posts"} // 0
$_[0]{"posts"}
Truth table0%0/2
A
A= $_[0]{"posts"}
| |||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | ▶ | 'r' => sub { ($_[0]->{ posts } // 0) - ($_[0]->{ unread } // 0) }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
Condition0%0/4
$_[0]{"posts"} // 0
$_[0]{"unread"} // 0
MC/DC0%0/1
$_[0]{"posts"} // 0
$_[0]{"posts"}
MC/DC0%0/1
$_[0]{"unread"} // 0
$_[0]{"unread"}
Truth table0%0/2
A
A= $_[0]{"posts"}
Truth table0%0/2
A
A= $_[0]{"unread"}
| |||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | ▶ | 'U' => sub { $_[0]->{ unread } // 0}, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Condition0%0/2
$_[0]{"unread"} // 0
MC/DC0%0/1
$_[0]{"unread"} // 0
$_[0]{"unread"}
Truth table0%0/2
A
A= $_[0]{"unread"}
| |||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | ▶ | 'C' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | ▶ | strftime('%c', localtime($_[0]->{ updated } // return 'N/A')) | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$_[0]{"updated"} // (return "N/A")
MC/DC0%0/1
$_[0]{"updated"} // (return "N/A")
$_[0]{"updated"}
Truth table0%0/2
A
A= $_[0]{"updated"}
| |||||||||||||||||||||||||||||||||||||||||||
| 137 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | ▶ | 'd' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | ▶ | strftime('%d', localtime($_[0]->{ updated } // return '??')) | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$_[0]{"updated"} // (return "??")
MC/DC0%0/1
$_[0]{"updated"} // (return "??")
$_[0]{"updated"}
Truth table0%0/2
A
A= $_[0]{"updated"}
| |||||||||||||||||||||||||||||||||||||||||||
| 140 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | ▶ | 'w' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | ▶ | strftime('%a', localtime($_[0]->{ updated } // return '???')) | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$_[0]{"updated"} // (return "???")
MC/DC0%0/1
$_[0]{"updated"} // (return "???")
$_[0]{"updated"}
Truth table0%0/2
A
A= $_[0]{"updated"}
| |||||||||||||||||||||||||||||||||||||||||||
| 143 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | ▶ | 'W' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | ▶ | strftime('%A', localtime($_[0]->{ updated } // return '???')) | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$_[0]{"updated"} // (return "???")
MC/DC0%0/1
$_[0]{"updated"} // (return "???")
$_[0]{"updated"}
Truth table0%0/2
A
A= $_[0]{"updated"}
| |||||||||||||||||||||||||||||||||||||||||||
| 146 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | ▶ | 'm' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | ▶ | strftime('%b', localtime($_[0]->{ updated } // return '???')) | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$_[0]{"updated"} // (return "???")
MC/DC0%0/1
$_[0]{"updated"} // (return "???")
$_[0]{"updated"}
Truth table0%0/2
A
A= $_[0]{"updated"}
| |||||||||||||||||||||||||||||||||||||||||||
| 149 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | ▶ | 'M' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | ▶ | strftime('%B', localtime($_[0]->{ updated } // return '???')) | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$_[0]{"updated"} // (return "???")
MC/DC0%0/1
$_[0]{"updated"} // (return "???")
$_[0]{"updated"}
Truth table0%0/2
A
A= $_[0]{"updated"}
| |||||||||||||||||||||||||||||||||||||||||||
| 152 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | ▶ | 'n' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | ▶ | strftime('%m', localtime($_[0]->{ updated } // return '??')) | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$_[0]{"updated"} // (return "??")
MC/DC0%0/1
$_[0]{"updated"} // (return "??")
$_[0]{"updated"}
Truth table0%0/2
A
A= $_[0]{"updated"}
| |||||||||||||||||||||||||||||||||||||||||||
| 155 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | ▶ | 'y' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | ▶ | strftime('%g', localtime($_[0]->{ updated } // return '??')) | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$_[0]{"updated"} // (return "??")
MC/DC0%0/1
$_[0]{"updated"} // (return "??")
$_[0]{"updated"}
Truth table0%0/2
A
A= $_[0]{"updated"}
| |||||||||||||||||||||||||||||||||||||||||||
| 158 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | ▶ | 'Y' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | ▶ | strftime('%G', localtime($_[0]->{ updated } // return '????')) | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$_[0]{"updated"} // (return "????")
MC/DC0%0/1
$_[0]{"updated"} // (return "????")
$_[0]{"updated"}
Truth table0%0/2
A
A= $_[0]{"updated"}
| |||||||||||||||||||||||||||||||||||||||||||
| 161 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | ▶ | 'z' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | my $t = $_[0]->{ updated }; | |||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | ▶ | if (defined $t) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | return strftime($Z_FMT, localtime $t); | |||||||||||||||||||||||||||||||||||||||||
| 166 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | return $Z_UNK; | |||||||||||||||||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||||||||||||||||
| 169 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 170 | 1 | ); | |||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||
| 172 | 1 | my $DEFAULT_READ_FMT = <<'HERE'; | |||||||||||||||||||||||||||||||||||||||||
| 173 | <h1>%f - %t</h1> | ||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||
| 175 | <div> | ||||||||||||||||||||||||||||||||||||||||||
| 176 | %P | ||||||||||||||||||||||||||||||||||||||||||
| 177 | </div> | ||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||
| 179 | <p> | ||||||||||||||||||||||||||||||||||||||||||
| 180 | Link: %u | ||||||||||||||||||||||||||||||||||||||||||
| 181 | </p> | ||||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||||
| 183 | <p> | ||||||||||||||||||||||||||||||||||||||||||
| 184 | Updated: %z | ||||||||||||||||||||||||||||||||||||||||||
| 185 | </p> | ||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||
| 187 | HERE | ||||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||
| 189 | 1 | my $DEFAULT_POST_FMT = <<'HERE'; | |||||||||||||||||||||||||||||||||||||||||
| 190 | <14>%f<0>:<15>%i<0> | ||||||||||||||||||||||||||||||||||||||||||
| 191 | <16>Title<0>: %t | ||||||||||||||||||||||||||||||||||||||||||
| 192 | <16>Link<0>: %u | ||||||||||||||||||||||||||||||||||||||||||
| 193 | <16>Author<0>: %a | ||||||||||||||||||||||||||||||||||||||||||
| 194 | <16>Tags<0>: %c | ||||||||||||||||||||||||||||||||||||||||||
| 195 | <16>Updated<0>: %z | ||||||||||||||||||||||||||||||||||||||||||
| 196 | <16>Status<0>: %S | ||||||||||||||||||||||||||||||||||||||||||
| 197 | HERE | ||||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||
| 199 | 1 | my $DEFAULT_FEED_FMT = <<'HERE'; | |||||||||||||||||||||||||||||||||||||||||
| 200 | <14>%f<0> | ||||||||||||||||||||||||||||||||||||||||||
| 201 | <16>Title<0>: %t | ||||||||||||||||||||||||||||||||||||||||||
| 202 | <16>Source<0>: %l | ||||||||||||||||||||||||||||||||||||||||||
| 203 | <16>Link<0>: %u | ||||||||||||||||||||||||||||||||||||||||||
| 204 | <16>Author<0>: %a | ||||||||||||||||||||||||||||||||||||||||||
| 205 | <16>Updated<0>: %z | ||||||||||||||||||||||||||||||||||||||||||
| 206 | <16>Posts<0>: %p | ||||||||||||||||||||||||||||||||||||||||||
| 207 | <16>Unread<0>: %U/%p | ||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||
| 209 | HERE | ||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||
| 211 | 1 | my %DOESNT_NEED_FEED = map { $_ => 1 } qw( | |||||||||||||||||||||||||||||||||||||||||
| 212 | discover import help | ||||||||||||||||||||||||||||||||||||||||||
| 213 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||||||||||||
| 215 | 1 | my $COLOR_CODE_RX = qr/(?:1[0-6]|[0-9])/; | |||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||
| 217 | 1 | my %COLOR_CODES = ( | |||||||||||||||||||||||||||||||||||||||||
| 218 | 0 => 'clear', | ||||||||||||||||||||||||||||||||||||||||||
| 219 | 1 => 'black', | ||||||||||||||||||||||||||||||||||||||||||
| 220 | 2 => 'red', | ||||||||||||||||||||||||||||||||||||||||||
| 221 | 3 => 'green', | ||||||||||||||||||||||||||||||||||||||||||
| 222 | 4 => 'yellow', | ||||||||||||||||||||||||||||||||||||||||||
| 223 | 5 => 'blue', | ||||||||||||||||||||||||||||||||||||||||||
| 224 | 6 => 'magenta', | ||||||||||||||||||||||||||||||||||||||||||
| 225 | 7 => 'cyan', | ||||||||||||||||||||||||||||||||||||||||||
| 226 | 8 => 'white', | ||||||||||||||||||||||||||||||||||||||||||
| 227 | 9 => 'bold black', | ||||||||||||||||||||||||||||||||||||||||||
| 228 | 10 => 'bold red', | ||||||||||||||||||||||||||||||||||||||||||
| 229 | 11 => 'bold green', | ||||||||||||||||||||||||||||||||||||||||||
| 230 | 12 => 'bold yellow', | ||||||||||||||||||||||||||||||||||||||||||
| 231 | 13 => 'bold blue', | ||||||||||||||||||||||||||||||||||||||||||
| 232 | 14 => 'bold magenta', | ||||||||||||||||||||||||||||||||||||||||||
| 233 | 15 => 'bold cyan', | ||||||||||||||||||||||||||||||||||||||||||
| 234 | 16 => 'bold white', | ||||||||||||||||||||||||||||||||||||||||||
| 235 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | ▶ | sub _HELP { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_HELP: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | my ($fh, $rt) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | pod2usage( | |||||||||||||||||||||||||||||||||||||||||
| 242 | -exitval => 'NOEXIT', | ||||||||||||||||||||||||||||||||||||||||||
| 243 | -verbose => 99, | ||||||||||||||||||||||||||||||||||||||||||
| 244 | -sections => 'SYNOPSIS', | ||||||||||||||||||||||||||||||||||||||||||
| 245 | -output => \$fh, | ||||||||||||||||||||||||||||||||||||||||||
| 246 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | ▶ | if (defined $rt) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | exit $rt; | |||||||||||||||||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | ▶ | sub _VER { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_VER: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | my ($fh, $rt) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | print { $fh } <<"HERE"; | |||||||||||||||||||||||||||||||||||||||||
| 259 | $PRGNAM - $PRGVER | ||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||
| 261 | Copyright (C) 2025-2026 Samuel Young | ||||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||
| 263 | This program is free software: you can redistribute it and/or modify | ||||||||||||||||||||||||||||||||||||||||||
| 264 | it under the terms of the GNU General Public License as published by | ||||||||||||||||||||||||||||||||||||||||||
| 265 | the Free Software Foundation, either version 3 of the License, or | ||||||||||||||||||||||||||||||||||||||||||
| 266 | (at your option) any later version. | ||||||||||||||||||||||||||||||||||||||||||
| 267 | HERE | ||||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | ▶ | if (defined $rt) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | exit $rt; | |||||||||||||||||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||
| 273 | } | ||||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | ▶ | sub _set_z_fmt { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_set_z_fmt: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | my ($z) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | $Z_FMT = $z; | |||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | $Z_UNK = strftime($Z_FMT, localtime 0) =~ s/\w/?/gr; | |||||||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | ▶ | sub _default_data_dir { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_default_data_dir: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | my $data; | |||||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | ▶ | if (exists $ENV{ NOSS_DATA }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 289 | 0 | $data = $ENV{ NOSS_DATA }; | |||||||||||||||||||||||||||||||||||||||||
| 290 | ▶ | } elsif (exists $ENV{ XDG_DATA_HOME } and -d $ENV{ XDG_DATA_HOME }) { | |||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
exists $ENV{"XDG_DATA_HOME"} and -d $ENV{"XDG_DATA_HOME"}
MC/DC0%0/2
exists $ENV{"XDG_DATA_HOME"} and -d $ENV{"XDG_DATA_HOME"}
exists $ENV{"XDG_DATA_HOME"}
-d $ENV{"XDG_DATA_HOME"}
Truth table0%0/3
A and B
A= exists $ENV{"XDG_DATA_HOME"}B= -d $ENV{"XDG_DATA_HOME"}
| |||||||||||||||||||||||||||||||||||||||||||
| 291 | 0 | $data = File::Spec->catfile($ENV{ XDG_DATA_HOME }, $PRGNAM); | |||||||||||||||||||||||||||||||||||||||||
| 292 | } elsif (-d $DOT_LOCAL) { | ||||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | $data = File::Spec->catfile($DOT_LOCAL, $PRGNAM); | |||||||||||||||||||||||||||||||||||||||||
| 294 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 295 | 0 | $data = File::Spec->catfile(home, ".$PRGNAM"); | |||||||||||||||||||||||||||||||||||||||||
| 296 | } | ||||||||||||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | return $data; | |||||||||||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||||||||||||
| 300 | } | ||||||||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||||||||
| 302 | 0 | ▶ | sub _default_config { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_default_config: not called CC=9 SCAR=45.0
| |||||||||||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||||||||||
| 304 | 0 | my $cf; | |||||||||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | ▶ | if (exists $ENV{ NOSS_CONFIG }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | return $ENV{ NOSS_CONFIG }; | |||||||||||||||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | ▶ | if (exists $ENV{ XDG_CONFIG_HOME }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||||||
| 312 | $cf = File::Spec->catfile( | ||||||||||||||||||||||||||||||||||||||||||
| 313 | $ENV{ XDG_CONFIG_HOME }, | ||||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | $PRGNAM, | |||||||||||||||||||||||||||||||||||||||||
| 315 | "$PRGNAM.conf" | ||||||||||||||||||||||||||||||||||||||||||
| 316 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 317 | 0 | ▶ | return $cf if -f $cf; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||||||||||||
| 319 | $cf = File::Spec->catfile( | ||||||||||||||||||||||||||||||||||||||||||
| 320 | $ENV{ XDG_CONFIG_HOME }, | ||||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | "$PRGNAM.conf" | |||||||||||||||||||||||||||||||||||||||||
| 322 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 323 | 0 | ▶ | return $cf if -f $cf; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||||||||||||
| 325 | } | ||||||||||||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||||||||||||
| 327 | 0 | ▶ | if (-d $DOT_CONFIG) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||||||||||||
| 329 | 0 | $cf = File::Spec->catfile( | |||||||||||||||||||||||||||||||||||||||||
| 330 | $DOT_CONFIG, | ||||||||||||||||||||||||||||||||||||||||||
| 331 | $PRGNAM, | ||||||||||||||||||||||||||||||||||||||||||
| 332 | "$PRGNAM.conf" | ||||||||||||||||||||||||||||||||||||||||||
| 333 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 334 | 0 | ▶ | return $cf if -f $cf; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | $cf = File::Spec->catfile( | |||||||||||||||||||||||||||||||||||||||||
| 337 | $DOT_CONFIG, | ||||||||||||||||||||||||||||||||||||||||||
| 338 | "$PRGNAM.conf" | ||||||||||||||||||||||||||||||||||||||||||
| 339 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | ▶ | return $cf if -f $cf; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||||||
| 342 | } | ||||||||||||||||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | $cf = File::Spec->catfile(home, ".$PRGNAM.conf"); | |||||||||||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | ▶ | return $cf if -f $cf; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||||||||||||||||
| 348 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||||||||||||||
| 350 | } | ||||||||||||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||||||||||||
| 352 | 0 | ▶ | sub _default_feeds { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_default_feeds: not called CC=9 SCAR=45.0
| |||||||||||||||||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||||||||||||||||
| 354 | 0 | my $ff; | |||||||||||||||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||||||||||||||||
| 356 | 0 | ▶ | if (exists $ENV{ NOSS_FEEDS }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 357 | 0 | return $ENV{ NOSS_FEEDS }; | |||||||||||||||||||||||||||||||||||||||||
| 358 | } | ||||||||||||||||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||||||||||||||||
| 360 | 0 | ▶ | if (exists $ENV{ XDG_CONFIG_HOME }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||||||||||||
| 362 | $ff = File::Spec->catfile( | ||||||||||||||||||||||||||||||||||||||||||
| 363 | $ENV{ XDG_CONFIG_HOME }, | ||||||||||||||||||||||||||||||||||||||||||
| 364 | 0 | $PRGNAM, | |||||||||||||||||||||||||||||||||||||||||
| 365 | "$PRGNAM.feeds" | ||||||||||||||||||||||||||||||||||||||||||
| 366 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | ▶ | return $ff if -f $ff; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||||||||||||||
| 369 | $ff = File::Spec->catfile( | ||||||||||||||||||||||||||||||||||||||||||
| 370 | $ENV{ XDG_CONFIG_HOME }, | ||||||||||||||||||||||||||||||||||||||||||
| 371 | 0 | "$PRGNAM.feeds" | |||||||||||||||||||||||||||||||||||||||||
| 372 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 373 | 0 | ▶ | return $ff if -f $ff; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||||||||||||||||
| 375 | } | ||||||||||||||||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | ▶ | if (-d $DOT_CONFIG) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||||||||||||||||
| 379 | 0 | $ff = File::Spec->catfile( | |||||||||||||||||||||||||||||||||||||||||
| 380 | $DOT_CONFIG, | ||||||||||||||||||||||||||||||||||||||||||
| 381 | $PRGNAM, | ||||||||||||||||||||||||||||||||||||||||||
| 382 | "$PRGNAM.feeds" | ||||||||||||||||||||||||||||||||||||||||||
| 383 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 384 | 0 | ▶ | return $ff if -f $ff; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||||||||||||||||
| 386 | 0 | $ff = File::Spec->catfile( | |||||||||||||||||||||||||||||||||||||||||
| 387 | $DOT_CONFIG, | ||||||||||||||||||||||||||||||||||||||||||
| 388 | "$PRGNAM.feeds" | ||||||||||||||||||||||||||||||||||||||||||
| 389 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 390 | 0 | ▶ | return $ff if -f $ff; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||||||||||||||||
| 392 | } | ||||||||||||||||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||||||||||||||||
| 394 | 0 | $ff = File::Spec->catfile(home, ".$PRGNAM.feeds"); | |||||||||||||||||||||||||||||||||||||||||
| 395 | 0 | ▶ | return $ff if -f $ff; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||||||||||||
| 397 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||||||||||||||||
| 399 | } | ||||||||||||||||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||||||||||||||||
| 401 | 0 | ▶ | sub _read_config { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_read_config: not called CC=72 SCAR=85.7
| |||||||||||||||||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||||||||||||||||
| 403 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||||||||||||||||
| 405 | 0 | my $cd = dirname(File::Spec->rel2abs($self->{ ConfFile })); | |||||||||||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||||||||||||
| 407 | open my $fh, '<', $self->{ ConfFile } | ||||||||||||||||||||||||||||||||||||||||||
| 408 | 0 | ▶ | or die "Failed to open $self->{ ConfFile } for reading: $!\n"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 409 | 0 | my $slurp = do { local $/ = undef; readline $fh }; | |||||||||||||||||||||||||||||||||||||||||
| 410 | 0 | close $fh; | |||||||||||||||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||||||||||||||||
| 412 | 0 | my $json_obj = JSON->new->relaxed; | |||||||||||||||||||||||||||||||||||||||||
| 413 | 0 | my $json = $json_obj->decode($slurp); | |||||||||||||||||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||||||||||||||||
| 415 | 0 | ▶ | unless (ref $json eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 416 | 0 | die "$self->{ ConfFile } is not a valid $PRGNAM configuration file\n"; | |||||||||||||||||||||||||||||||||||||||||
| 417 | } | ||||||||||||||||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||||||||||||||||
| 419 | 0 | ▶ | if (defined $json->{ feeds }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 420 | 0 | ▶ | if (not ref $json->{ feeds }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 421 | 0 | my $p = $json->{ feeds } =~ s/^~/@{[ home ]}/r; | |||||||||||||||||||||||||||||||||||||||||
| 422 | $self->{ FeedFile } //= | ||||||||||||||||||||||||||||||||||||||||||
| 423 | File::Spec->file_name_is_absolute($p) | ||||||||||||||||||||||||||||||||||||||||||
| 424 | ? $json->{ feeds } | ||||||||||||||||||||||||||||||||||||||||||
| 425 | 0 | ▶ | : File::Spec->catfile($cd, $p); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->{"FeedFile"} //= "File::Spec"->file_name_is_absolute($p) ? $json->{"feeds"} : "File::Spec"->catfile($cd, $p)
MC/DC0%0/2
$self->{"FeedFile"} //= "File::Spec"->file_name_is_absolute($p) ? $json->{"feeds"} : "File::Spec"->catfile($cd, $p)
$self->{"FeedFile"}
"File::Spec"->file_name_is_absolute($p) ? $json->{"feeds"} : "File::Spec"->catfile($cd, $p)
Truth table0%0/3
A //= B
A= $self->{"FeedFile"}B= "File::Spec"->file_name_is_absolute($p) ? $json->{"feeds"} : "File::Spec"->catfile($cd, $p)
| |||||||||||||||||||||||||||||||||||||||||||
| 426 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 427 | 0 | warn "'feeds' is not a string, ignoring\n"; | |||||||||||||||||||||||||||||||||||||||||
| 428 | } | ||||||||||||||||||||||||||||||||||||||||||
| 429 | } | ||||||||||||||||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||||||||||||||||
| 431 | 0 | ▶ | if (defined $json->{ data }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 432 | 0 | ▶ | if (not ref $json->{ data }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 433 | 0 | my $p = $json->{ data } =~ s/^~/@{[ home ]}/r; | |||||||||||||||||||||||||||||||||||||||||
| 434 | $self->{ DataDir } //= | ||||||||||||||||||||||||||||||||||||||||||
| 435 | File::Spec->file_name_is_absolute($p) | ||||||||||||||||||||||||||||||||||||||||||
| 436 | ? $json->{ data } | ||||||||||||||||||||||||||||||||||||||||||
| 437 | 0 | ▶ | : File::Spec->catfile($cd, $p); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->{"DataDir"} //= "File::Spec"->file_name_is_absolute($p) ? $json->{"data"} : "File::Spec"->catfile($cd, $p)
MC/DC0%0/2
$self->{"DataDir"} //= "File::Spec"->file_name_is_absolute($p) ? $json->{"data"} : "File::Spec"->catfile($cd, $p)
$self->{"DataDir"}
"File::Spec"->file_name_is_absolute($p) ? $json->{"data"} : "File::Spec"->catfile($cd, $p)
Truth table0%0/3
A //= B
A= $self->{"DataDir"}B= "File::Spec"->file_name_is_absolute($p) ? $json->{"data"} : "File::Spec"->catfile($cd, $p)
| |||||||||||||||||||||||||||||||||||||||||||
| 438 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 439 | 0 | warn "'data' is not a string, ignoring\n"; | |||||||||||||||||||||||||||||||||||||||||
| 440 | } | ||||||||||||||||||||||||||||||||||||||||||
| 441 | } | ||||||||||||||||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||||||||||||||||
| 443 | 0 | ▶ | if (defined $json->{ downloads }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 444 | 0 | ▶ | if ($json->{ downloads } =~ /^\d+$/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 445 | 0 | ▶ | $self->{ Forks } //= $json->{ downloads }; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->{"Forks"} //= $json->{"downloads"}
MC/DC0%0/2
$self->{"Forks"} //= $json->{"downloads"}
$self->{"Forks"}
$json->{"downloads"}
Truth table0%0/3
A //= B
A= $self->{"Forks"}B= $json->{"downloads"}
| |||||||||||||||||||||||||||||||||||||||||||
| 446 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 447 | 0 | warn "'downloads' ($json->{ downloads }) is not an integar, ignoring\n"; | |||||||||||||||||||||||||||||||||||||||||
| 448 | } | ||||||||||||||||||||||||||||||||||||||||||
| 449 | } | ||||||||||||||||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||||||||||||||||
| 451 | 0 | ▶ | if (defined $json->{ pager }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 452 | 0 | ▶ | if (not ref $self->{ pager }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 453 | 0 | ▶ | $self->{ Pager } //= $json->{ pager }; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->{"Pager"} //= $json->{"pager"}
MC/DC0%0/2
$self->{"Pager"} //= $json->{"pager"}
$self->{"Pager"}
$json->{"pager"}
Truth table0%0/3
A //= B
A= $self->{"Pager"}B= $json->{"pager"}
| |||||||||||||||||||||||||||||||||||||||||||
| 454 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 455 | 0 | warn "'pager' is not a string, ignoring\n"; | |||||||||||||||||||||||||||||||||||||||||
| 456 | } | ||||||||||||||||||||||||||||||||||||||||||
| 457 | } | ||||||||||||||||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||||||||||||||||
| 459 | 0 | ▶ | if (defined $json->{ browser }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 460 | 0 | ▶ | if (not ref $self->{ browser }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 461 | 0 | ▶ | $self->{ Browser } //= $json->{ browser }; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->{"Browser"} //= $json->{"browser"}
MC/DC0%0/2
$self->{"Browser"} //= $json->{"browser"}
$self->{"Browser"}
$json->{"browser"}
Truth table0%0/3
A //= B
A= $self->{"Browser"}B= $json->{"browser"}
| |||||||||||||||||||||||||||||||||||||||||||
| 462 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 463 | 0 | warn "'browser' is not a string, ignoring\n"; | |||||||||||||||||||||||||||||||||||||||||
| 464 | } | ||||||||||||||||||||||||||||||||||||||||||
| 465 | } | ||||||||||||||||||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||||||||||||||||
| 467 | 0 | ▶ | if (defined $json->{ limit_rate }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 468 | 0 | ▶ | if ($self->{ RateLimit } =~ $RATE_RX) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 469 | 0 | ▶ | $self->{ RateLimit } //= $json->{ limit_rate }; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->{"RateLimit"} //= $json->{"limit_rate"}
MC/DC0%0/2
$self->{"RateLimit"} //= $json->{"limit_rate"}
$self->{"RateLimit"}
$json->{"limit_rate"}
Truth table0%0/3
A //= B
A= $self->{"RateLimit"}B= $json->{"limit_rate"}
| |||||||||||||||||||||||||||||||||||||||||||
| 470 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 471 | 0 | warn "limit_rate' ($json->{ limit_rate }) is not a valid speed, ignoring\n"; | |||||||||||||||||||||||||||||||||||||||||
| 472 | } | ||||||||||||||||||||||||||||||||||||||||||
| 473 | } | ||||||||||||||||||||||||||||||||||||||||||
| 474 | |||||||||||||||||||||||||||||||||||||||||||
| 475 | 0 | ▶ | if (defined $json->{ user_agent }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 476 | 0 | ▶ | if (ref $json->{ user_agent }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 477 | 0 | warn "'user_agent' is not a string, ignoring\n"; | |||||||||||||||||||||||||||||||||||||||||
| 478 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 479 | 0 | ▶ | $self->{ UserAgent } //= $json->{ user_agent }; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->{"UserAgent"} //= $json->{"user_agent"}
MC/DC0%0/2
$self->{"UserAgent"} //= $json->{"user_agent"}
$self->{"UserAgent"}
$json->{"user_agent"}
Truth table0%0/3
A //= B
A= $self->{"UserAgent"}B= $json->{"user_agent"}
| |||||||||||||||||||||||||||||||||||||||||||
| 480 | } | ||||||||||||||||||||||||||||||||||||||||||
| 481 | } | ||||||||||||||||||||||||||||||||||||||||||
| 482 | |||||||||||||||||||||||||||||||||||||||||||
| 483 | 0 | ▶ | if (defined $json->{ timeout }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 484 | 0 | ▶ | if ($json->{ timeout } =~ /^\d+(\.\d+)?$/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 485 | 0 | ▶ | $self->{ Timeout } //= $json->{ timeout }; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->{"Timeout"} //= $json->{"timeout"}
MC/DC0%0/2
$self->{"Timeout"} //= $json->{"timeout"}
$self->{"Timeout"}
$json->{"timeout"}
Truth table0%0/3
A //= B
A= $self->{"Timeout"}B= $json->{"timeout"}
| |||||||||||||||||||||||||||||||||||||||||||
| 486 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 487 | 0 | warn "'timeout' ($json->{ timeout }) is not numerical, ignoring\n"; | |||||||||||||||||||||||||||||||||||||||||
| 488 | } | ||||||||||||||||||||||||||||||||||||||||||
| 489 | } | ||||||||||||||||||||||||||||||||||||||||||
| 490 | |||||||||||||||||||||||||||||||||||||||||||
| 491 | 0 | ▶ | if (defined $json->{ proxy }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 492 | 0 | ▶ | if (ref $json->{ proxy }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 493 | 0 | warn "'proxy' is not a string, ignoring\n"; | |||||||||||||||||||||||||||||||||||||||||
| 494 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 495 | 0 | ▶ | $self->{ Proxy } //= $json->{ proxy }; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->{"Proxy"} //= $json->{"proxy"}
MC/DC0%0/2
$self->{"Proxy"} //= $json->{"proxy"}
$self->{"Proxy"}
$json->{"proxy"}
Truth table0%0/3
A //= B
A= $self->{"Proxy"}B= $json->{"proxy"}
| |||||||||||||||||||||||||||||||||||||||||||
| 496 | } | ||||||||||||||||||||||||||||||||||||||||||
| 497 | } | ||||||||||||||||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||||||||||||||||
| 499 | 0 | ▶ | if (defined $json->{ proxy_user }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 500 | 0 | ▶ | if ($json->{ proxy_user } =~ /^[^:]+:[^:]+$/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 501 | 0 | ▶ | $self->{ ProxyUser } //= $json->{ proxy_user }; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->{"ProxyUser"} //= $json->{"proxy_user"}
MC/DC0%0/2
$self->{"ProxyUser"} //= $json->{"proxy_user"}
$self->{"ProxyUser"}
$json->{"proxy_user"}
Truth table0%0/3
A //= B
A= $self->{"ProxyUser"}B= $json->{"proxy_user"}
| |||||||||||||||||||||||||||||||||||||||||||
| 502 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 503 | 0 | warn "'proxy_user' ($json->{ proxy_user }) is not a valid proxy user string, ignoring\n"; | |||||||||||||||||||||||||||||||||||||||||
| 504 | } | ||||||||||||||||||||||||||||||||||||||||||
| 505 | } | ||||||||||||||||||||||||||||||||||||||||||
| 506 | |||||||||||||||||||||||||||||||||||||||||||
| 507 | 0 | ▶ | if (defined $json->{ sort }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 508 | 0 | ▶ | if (exists $VALID_SORTS{ $json->{ sort } }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 509 | 0 | ▶ | $self->{ Sort } //= $json->{ sort }; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->{"Sort"} //= $json->{"sort"}
MC/DC0%0/2
$self->{"Sort"} //= $json->{"sort"}
$self->{"Sort"}
$json->{"sort"}
Truth table0%0/3
A //= B
A= $self->{"Sort"}B= $json->{"sort"}
| |||||||||||||||||||||||||||||||||||||||||||
| 510 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 511 | 0 | warn sprintf "'sort' must be one of the following: %s\n", join(', ', sort keys %VALID_SORTS); | |||||||||||||||||||||||||||||||||||||||||
| 512 | } | ||||||||||||||||||||||||||||||||||||||||||
| 513 | } | ||||||||||||||||||||||||||||||||||||||||||
| 514 | |||||||||||||||||||||||||||||||||||||||||||
| 515 | 0 | ▶ | if (defined $json->{ line_width }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 516 | 0 | ▶ | if ($json->{ line_width } =~ /^\d+$/ and $json->{ line_width } > 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$json->{"line_width"} =~ /^\d+$/u and $json->{"line_width"} > 0
MC/DC0%0/2
$json->{"line_width"} =~ /^\d+$/u and $json->{"line_width"} > 0
$json->{"line_width"} =~ /^\d+$/u
$json->{"line_width"} > 0
Truth table0%0/3
A and B
A= $json->{"line_width"} =~ /^\d+$/uB= $json->{"line_width"} > 0
| |||||||||||||||||||||||||||||||||||||||||||
| 517 | 0 | ▶ | $self->{ LineWidth } //= $json->{ line_width }; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->{"LineWidth"} //= $json->{"line_width"}
MC/DC0%0/2
$self->{"LineWidth"} //= $json->{"line_width"}
$self->{"LineWidth"}
$json->{"line_width"}
Truth table0%0/3
A //= B
A= $self->{"LineWidth"}B= $json->{"line_width"}
| |||||||||||||||||||||||||||||||||||||||||||
| 518 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 519 | 0 | warn "'line_width' must be an integar greater than 0, ignoring\n"; | |||||||||||||||||||||||||||||||||||||||||
| 520 | } | ||||||||||||||||||||||||||||||||||||||||||
| 521 | } | ||||||||||||||||||||||||||||||||||||||||||
| 522 | |||||||||||||||||||||||||||||||||||||||||||
| 523 | 0 | ▶ | if (defined $json->{ list_format }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 524 | 0 | ▶ | if (ref $json->{ list_format }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 525 | 0 | warn "'list_format' is not a format string, ignoring\n"; | |||||||||||||||||||||||||||||||||||||||||
| 526 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 527 | 0 | ▶ | $self->{ ListFmt } //= $json->{ list_format }; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->{"ListFmt"} //= $json->{"list_format"}
MC/DC0%0/2
$self->{"ListFmt"} //= $json->{"list_format"}
$self->{"ListFmt"}
$json->{"list_format"}
Truth table0%0/3
A //= B
A= $self->{"ListFmt"}B= $json->{"list_format"}
| |||||||||||||||||||||||||||||||||||||||||||
| 528 | } | ||||||||||||||||||||||||||||||||||||||||||
| 529 | } | ||||||||||||||||||||||||||||||||||||||||||
| 530 | |||||||||||||||||||||||||||||||||||||||||||
| 531 | 0 | ▶ | if (defined $json->{ read_format }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 532 | 0 | ▶ | if (ref $json->{ read_format }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 533 | 0 | warn "'read_format' is not a format string, ignoring\n"; | |||||||||||||||||||||||||||||||||||||||||
| 534 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 535 | 0 | ▶ | $self->{ ReadFmt } //= $json->{ read_format }; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->{"ReadFmt"} //= $json->{"read_format"}
MC/DC0%0/2
$self->{"ReadFmt"} //= $json->{"read_format"}
$self->{"ReadFmt"}
$json->{"read_format"}
Truth table0%0/3
A //= B
A= $self->{"ReadFmt"}B= $json->{"read_format"}
| |||||||||||||||||||||||||||||||||||||||||||
| 536 | } | ||||||||||||||||||||||||||||||||||||||||||
| 537 | } | ||||||||||||||||||||||||||||||||||||||||||
| 538 | |||||||||||||||||||||||||||||||||||||||||||
| 539 | 0 | ▶ | if (defined $json->{ post_format }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 540 | 0 | ▶ | if (ref $json->{ post_format }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 541 | 0 | warn "'post_format' is not a format string, ignoring\n"; | |||||||||||||||||||||||||||||||||||||||||
| 542 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 543 | 0 | ▶ | $self->{ PostFmt } //= $json->{ post_format }; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->{"PostFmt"} //= $json->{"post_format"}
MC/DC0%0/2
$self->{"PostFmt"} //= $json->{"post_format"}
$self->{"PostFmt"}
$json->{"post_format"}
Truth table0%0/3
A //= B
A= $self->{"PostFmt"}B= $json->{"post_format"}
| |||||||||||||||||||||||||||||||||||||||||||
| 544 | } | ||||||||||||||||||||||||||||||||||||||||||
| 545 | } | ||||||||||||||||||||||||||||||||||||||||||
| 546 | |||||||||||||||||||||||||||||||||||||||||||
| 547 | 0 | ▶ | if (defined $json->{ feeds_format }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 548 | 0 | ▶ | if (ref $json->{ feeds_format }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 549 | 0 | warn "'feeds_format' is not a format string, ignoring\n"; | |||||||||||||||||||||||||||||||||||||||||
| 550 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 551 | 0 | ▶ | $self->{ FeedsFmt } //= $json->{ feeds_fmt }; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->{"FeedsFmt"} //= $json->{"feeds_fmt"}
MC/DC0%0/2
$self->{"FeedsFmt"} //= $json->{"feeds_fmt"}
$self->{"FeedsFmt"}
$json->{"feeds_fmt"}
Truth table0%0/3
A //= B
A= $self->{"FeedsFmt"}B= $json->{"feeds_fmt"}
| |||||||||||||||||||||||||||||||||||||||||||
| 552 | } | ||||||||||||||||||||||||||||||||||||||||||
| 553 | } | ||||||||||||||||||||||||||||||||||||||||||
| 554 | |||||||||||||||||||||||||||||||||||||||||||
| 555 | 0 | ▶ | if (defined $json->{ autoclean }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 556 | 0 | ▶ | $self->{ AutoClean } //= !! $json->{ autoclean }; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->{"AutoClean"} //= !!$json->{"autoclean"}
MC/DC0%0/2
$self->{"AutoClean"} //= !!$json->{"autoclean"}
$self->{"AutoClean"}
!!$json->{"autoclean"}
Truth table0%0/3
A //= B
A= $self->{"AutoClean"}B= !!$json->{"autoclean"}
| |||||||||||||||||||||||||||||||||||||||||||
| 557 | } | ||||||||||||||||||||||||||||||||||||||||||
| 558 | |||||||||||||||||||||||||||||||||||||||||||
| 559 | 0 | ▶ | if (defined $json->{ time_format }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 560 | 0 | ▶ | if (ref $json->{ time_format }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 561 | 0 | warn "'time_format' is not a format string, ignoring\n"; | |||||||||||||||||||||||||||||||||||||||||
| 562 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 563 | 0 | ▶ | $self->{ TimeFmt } //= $json->{ time_format }; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->{"TimeFmt"} //= $json->{"time_format"}
MC/DC0%0/2
$self->{"TimeFmt"} //= $json->{"time_format"}
$self->{"TimeFmt"}
$json->{"time_format"}
Truth table0%0/3
A //= B
A= $self->{"TimeFmt"}B= $json->{"time_format"}
| |||||||||||||||||||||||||||||||||||||||||||
| 564 | } | ||||||||||||||||||||||||||||||||||||||||||
| 565 | } | ||||||||||||||||||||||||||||||||||||||||||
| 566 | |||||||||||||||||||||||||||||||||||||||||||
| 567 | 0 | ▶ | if (defined $json->{ list_limit }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 568 | 0 | ▶ | if ($json->{ list_limit } =~ /^-?\d+$/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 569 | 0 | ▶ | $self->{ ListLimit } //= $json->{ list_limit }; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->{"ListLimit"} //= $json->{"list_limit"}
MC/DC0%0/2
$self->{"ListLimit"} //= $json->{"list_limit"}
$self->{"ListLimit"}
$json->{"list_limit"}
Truth table0%0/3
A //= B
A= $self->{"ListLimit"}B= $json->{"list_limit"}
| |||||||||||||||||||||||||||||||||||||||||||
| 570 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 571 | 0 | warn "'list_limit' ($json->{ list_limit }) is not an integar, ignoring\n"; | |||||||||||||||||||||||||||||||||||||||||
| 572 | } | ||||||||||||||||||||||||||||||||||||||||||
| 573 | } | ||||||||||||||||||||||||||||||||||||||||||
| 574 | |||||||||||||||||||||||||||||||||||||||||||
| 575 | 0 | ▶ | if (defined $json->{ colors }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 576 | 0 | ▶ | if (ref $json->{ colors } ne 'HASH') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 577 | 0 | warn "'colors' is not a key-value map, ignoring\n"; | |||||||||||||||||||||||||||||||||||||||||
| 578 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 579 | 0 | for my $k (keys %{ $json->{ colors } }) { | |||||||||||||||||||||||||||||||||||||||||
| 580 | 0 | ▶ | if (not exists $self->{ ColorMap }{ $k }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 581 | 0 | warn "'$k' is not a valid color code, ignoring\n"; | |||||||||||||||||||||||||||||||||||||||||
| 582 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 583 | } | ||||||||||||||||||||||||||||||||||||||||||
| 584 | 0 | $self->{ ColorMap }{ $k } = $json->{ colors }{ $k }; | |||||||||||||||||||||||||||||||||||||||||
| 585 | } | ||||||||||||||||||||||||||||||||||||||||||
| 586 | } | ||||||||||||||||||||||||||||||||||||||||||
| 587 | } | ||||||||||||||||||||||||||||||||||||||||||
| 588 | |||||||||||||||||||||||||||||||||||||||||||
| 589 | 0 | ▶ | if (defined $json->{ list_unread_format }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 590 | 0 | ▶ | if (ref $json->{ list_unread_format }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 591 | 0 | warn "'list_unread_format' is not a format string, ignoring\n"; | |||||||||||||||||||||||||||||||||||||||||
| 592 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 593 | 0 | ▶ | $self->{ ListUnreadFmt } //= $json->{ list_unread_format }; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->{"ListUnreadFmt"} //= $json->{"list_unread_format"}
MC/DC0%0/2
$self->{"ListUnreadFmt"} //= $json->{"list_unread_format"}
$self->{"ListUnreadFmt"}
$json->{"list_unread_format"}
Truth table0%0/3
A //= B
A= $self->{"ListUnreadFmt"}B= $json->{"list_unread_format"}
| |||||||||||||||||||||||||||||||||||||||||||
| 594 | } | ||||||||||||||||||||||||||||||||||||||||||
| 595 | } | ||||||||||||||||||||||||||||||||||||||||||
| 596 | |||||||||||||||||||||||||||||||||||||||||||
| 597 | 0 | ▶ | if (defined $json->{ colored_output }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 598 | # If true, set to undef so that noss can automatically disable the use | ||||||||||||||||||||||||||||||||||||||||||
| 599 | # of color when not writing to a terminal. | ||||||||||||||||||||||||||||||||||||||||||
| 600 | 0 | ▶ | $self->{ UseColor } //= $json->{ colored_output } ? undef : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->{"UseColor"} //= $json->{"colored_output"} ? undef : 0
MC/DC0%0/2
$self->{"UseColor"} //= $json->{"colored_output"} ? undef : 0
$self->{"UseColor"}
$json->{"colored_output"} ? undef : 0
Truth table0%0/3
A //= B
A= $self->{"UseColor"}B= $json->{"colored_output"} ? undef : 0
| |||||||||||||||||||||||||||||||||||||||||||
| 601 | } | ||||||||||||||||||||||||||||||||||||||||||
| 602 | |||||||||||||||||||||||||||||||||||||||||||
| 603 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 604 | |||||||||||||||||||||||||||||||||||||||||||
| 605 | } | ||||||||||||||||||||||||||||||||||||||||||
| 606 | |||||||||||||||||||||||||||||||||||||||||||
| 607 | # Note to a confused future self: | ||||||||||||||||||||||||||||||||||||||||||
| 608 | # When adding a new feed parameter, the following locations should be updated: | ||||||||||||||||||||||||||||||||||||||||||
| 609 | # * This _feed_params subroutine | ||||||||||||||||||||||||||||||||||||||||||
| 610 | # * BaseConfig attributes | ||||||||||||||||||||||||||||||||||||||||||
| 611 | # * FeedConfig group attribute initialization | ||||||||||||||||||||||||||||||||||||||||||
| 612 | # * (Base|Feed|Group)Config documentation | ||||||||||||||||||||||||||||||||||||||||||
| 613 | # * FeedConfig tests | ||||||||||||||||||||||||||||||||||||||||||
| 614 | # * Feed configuration section in manual | ||||||||||||||||||||||||||||||||||||||||||
| 615 | 0 | ▶ | sub _feed_params { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_feed_params: not called CC=26 SCAR=65.5
| |||||||||||||||||||||||||||||||||||||||||||
| 616 | |||||||||||||||||||||||||||||||||||||||||||
| 617 | 0 | my ($ref) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 618 | |||||||||||||||||||||||||||||||||||||||||||
| 619 | 0 | my %params; | |||||||||||||||||||||||||||||||||||||||||
| 620 | |||||||||||||||||||||||||||||||||||||||||||
| 621 | 0 | ▶ | if (defined $ref->{ limit }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 622 | 0 | ▶ | if ($ref->{ limit } =~ /^\d+$/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 623 | 0 | $params{ limit } = $ref->{ limit }; | |||||||||||||||||||||||||||||||||||||||||
| 624 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 625 | 0 | warn "'limit' ($ref->{ limit }) is not an integar, ignoring\n"; | |||||||||||||||||||||||||||||||||||||||||
| 626 | } | ||||||||||||||||||||||||||||||||||||||||||
| 627 | } | ||||||||||||||||||||||||||||||||||||||||||
| 628 | |||||||||||||||||||||||||||||||||||||||||||
| 629 | 0 | ▶ | if (defined $ref->{ respect_skip }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 630 | 0 | $params{ respect_skip } = !! $ref->{ respect_skip }; | |||||||||||||||||||||||||||||||||||||||||
| 631 | } | ||||||||||||||||||||||||||||||||||||||||||
| 632 | |||||||||||||||||||||||||||||||||||||||||||
| 633 | 0 | ▶ | if (defined $ref->{ include_title }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 634 | 0 | ▶ | if (ref $ref->{ include_title } eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 635 | 0 | $params{ include_title } = [ map { _arg2rx($_) } @{ $ref->{ include_title } } ]; | |||||||||||||||||||||||||||||||||||||||||
| 636 | } elsif (not ref $ref->{ include_title }) { | ||||||||||||||||||||||||||||||||||||||||||
| 637 | 0 | $params{ include_title } = [ _arg2rx($ref->{ include_title }) ]; | |||||||||||||||||||||||||||||||||||||||||
| 638 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 639 | 0 | warn "'include_title' is not an array or string, ignoring\n"; | |||||||||||||||||||||||||||||||||||||||||
| 640 | } | ||||||||||||||||||||||||||||||||||||||||||
| 641 | } | ||||||||||||||||||||||||||||||||||||||||||
| 642 | |||||||||||||||||||||||||||||||||||||||||||
| 643 | 0 | ▶ | if (defined $ref->{ exclude_title }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 644 | 0 | ▶ | if (ref $ref->{ exclude_title } eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 645 | 0 | $params{ exclude_title } = [ map { _arg2rx($_) } @{ $ref->{ exclude_title } } ]; | |||||||||||||||||||||||||||||||||||||||||
| 646 | } elsif (not ref $ref->{ exclude_title }) { | ||||||||||||||||||||||||||||||||||||||||||
| 647 | 0 | $params{ exclude_title } = [ _arg2rx($ref->{ exclude_title }) ]; | |||||||||||||||||||||||||||||||||||||||||
| 648 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 649 | 0 | warn "'exclude_title' is not an array or string, ignoring\n"; | |||||||||||||||||||||||||||||||||||||||||
| 650 | } | ||||||||||||||||||||||||||||||||||||||||||
| 651 | } | ||||||||||||||||||||||||||||||||||||||||||
| 652 | |||||||||||||||||||||||||||||||||||||||||||
| 653 | 0 | ▶ | if (defined $ref->{ include_content }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 654 | 0 | ▶ | if (ref $ref->{ include_content } eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 655 | 0 | $params{ include_content } = [ map { _arg2rx($_) } @{ $ref->{ include_content } } ]; | |||||||||||||||||||||||||||||||||||||||||
| 656 | } elsif (not ref $ref->{ include_content }) { | ||||||||||||||||||||||||||||||||||||||||||
| 657 | 0 | $params{ include_content } = [ _arg2rx($ref->{ include_content }) ]; | |||||||||||||||||||||||||||||||||||||||||
| 658 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 659 | 0 | warn "'include_content' is not an array or string, ignoring\n"; | |||||||||||||||||||||||||||||||||||||||||
| 660 | } | ||||||||||||||||||||||||||||||||||||||||||
| 661 | } | ||||||||||||||||||||||||||||||||||||||||||
| 662 | |||||||||||||||||||||||||||||||||||||||||||
| 663 | 0 | ▶ | if (defined $ref->{ exclude_content }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 664 | 0 | ▶ | if (ref $ref->{ exclude_content } eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 665 | 0 | $params{ exclude_content } = [ map { _arg2rx($_) } @{ $ref->{ exclude_content } } ]; | |||||||||||||||||||||||||||||||||||||||||
| 666 | } elsif (not ref $ref->{ exclude_content }) { | ||||||||||||||||||||||||||||||||||||||||||
| 667 | 0 | $params{ exclude_content } = [ _arg2rx($ref->{ exclude_content }) ]; | |||||||||||||||||||||||||||||||||||||||||
| 668 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 669 | 0 | warn "'exclude_content' is not an array or string, ignoring\n"; | |||||||||||||||||||||||||||||||||||||||||
| 670 | } | ||||||||||||||||||||||||||||||||||||||||||
| 671 | } | ||||||||||||||||||||||||||||||||||||||||||
| 672 | |||||||||||||||||||||||||||||||||||||||||||
| 673 | 0 | ▶ | if (defined $ref->{ include_tags }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 674 | 0 | ▶ | if (ref $ref->{ include_tags } eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 675 | 0 | $params{ include_tags } = $ref->{ include_tags }; | |||||||||||||||||||||||||||||||||||||||||
| 676 | } elsif (not ref $ref->{ include_tags }) { | ||||||||||||||||||||||||||||||||||||||||||
| 677 | 0 | $params{ include_tags } = [ $ref->{ include_tags } ]; | |||||||||||||||||||||||||||||||||||||||||
| 678 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 679 | 0 | warn "'include_tags' is not an array or string, ignoring\n"; | |||||||||||||||||||||||||||||||||||||||||
| 680 | } | ||||||||||||||||||||||||||||||||||||||||||
| 681 | } | ||||||||||||||||||||||||||||||||||||||||||
| 682 | |||||||||||||||||||||||||||||||||||||||||||
| 683 | 0 | ▶ | if (defined $ref->{ exclude_tags }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 684 | 0 | ▶ | if (ref $ref->{ exclude_tags } eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 685 | 0 | $params{ exclude_tags } = $ref->{ exclude_tags }; | |||||||||||||||||||||||||||||||||||||||||
| 686 | } elsif (not ref $ref->{ exclude_tags }) { | ||||||||||||||||||||||||||||||||||||||||||
| 687 | 0 | $params{ exclude_tags } = [ $ref->{ exclude_tags } ]; | |||||||||||||||||||||||||||||||||||||||||
| 688 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 689 | 0 | warn "'exclude_tags' is not an array or string, ignoring\n"; | |||||||||||||||||||||||||||||||||||||||||
| 690 | } | ||||||||||||||||||||||||||||||||||||||||||
| 691 | } | ||||||||||||||||||||||||||||||||||||||||||
| 692 | |||||||||||||||||||||||||||||||||||||||||||
| 693 | 0 | ▶ | if (defined $ref->{ autoread }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 694 | 0 | $params{ autoread } = !! $ref->{ autoread }; | |||||||||||||||||||||||||||||||||||||||||
| 695 | } | ||||||||||||||||||||||||||||||||||||||||||
| 696 | |||||||||||||||||||||||||||||||||||||||||||
| 697 | 0 | ▶ | if (defined $ref->{ default_update }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 698 | 0 | $params{ default_update } = !! $ref->{ default_update }; | |||||||||||||||||||||||||||||||||||||||||
| 699 | } | ||||||||||||||||||||||||||||||||||||||||||
| 700 | |||||||||||||||||||||||||||||||||||||||||||
| 701 | 0 | ▶ | if (defined $ref->{ hidden }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 702 | 0 | $params{ hidden } = !! $ref->{ hidden }; | |||||||||||||||||||||||||||||||||||||||||
| 703 | } | ||||||||||||||||||||||||||||||||||||||||||
| 704 | |||||||||||||||||||||||||||||||||||||||||||
| 705 | 0 | ▶ | if (defined $ref->{ open }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 706 | 0 | $params{ open } = $ref->{ open }; | |||||||||||||||||||||||||||||||||||||||||
| 707 | } | ||||||||||||||||||||||||||||||||||||||||||
| 708 | |||||||||||||||||||||||||||||||||||||||||||
| 709 | 0 | return %params; | |||||||||||||||||||||||||||||||||||||||||
| 710 | |||||||||||||||||||||||||||||||||||||||||||
| 711 | } | ||||||||||||||||||||||||||||||||||||||||||
| 712 | |||||||||||||||||||||||||||||||||||||||||||
| 713 | 0 | ▶ | sub _read_feed_file { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_read_feed_file: not called CC=27 SCAR=66.3
| |||||||||||||||||||||||||||||||||||||||||||
| 714 | |||||||||||||||||||||||||||||||||||||||||||
| 715 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 716 | |||||||||||||||||||||||||||||||||||||||||||
| 717 | open my $fh, '<', $self->{ FeedFile } | ||||||||||||||||||||||||||||||||||||||||||
| 718 | 0 | ▶ | or die "Failed to open $self->{ FeedFile } for reading: $!\n"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 719 | 0 | my $slurp = do { local $/ = undef; readline $fh }; | |||||||||||||||||||||||||||||||||||||||||
| 720 | 0 | close $fh; | |||||||||||||||||||||||||||||||||||||||||
| 721 | |||||||||||||||||||||||||||||||||||||||||||
| 722 | 0 | my $json_obj = JSON->new->relaxed; | |||||||||||||||||||||||||||||||||||||||||
| 723 | 0 | my $json = $json_obj->decode($slurp); | |||||||||||||||||||||||||||||||||||||||||
| 724 | |||||||||||||||||||||||||||||||||||||||||||
| 725 | 0 | ▶ | unless (ref $json eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 726 | 0 | die "$self->{ FeedFile } is not a valid feed file\n"; | |||||||||||||||||||||||||||||||||||||||||
| 727 | } | ||||||||||||||||||||||||||||||||||||||||||
| 728 | |||||||||||||||||||||||||||||||||||||||||||
| 729 | 0 | ▶ | unless (exists $json->{ feeds }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 730 | 0 | die "Failed to read $self->{ FeedFile }: missing 'feeds' list\n"; | |||||||||||||||||||||||||||||||||||||||||
| 731 | } | ||||||||||||||||||||||||||||||||||||||||||
| 732 | |||||||||||||||||||||||||||||||||||||||||||
| 733 | 0 | my $feeds = $json->{ feeds }; | |||||||||||||||||||||||||||||||||||||||||
| 734 | 0 | ▶ | my $groups = $json->{ groups } // {}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$json->{"groups"} // {}
MC/DC0%0/1
$json->{"groups"} // {}
$json->{"groups"}
Truth table0%0/2
A
A= $json->{"groups"}
| |||||||||||||||||||||||||||||||||||||||||||
| 735 | 0 | ▶ | my $default = $json->{ default } // {}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$json->{"default"} // {}
MC/DC0%0/1
$json->{"default"} // {}
$json->{"default"}
Truth table0%0/2
A
A= $json->{"default"}
| |||||||||||||||||||||||||||||||||||||||||||
| 736 | |||||||||||||||||||||||||||||||||||||||||||
| 737 | 0 | ▶ | unless (ref $feeds eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 738 | 0 | die "Failed to read $self->{ FeedFile }: 'feeds' must be a key-value map\n"; | |||||||||||||||||||||||||||||||||||||||||
| 739 | } | ||||||||||||||||||||||||||||||||||||||||||
| 740 | |||||||||||||||||||||||||||||||||||||||||||
| 741 | 0 | ▶ | unless (ref $groups eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 742 | 0 | die "Failed to read $self->{ FeedFile }: 'groups' must be a key-value map\n"; | |||||||||||||||||||||||||||||||||||||||||
| 743 | } | ||||||||||||||||||||||||||||||||||||||||||
| 744 | |||||||||||||||||||||||||||||||||||||||||||
| 745 | 0 | ▶ | unless (ref $default eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 746 | 0 | die "Failed to read $self->{ FeedFile }: 'default' must be a key-value map\n"; | |||||||||||||||||||||||||||||||||||||||||
| 747 | } | ||||||||||||||||||||||||||||||||||||||||||
| 748 | |||||||||||||||||||||||||||||||||||||||||||
| 749 | 0 | for my $k (keys %$groups) { | |||||||||||||||||||||||||||||||||||||||||
| 750 | 0 | ▶ | unless ($k =~ /^\w+$/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 751 | 0 | warn "'$k' is not a valid feed group: name contains invalid characters, ignoring\n"; | |||||||||||||||||||||||||||||||||||||||||
| 752 | 0 | delete $groups->{ $k }; | |||||||||||||||||||||||||||||||||||||||||
| 753 | } | ||||||||||||||||||||||||||||||||||||||||||
| 754 | 0 | ▶ | if (exists $feeds->{ $k }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 755 | 0 | die "'$k' is both the name of a feed and group\n"; | |||||||||||||||||||||||||||||||||||||||||
| 756 | } | ||||||||||||||||||||||||||||||||||||||||||
| 757 | } | ||||||||||||||||||||||||||||||||||||||||||
| 758 | |||||||||||||||||||||||||||||||||||||||||||
| 759 | 0 | for my $k (keys %$feeds) { | |||||||||||||||||||||||||||||||||||||||||
| 760 | 0 | ▶ | unless ($k =~ /^\w+$/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 761 | 0 | warn "'$k' is not a valid feed name: contains invalid characters, ignoring\n"; | |||||||||||||||||||||||||||||||||||||||||
| 762 | 0 | delete $feeds->{ $k }; | |||||||||||||||||||||||||||||||||||||||||
| 763 | } | ||||||||||||||||||||||||||||||||||||||||||
| 764 | } | ||||||||||||||||||||||||||||||||||||||||||
| 765 | |||||||||||||||||||||||||||||||||||||||||||
| 766 | |||||||||||||||||||||||||||||||||||||||||||
| 767 | 0 | ▶ | if (%$default) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 768 | 0 | my %params = _feed_params($default); | |||||||||||||||||||||||||||||||||||||||||
| 769 | 0 | $self->{ DefaultGroup } = WWW::Noss::GroupConfig->new( | |||||||||||||||||||||||||||||||||||||||||
| 770 | name => ':all', | ||||||||||||||||||||||||||||||||||||||||||
| 771 | feeds => [ keys %$feeds ], | ||||||||||||||||||||||||||||||||||||||||||
| 772 | %params | ||||||||||||||||||||||||||||||||||||||||||
| 773 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 774 | } | ||||||||||||||||||||||||||||||||||||||||||
| 775 | |||||||||||||||||||||||||||||||||||||||||||
| 776 | 0 | for my $k (keys %$groups) { | |||||||||||||||||||||||||||||||||||||||||
| 777 | 0 | my $g = $groups->{ $k }; | |||||||||||||||||||||||||||||||||||||||||
| 778 | |||||||||||||||||||||||||||||||||||||||||||
| 779 | 0 | ▶ | if (ref $g eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 780 | 0 | $g = { feeds => $g }; | |||||||||||||||||||||||||||||||||||||||||
| 781 | } elsif (ref $g ne 'HASH') { | ||||||||||||||||||||||||||||||||||||||||||
| 782 | 0 | warn "'$k' is neither a feed list or key-value map, skipping\n"; | |||||||||||||||||||||||||||||||||||||||||
| 783 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 784 | } | ||||||||||||||||||||||||||||||||||||||||||
| 785 | |||||||||||||||||||||||||||||||||||||||||||
| 786 | 0 | ▶ | unless (ref $g->{ feeds } eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 787 | 0 | warn "'$k' group does not contain a feed list, skipping\n"; | |||||||||||||||||||||||||||||||||||||||||
| 788 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 789 | } | ||||||||||||||||||||||||||||||||||||||||||
| 790 | |||||||||||||||||||||||||||||||||||||||||||
| 791 | 0 | my %params = _feed_params($g); | |||||||||||||||||||||||||||||||||||||||||
| 792 | |||||||||||||||||||||||||||||||||||||||||||
| 793 | $self->{ Groups }{ $k } = WWW::Noss::GroupConfig->new( | ||||||||||||||||||||||||||||||||||||||||||
| 794 | name => $k, | ||||||||||||||||||||||||||||||||||||||||||
| 795 | feeds => $g->{ feeds }, | ||||||||||||||||||||||||||||||||||||||||||
| 796 | 0 | %params | |||||||||||||||||||||||||||||||||||||||||
| 797 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 798 | |||||||||||||||||||||||||||||||||||||||||||
| 799 | } | ||||||||||||||||||||||||||||||||||||||||||
| 800 | |||||||||||||||||||||||||||||||||||||||||||
| 801 | 0 | for my $k (keys %$feeds) { | |||||||||||||||||||||||||||||||||||||||||
| 802 | 0 | my $f = $feeds->{ $k }; | |||||||||||||||||||||||||||||||||||||||||
| 803 | |||||||||||||||||||||||||||||||||||||||||||
| 804 | 0 | ▶ | if (not ref $f and defined $f) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
not ref $f and defined $f
MC/DC0%0/2
not ref $f and defined $f
not ref $f
defined $f
Truth table0%0/3
not(A) and B
A= not ref $fB= defined $f
| |||||||||||||||||||||||||||||||||||||||||||
| 805 | 0 | $f = { feed => $f }; | |||||||||||||||||||||||||||||||||||||||||
| 806 | } elsif (ref $f ne 'HASH') { | ||||||||||||||||||||||||||||||||||||||||||
| 807 | 0 | warn "'$k' is neither a feed link or a key-value map, skipping\n"; | |||||||||||||||||||||||||||||||||||||||||
| 808 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 809 | } | ||||||||||||||||||||||||||||||||||||||||||
| 810 | |||||||||||||||||||||||||||||||||||||||||||
| 811 | 0 | ▶ | unless (exists $f->{ feed }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 812 | 0 | warn "'$k' feed does not contain a feed link, skipping\n"; | |||||||||||||||||||||||||||||||||||||||||
| 813 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 814 | } | ||||||||||||||||||||||||||||||||||||||||||
| 815 | |||||||||||||||||||||||||||||||||||||||||||
| 816 | 0 | ▶ | if (ref $f->{ feed } or not defined $f->{ feed }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $f->{"feed"} or not defined $f->{"feed"}
MC/DC0%0/2
ref $f->{"feed"} or not defined $f->{"feed"}
ref $f->{"feed"}
not defined $f->{"feed"}
Truth table0%0/3
A or not(B)
A= ref $f->{"feed"}B= not defined $f->{"feed"}
| |||||||||||||||||||||||||||||||||||||||||||
| 817 | 0 | warn "'$k' feed link is not a string, skipping\n"; | |||||||||||||||||||||||||||||||||||||||||
| 818 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 819 | } | ||||||||||||||||||||||||||||||||||||||||||
| 820 | |||||||||||||||||||||||||||||||||||||||||||
| 821 | 0 | my @groups = grep { $_->has_feed($k) } values %{ $self->{ Groups } }; | |||||||||||||||||||||||||||||||||||||||||
| 822 | |||||||||||||||||||||||||||||||||||||||||||
| 823 | 0 | my %params = _feed_params($f); | |||||||||||||||||||||||||||||||||||||||||
| 824 | |||||||||||||||||||||||||||||||||||||||||||
| 825 | $self->{ Feeds }{ $k } = WWW::Noss::FeedConfig->new( | ||||||||||||||||||||||||||||||||||||||||||
| 826 | name => $k, | ||||||||||||||||||||||||||||||||||||||||||
| 827 | feed => $f->{ feed }, | ||||||||||||||||||||||||||||||||||||||||||
| 828 | default => $self->{ DefaultGroup }, | ||||||||||||||||||||||||||||||||||||||||||
| 829 | groups => \@groups, | ||||||||||||||||||||||||||||||||||||||||||
| 830 | path => File::Spec->catfile($self->{ FeedDir }, "$k.feed"), | ||||||||||||||||||||||||||||||||||||||||||
| 831 | etag => File::Spec->catfile($self->{ EtagDir }, "$k.etag"), | ||||||||||||||||||||||||||||||||||||||||||
| 832 | 0 | retry_cache => File::Spec->catfile($self->{ RetryDir }, "$k.retry"), | |||||||||||||||||||||||||||||||||||||||||
| 833 | %params | ||||||||||||||||||||||||||||||||||||||||||
| 834 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 835 | |||||||||||||||||||||||||||||||||||||||||||
| 836 | } | ||||||||||||||||||||||||||||||||||||||||||
| 837 | |||||||||||||||||||||||||||||||||||||||||||
| 838 | 0 | ▶ | unless (%{ $self->{ Feeds } }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 839 | 0 | die "$PRGNAM found no feeds in $self->{ FeedFile }\n"; | |||||||||||||||||||||||||||||||||||||||||
| 840 | } | ||||||||||||||||||||||||||||||||||||||||||
| 841 | |||||||||||||||||||||||||||||||||||||||||||
| 842 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 843 | |||||||||||||||||||||||||||||||||||||||||||
| 844 | } | ||||||||||||||||||||||||||||||||||||||||||
| 845 | |||||||||||||||||||||||||||||||||||||||||||
| 846 | 0 | ▶ | sub _arg2rx { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_arg2rx: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 847 | |||||||||||||||||||||||||||||||||||||||||||
| 848 | 0 | my ($str) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 849 | |||||||||||||||||||||||||||||||||||||||||||
| 850 | 0 | ▶ | if ($str =~ /^\/(.*)\/$/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 851 | 0 | return qr/$1/i; | |||||||||||||||||||||||||||||||||||||||||
| 852 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 853 | 0 | return qr/\Q$str\E/i; | |||||||||||||||||||||||||||||||||||||||||
| 854 | } | ||||||||||||||||||||||||||||||||||||||||||
| 855 | |||||||||||||||||||||||||||||||||||||||||||
| 856 | } | ||||||||||||||||||||||||||||||||||||||||||
| 857 | |||||||||||||||||||||||||||||||||||||||||||
| 858 | 0 | ▶ | sub _fmt { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_fmt: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||||||||||||||||
| 859 | |||||||||||||||||||||||||||||||||||||||||||
| 860 | 0 | my ($fmt, $codes, $colors) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 861 | 0 | ▶ | $colors //= {}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$colors //= {}
MC/DC0%0/1
$colors //= {}
$colors
Truth table0%0/2
A
A= $colors
| |||||||||||||||||||||||||||||||||||||||||||
| 862 | |||||||||||||||||||||||||||||||||||||||||||
| 863 | 0 | ▶ | $fmt .= "\n" unless $fmt =~ /\n$/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 864 | |||||||||||||||||||||||||||||||||||||||||||
| 865 | 0 | my @subs; | |||||||||||||||||||||||||||||||||||||||||
| 866 | 0 | my $colored = 0; | |||||||||||||||||||||||||||||||||||||||||
| 867 | |||||||||||||||||||||||||||||||||||||||||||
| 868 | 0 | $fmt =~ s{(?<Fmt>%(?:[+\-]?\d+)?.)|(?<Color><$COLOR_CODE_RX>)}{ | |||||||||||||||||||||||||||||||||||||||||
| 869 | 0 | ▶ | if (defined $+{ Fmt }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 870 | 0 | my $code = substr $+{ Fmt }, 1; | |||||||||||||||||||||||||||||||||||||||||
| 871 | 0 | my $c = chop $code; | |||||||||||||||||||||||||||||||||||||||||
| 872 | 0 | ▶ | unless (exists $codes->{ $c }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 873 | 0 | die "'%$code$c' is not a valid formatting code\n"; | |||||||||||||||||||||||||||||||||||||||||
| 874 | } | ||||||||||||||||||||||||||||||||||||||||||
| 875 | 0 | push @subs, $codes->{ $c }; | |||||||||||||||||||||||||||||||||||||||||
| 876 | 0 | '%' . $code . 's'; | |||||||||||||||||||||||||||||||||||||||||
| 877 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 878 | 0 | my $code = substr $+{ Color }, 1, -1; | |||||||||||||||||||||||||||||||||||||||||
| 879 | 0 | ▶ | if (not exists $colors->{ $code }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 880 | 0 | $+{ Color }; | |||||||||||||||||||||||||||||||||||||||||
| 881 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 882 | 0 | $colored = 1; | |||||||||||||||||||||||||||||||||||||||||
| 883 | 0 | color($colors->{ $code }); | |||||||||||||||||||||||||||||||||||||||||
| 884 | } | ||||||||||||||||||||||||||||||||||||||||||
| 885 | } | ||||||||||||||||||||||||||||||||||||||||||
| 886 | }ge; | ||||||||||||||||||||||||||||||||||||||||||
| 887 | |||||||||||||||||||||||||||||||||||||||||||
| 888 | 0 | ▶ | if ($colored) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 889 | 0 | $fmt .= color('reset'); | |||||||||||||||||||||||||||||||||||||||||
| 890 | } | ||||||||||||||||||||||||||||||||||||||||||
| 891 | |||||||||||||||||||||||||||||||||||||||||||
| 892 | 0 | ▶ | return sub { sprintf $fmt, map { $_->($_[0]) } @subs }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 893 | |||||||||||||||||||||||||||||||||||||||||||
| 894 | } | ||||||||||||||||||||||||||||||||||||||||||
| 895 | |||||||||||||||||||||||||||||||||||||||||||
| 896 | 0 | ▶ | sub _rm_color_codes { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_rm_color_codes: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 897 | |||||||||||||||||||||||||||||||||||||||||||
| 898 | 0 | my ($str) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 899 | |||||||||||||||||||||||||||||||||||||||||||
| 900 | 0 | return $str =~ s/<$COLOR_CODE_RX>//gr; | |||||||||||||||||||||||||||||||||||||||||
| 901 | |||||||||||||||||||||||||||||||||||||||||||
| 902 | } | ||||||||||||||||||||||||||||||||||||||||||
| 903 | |||||||||||||||||||||||||||||||||||||||||||
| 904 | 0 | ▶ | sub err { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
err: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 905 | |||||||||||||||||||||||||||||||||||||||||||
| 906 | 0 | my ($self, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 907 | |||||||||||||||||||||||||||||||||||||||||||
| 908 | 0 | my $err = join '', @args; | |||||||||||||||||||||||||||||||||||||||||
| 909 | |||||||||||||||||||||||||||||||||||||||||||
| 910 | 0 | ▶ | if ($self->{ UseColor } and -t STDERR) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->{"UseColor"} and -t STDERR
MC/DC0%0/2
$self->{"UseColor"} and -t STDERR
$self->{"UseColor"}
-t STDERR
Truth table0%0/3
A and B
A= $self->{"UseColor"}B= -t STDERR
| |||||||||||||||||||||||||||||||||||||||||||
| 911 | 0 | warn colored($err, 'bold red') . "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 912 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 913 | 0 | warn "$err\n"; | |||||||||||||||||||||||||||||||||||||||||
| 914 | } | ||||||||||||||||||||||||||||||||||||||||||
| 915 | |||||||||||||||||||||||||||||||||||||||||||
| 916 | } | ||||||||||||||||||||||||||||||||||||||||||
| 917 | |||||||||||||||||||||||||||||||||||||||||||
| 918 | 0 | ▶ | sub _get_feed { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_feed: not called CC=21 SCAR=61.4
| |||||||||||||||||||||||||||||||||||||||||||
| 919 | |||||||||||||||||||||||||||||||||||||||||||
| 920 | 0 | my ($self, $feed) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 921 | |||||||||||||||||||||||||||||||||||||||||||
| 922 | 0 | ▶ | if ($feed->feed =~ /^file:\/\//) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 923 | |||||||||||||||||||||||||||||||||||||||||||
| 924 | 0 | my $f = $feed->feed =~ s/^file:\/\///r; | |||||||||||||||||||||||||||||||||||||||||
| 925 | |||||||||||||||||||||||||||||||||||||||||||
| 926 | 0 | $f =~ s/^~/@{[ home ]}/; | |||||||||||||||||||||||||||||||||||||||||
| 927 | |||||||||||||||||||||||||||||||||||||||||||
| 928 | 0 | ▶ | unless (File::Spec->file_name_is_absolute($f)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 929 | $f = File::Spec->catfile( | ||||||||||||||||||||||||||||||||||||||||||
| 930 | 0 | dirname($self->{ FeedFile }), | |||||||||||||||||||||||||||||||||||||||||
| 931 | $f | ||||||||||||||||||||||||||||||||||||||||||
| 932 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 933 | } | ||||||||||||||||||||||||||||||||||||||||||
| 934 | |||||||||||||||||||||||||||||||||||||||||||
| 935 | 0 | ▶ | copy($f, $feed->path) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 936 | or die sprintf "Failed to copy %s to %s: %s\n", $f, $feed->path, $!; | ||||||||||||||||||||||||||||||||||||||||||
| 937 | # Copy over access and mod times | ||||||||||||||||||||||||||||||||||||||||||
| 938 | 0 | utime((stat($f))[8, 9], $feed->path); | |||||||||||||||||||||||||||||||||||||||||
| 939 | |||||||||||||||||||||||||||||||||||||||||||
| 940 | 0 | return $feed->path; | |||||||||||||||||||||||||||||||||||||||||
| 941 | |||||||||||||||||||||||||||||||||||||||||||
| 942 | } elsif ($feed->feed =~ /^shell:\/\//) { | ||||||||||||||||||||||||||||||||||||||||||
| 943 | |||||||||||||||||||||||||||||||||||||||||||
| 944 | 0 | my $cmd = $feed->feed =~ s/^shell:\/\///r; | |||||||||||||||||||||||||||||||||||||||||
| 945 | |||||||||||||||||||||||||||||||||||||||||||
| 946 | 0 | ▶ | open my $fh, '>', $feed->path | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 947 | or die sprintf "Failed to open %s for writing: %s\n", $feed->path, $!; | ||||||||||||||||||||||||||||||||||||||||||
| 948 | |||||||||||||||||||||||||||||||||||||||||||
| 949 | # cd into feed file directory, so that shell command is ran from said | ||||||||||||||||||||||||||||||||||||||||||
| 950 | # directory. | ||||||||||||||||||||||||||||||||||||||||||
| 951 | 0 | my $cwd = cwd; | |||||||||||||||||||||||||||||||||||||||||
| 952 | |||||||||||||||||||||||||||||||||||||||||||
| 953 | chdir dirname($self->{ FeedFile }) | ||||||||||||||||||||||||||||||||||||||||||
| 954 | 0 | ▶ | or die "Failed to chdir to $self->{ FeedFile }: $!\n"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 955 | |||||||||||||||||||||||||||||||||||||||||||
| 956 | 0 | my $qx = qx/$cmd/; | |||||||||||||||||||||||||||||||||||||||||
| 957 | |||||||||||||||||||||||||||||||||||||||||||
| 958 | 0 | ▶ | unless ($? >> 8 == 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 959 | 0 | ▶ | chdir $cwd or die "Failed to chdir to $cwd: $!\n"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 960 | 0 | die "Failed to execute '$cmd'\n"; | |||||||||||||||||||||||||||||||||||||||||
| 961 | } | ||||||||||||||||||||||||||||||||||||||||||
| 962 | |||||||||||||||||||||||||||||||||||||||||||
| 963 | 0 | print { $fh } $qx; | |||||||||||||||||||||||||||||||||||||||||
| 964 | |||||||||||||||||||||||||||||||||||||||||||
| 965 | 0 | close $fh; | |||||||||||||||||||||||||||||||||||||||||
| 966 | |||||||||||||||||||||||||||||||||||||||||||
| 967 | 0 | ▶ | chdir $cwd or die "Failed to chdir to $cwd: $!\n"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 968 | |||||||||||||||||||||||||||||||||||||||||||
| 969 | 0 | return $feed->path; | |||||||||||||||||||||||||||||||||||||||||
| 970 | |||||||||||||||||||||||||||||||||||||||||||
| 971 | # Otherwise, just try to curl the URL | ||||||||||||||||||||||||||||||||||||||||||
| 972 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 973 | |||||||||||||||||||||||||||||||||||||||||||
| 974 | my ($rt, $resp, $head) = curl( | ||||||||||||||||||||||||||||||||||||||||||
| 975 | $feed->feed, | ||||||||||||||||||||||||||||||||||||||||||
| 976 | $feed->path, | ||||||||||||||||||||||||||||||||||||||||||
| 977 | verbose => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 978 | remote_time => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 979 | etag_save => $feed->etag, | ||||||||||||||||||||||||||||||||||||||||||
| 980 | limit_rate => $self->{ RateLimit }, | ||||||||||||||||||||||||||||||||||||||||||
| 981 | user_agent => $self->{ UserAgent }, | ||||||||||||||||||||||||||||||||||||||||||
| 982 | timeout => $self->{ Timeout }, | ||||||||||||||||||||||||||||||||||||||||||
| 983 | fail => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 984 | proxy => $self->{ Proxy }, | ||||||||||||||||||||||||||||||||||||||||||
| 985 | proxy_user => $self->{ ProxyUser }, | ||||||||||||||||||||||||||||||||||||||||||
| 986 | ( | ||||||||||||||||||||||||||||||||||||||||||
| 987 | 0 | ▶ | !$self->{ Unconditional } && -f $feed->path | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
not $self->{"Unconditional"} and -f $feed->path
MC/DC0%0/2
not $self->{"Unconditional"} and -f $feed->path
not $self->{"Unconditional"}
-f $feed->path
Truth table0%0/3
not(A) and B
A= not $self->{"Unconditional"}B= -f $feed->path
| |||||||||||||||||||||||||||||||||||||||||||
| 988 | ? ( | ||||||||||||||||||||||||||||||||||||||||||
| 989 | time_cond => $feed->path, | ||||||||||||||||||||||||||||||||||||||||||
| 990 | etag_compare => (-s $feed->etag ? $feed->etag : undef), | ||||||||||||||||||||||||||||||||||||||||||
| 991 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 992 | : () | ||||||||||||||||||||||||||||||||||||||||||
| 993 | ), | ||||||||||||||||||||||||||||||||||||||||||
| 994 | redirect => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 995 | compressed => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 996 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 997 | |||||||||||||||||||||||||||||||||||||||||||
| 998 | 0 | ▶ | if (defined $resp and $resp->[1] eq '429') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $resp and $resp->[1] eq 429
MC/DC0%0/2
defined $resp and $resp->[1] eq 429
defined $resp
$resp->[1] eq 429
Truth table0%0/3
A and B
A= defined $respB= $resp->[1] eq 429
| |||||||||||||||||||||||||||||||||||||||||||
| 999 | 0 | my $retry = $head->{ 'retry-after' }; | |||||||||||||||||||||||||||||||||||||||||
| 1000 | 0 | ▶ | if (defined $retry and $retry =~ /^\d+$/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $retry and $retry =~ /^\d+$/u
MC/DC0%0/2
defined $retry and $retry =~ /^\d+$/u
defined $retry
$retry =~ /^\d+$/u
Truth table0%0/3
A and B
A= defined $retryB= $retry =~ /^\d+$/u
| |||||||||||||||||||||||||||||||||||||||||||
| 1001 | 0 | $feed->set_retry($retry + time); | |||||||||||||||||||||||||||||||||||||||||
| 1002 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1003 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1004 | |||||||||||||||||||||||||||||||||||||||||||
| 1005 | 0 | ▶ | if ($rt != 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1006 | 0 | my $e; | |||||||||||||||||||||||||||||||||||||||||
| 1007 | 0 | ▶ | if (defined $resp and $resp->[1] =~ /^[45]/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $resp and $resp->[1] =~ /^[45]/u
MC/DC0%0/2
defined $resp and $resp->[1] =~ /^[45]/u
defined $resp
$resp->[1] =~ /^[45]/u
Truth table0%0/3
A and B
A= defined $respB= $resp->[1] =~ /^[45]/u
| |||||||||||||||||||||||||||||||||||||||||||
| 1008 | 0 | ▶ | $e = "$resp->[1] " . ($resp->[2] || http_status_string($resp->[1])); | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$resp->[2] || http_status_string($resp->[1])
MC/DC0%0/2
$resp->[2] || http_status_string($resp->[1])
$resp->[2]
http_status_string($resp->[1])
Truth table0%0/3
A || B
A= $resp->[2]B= http_status_string($resp->[1])
| |||||||||||||||||||||||||||||||||||||||||||
| 1009 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1010 | 0 | $e = curl_error($rt); | |||||||||||||||||||||||||||||||||||||||||
| 1011 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1012 | 0 | die "$e\n"; | |||||||||||||||||||||||||||||||||||||||||
| 1013 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1014 | |||||||||||||||||||||||||||||||||||||||||||
| 1015 | 0 | return $feed->path; | |||||||||||||||||||||||||||||||||||||||||
| 1016 | |||||||||||||||||||||||||||||||||||||||||||
| 1017 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1018 | |||||||||||||||||||||||||||||||||||||||||||
| 1019 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1020 | |||||||||||||||||||||||||||||||||||||||||||
| 1021 | 0 | ▶ | sub update { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
update: not called CC=30 SCAR=68.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1022 | |||||||||||||||||||||||||||||||||||||||||||
| 1023 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1024 | |||||||||||||||||||||||||||||||||||||||||||
| 1025 | # --hard implies --unconditional | ||||||||||||||||||||||||||||||||||||||||||
| 1026 | 0 | ▶ | if ($self->{ HardReload }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1027 | 0 | $self->{ Unconditional } = 1; | |||||||||||||||||||||||||||||||||||||||||
| 1028 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1029 | |||||||||||||||||||||||||||||||||||||||||||
| 1030 | 0 | my @updates; | |||||||||||||||||||||||||||||||||||||||||
| 1031 | |||||||||||||||||||||||||||||||||||||||||||
| 1032 | 0 | ▶ | if (@{ $self->{ Args } }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 1033 | 0 | my %feedset; | |||||||||||||||||||||||||||||||||||||||||
| 1034 | 0 | for my $arg (@{ $self->{ Args } }) { | |||||||||||||||||||||||||||||||||||||||||
| 1035 | 0 | ▶ | if (exists $self->{ Feeds }{ $arg }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 1036 | 0 | $feedset{ $arg } = 1; | |||||||||||||||||||||||||||||||||||||||||
| 1037 | } elsif ($self->{ Groups }{ $arg }) { | ||||||||||||||||||||||||||||||||||||||||||
| 1038 | 0 | for my $k (@{ $self->{ Groups }{ $arg }->feeds }) { | |||||||||||||||||||||||||||||||||||||||||
| 1039 | 0 | $feedset{ $k } = 1; | |||||||||||||||||||||||||||||||||||||||||
| 1040 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1041 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1042 | 0 | warn "'$arg' is not the name of a feed or feed group, skipping\n"; | |||||||||||||||||||||||||||||||||||||||||
| 1043 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1044 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1045 | 0 | @updates = keys %feedset; | |||||||||||||||||||||||||||||||||||||||||
| 1046 | } elsif ($self->{ NonDefaults }) { | ||||||||||||||||||||||||||||||||||||||||||
| 1047 | 0 | @updates = keys %{ $self->{ Feeds } }; | |||||||||||||||||||||||||||||||||||||||||
| 1048 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1049 | @updates = | ||||||||||||||||||||||||||||||||||||||||||
| 1050 | 0 | grep { $self->{ Feeds }{ $_ }->default_update } | |||||||||||||||||||||||||||||||||||||||||
| 1051 | 0 | keys %{ $self->{ Feeds } }; | |||||||||||||||||||||||||||||||||||||||||
| 1052 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1053 | |||||||||||||||||||||||||||||||||||||||||||
| 1054 | 0 | ▶ | if ($self->{ NewOnly }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1055 | 0 | @updates = grep { !$self->{ DB }->has_feed($_) } @updates; | |||||||||||||||||||||||||||||||||||||||||
| 1056 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1057 | |||||||||||||||||||||||||||||||||||||||||||
| 1058 | 0 | ▶ | unless (@updates) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1059 | 0 | die "No feeds can be updated\n"; | |||||||||||||||||||||||||||||||||||||||||
| 1060 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1061 | |||||||||||||||||||||||||||||||||||||||||||
| 1062 | 0 | @updates = map { [ $_, $self->{ DB }->skip($_) ] } @updates; | |||||||||||||||||||||||||||||||||||||||||
| 1063 | |||||||||||||||||||||||||||||||||||||||||||
| 1064 | 0 | my @change; | |||||||||||||||||||||||||||||||||||||||||
| 1065 | |||||||||||||||||||||||||||||||||||||||||||
| 1066 | 0 | my $forker = WWW::Noss::Forker->new($self->{ Forks }); | |||||||||||||||||||||||||||||||||||||||||
| 1067 | 0 | ▶ | $forker->run_on_finish(sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1068 | 0 | ▶ | push @change, ${ $_[2] } if defined $_[2]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1069 | 0 | }); | |||||||||||||||||||||||||||||||||||||||||
| 1070 | 0 | DOWNLOAD: for my $u (@updates) { | |||||||||||||||||||||||||||||||||||||||||
| 1071 | |||||||||||||||||||||||||||||||||||||||||||
| 1072 | 0 | ▶ | $forker->start and next DOWNLOAD; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1073 | |||||||||||||||||||||||||||||||||||||||||||
| 1074 | 0 | my ($name, $skip) = @$u; | |||||||||||||||||||||||||||||||||||||||||
| 1075 | 0 | my $feed = $self->{ Feeds }{ $name }; | |||||||||||||||||||||||||||||||||||||||||
| 1076 | |||||||||||||||||||||||||||||||||||||||||||
| 1077 | 0 | ▶ | if ($feed->respect_skip and !$self->{ Unconditional } and $skip) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$feed->respect_skip and not $self->{"Unconditional"} and $skip
$feed->respect_skip and not $self->{"Unconditional"}
MC/DC0%0/3
$feed->respect_skip and not $self->{"Unconditional"} and $skip
$feed->respect_skip
not $self->{"Unconditional"}
$skip
Truth table0%0/4
A and not(B) and C
A= $feed->respect_skipB= not $self->{"Unconditional"}C= $skip
| |||||||||||||||||||||||||||||||||||||||||||
| 1078 | 0 | say "Skipping $name"; | |||||||||||||||||||||||||||||||||||||||||
| 1079 | 0 | $forker->finish; | |||||||||||||||||||||||||||||||||||||||||
| 1080 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 1081 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1082 | |||||||||||||||||||||||||||||||||||||||||||
| 1083 | 0 | ▶ | if ($feed->respect_skip and !$self->{ Unconditional } and !$feed->can_we_retry) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$feed->respect_skip and not $self->{"Unconditional"} and not $feed->can_we_retry
$feed->respect_skip and not $self->{"Unconditional"}
MC/DC0%0/3
$feed->respect_skip and not $self->{"Unconditional"} and not $feed->can_we_retry
$feed->respect_skip
not $self->{"Unconditional"}
not $feed->can_we_retry
Truth table0%0/4
A and not(B) and not(C)
A= $feed->respect_skipB= not $self->{"Unconditional"}C= not $feed->can_we_retry
| |||||||||||||||||||||||||||||||||||||||||||
| 1084 | 0 | say "Skipping $name; performed too many requests"; | |||||||||||||||||||||||||||||||||||||||||
| 1085 | 0 | $forker->finish; | |||||||||||||||||||||||||||||||||||||||||
| 1086 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 1087 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1088 | |||||||||||||||||||||||||||||||||||||||||||
| 1089 | 0 | my $changed = 0; | |||||||||||||||||||||||||||||||||||||||||
| 1090 | |||||||||||||||||||||||||||||||||||||||||||
| 1091 | 0 | ▶ | my $oldmod = -f $feed->path ? (stat($feed->path))[9] : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1092 | |||||||||||||||||||||||||||||||||||||||||||
| 1093 | 0 | eval { $self->_get_feed($feed) }; | |||||||||||||||||||||||||||||||||||||||||
| 1094 | |||||||||||||||||||||||||||||||||||||||||||
| 1095 | 0 | ▶ | if ($@ ne '' or not -f $feed->path) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$@ ne "" or not -f $feed->path
MC/DC0%0/2
$@ ne "" or not -f $feed->path
$@ ne ""
not -f $feed->path
Truth table0%0/3
A or not(B)
A= $@ ne ""B= not -f $feed->path
| |||||||||||||||||||||||||||||||||||||||||||
| 1096 | 0 | ▶ | my $e = $@ || 'unknown error'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$@ || 'unknown error'
MC/DC0%0/1
$@ || 'unknown error'
$@
Truth table0%0/2
A
A= $@
| |||||||||||||||||||||||||||||||||||||||||||
| 1097 | 0 | chomp $e; | |||||||||||||||||||||||||||||||||||||||||
| 1098 | 0 | $self->err(sprintf "Failed to fetch %s: %s", $feed->feed, $e); | |||||||||||||||||||||||||||||||||||||||||
| 1099 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1100 | 0 | printf "Fetched %s\n", $feed->feed; | |||||||||||||||||||||||||||||||||||||||||
| 1101 | 0 | my $newmod = (stat($feed->path))[9]; | |||||||||||||||||||||||||||||||||||||||||
| 1102 | 0 | $changed = $newmod != $oldmod; | |||||||||||||||||||||||||||||||||||||||||
| 1103 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1104 | |||||||||||||||||||||||||||||||||||||||||||
| 1105 | 0 | ▶ | if ($self->{ HardReload }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1106 | 0 | $forker->finish(0, \$name); | |||||||||||||||||||||||||||||||||||||||||
| 1107 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1108 | 0 | ▶ | $forker->finish(0, $changed ? \$name : undef); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1109 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1110 | |||||||||||||||||||||||||||||||||||||||||||
| 1111 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1112 | |||||||||||||||||||||||||||||||||||||||||||
| 1113 | 0 | $forker->wait_all_children; | |||||||||||||||||||||||||||||||||||||||||
| 1114 | |||||||||||||||||||||||||||||||||||||||||||
| 1115 | 0 | my %feed_updates; | |||||||||||||||||||||||||||||||||||||||||
| 1116 | |||||||||||||||||||||||||||||||||||||||||||
| 1117 | 0 | for my $c (@change) { | |||||||||||||||||||||||||||||||||||||||||
| 1118 | |||||||||||||||||||||||||||||||||||||||||||
| 1119 | 0 | my $new = eval { | |||||||||||||||||||||||||||||||||||||||||
| 1120 | 0 | ▶ | if ($self->{ HardReload }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1121 | 0 | $self->{ DB }->del_feeds($c); | |||||||||||||||||||||||||||||||||||||||||
| 1122 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1123 | 0 | $self->{ DB }->load_feed($self->{ Feeds }{ $c }); | |||||||||||||||||||||||||||||||||||||||||
| 1124 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 1125 | |||||||||||||||||||||||||||||||||||||||||||
| 1126 | 0 | ▶ | if ($@ ne '') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1127 | 0 | my $e = $@; | |||||||||||||||||||||||||||||||||||||||||
| 1128 | 0 | chomp $e; | |||||||||||||||||||||||||||||||||||||||||
| 1129 | 0 | $self->err("Error updating $c: $e, skipping"); | |||||||||||||||||||||||||||||||||||||||||
| 1130 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 1131 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1132 | |||||||||||||||||||||||||||||||||||||||||||
| 1133 | 0 | ▶ | next if $new == 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1134 | 0 | $feed_updates{ $c } = $new; | |||||||||||||||||||||||||||||||||||||||||
| 1135 | |||||||||||||||||||||||||||||||||||||||||||
| 1136 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1137 | |||||||||||||||||||||||||||||||||||||||||||
| 1138 | 0 | ▶ | if (%feed_updates) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1139 | 0 | for my $k (sort keys %feed_updates) { | |||||||||||||||||||||||||||||||||||||||||
| 1140 | 0 | say "$k: $feed_updates{ $k } new posts"; | |||||||||||||||||||||||||||||||||||||||||
| 1141 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1142 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1143 | 0 | say "No new posts"; | |||||||||||||||||||||||||||||||||||||||||
| 1144 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1145 | |||||||||||||||||||||||||||||||||||||||||||
| 1146 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 1147 | |||||||||||||||||||||||||||||||||||||||||||
| 1148 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1149 | |||||||||||||||||||||||||||||||||||||||||||
| 1150 | 0 | ▶ | sub reload { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
reload: not called CC=16 SCAR=56.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1151 | |||||||||||||||||||||||||||||||||||||||||||
| 1152 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1153 | |||||||||||||||||||||||||||||||||||||||||||
| 1154 | 0 | my @reloads; | |||||||||||||||||||||||||||||||||||||||||
| 1155 | |||||||||||||||||||||||||||||||||||||||||||
| 1156 | 0 | ▶ | if (@{ $self->{ Args } }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1157 | 0 | my %feedset; | |||||||||||||||||||||||||||||||||||||||||
| 1158 | 0 | for my $arg (@{ $self->{ Args } }) { | |||||||||||||||||||||||||||||||||||||||||
| 1159 | 0 | ▶ | if (exists $self->{ Feeds }{ $arg }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 1160 | 0 | $feedset{ $arg } = 1; | |||||||||||||||||||||||||||||||||||||||||
| 1161 | } elsif (exists $self->{ Groups }{ $arg }) { | ||||||||||||||||||||||||||||||||||||||||||
| 1162 | 0 | for my $k (@{ $self->{ Groups }{ $arg }->feeds }) { | |||||||||||||||||||||||||||||||||||||||||
| 1163 | 0 | $feedset{ $k } = 1; | |||||||||||||||||||||||||||||||||||||||||
| 1164 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1165 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1166 | 0 | warn "'$arg' is not the name of a feed or feed group, skipping\n"; | |||||||||||||||||||||||||||||||||||||||||
| 1167 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1168 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1169 | |||||||||||||||||||||||||||||||||||||||||||
| 1170 | 0 | for my $f (keys %feedset) { | |||||||||||||||||||||||||||||||||||||||||
| 1171 | 0 | ▶ | if (-f $self->{ Feeds }{ $f }->path) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1172 | 0 | push @reloads, $f; | |||||||||||||||||||||||||||||||||||||||||
| 1173 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1174 | 0 | $self->err("'$f' does not have a local feed file, skipping"); | |||||||||||||||||||||||||||||||||||||||||
| 1175 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1176 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1177 | |||||||||||||||||||||||||||||||||||||||||||
| 1178 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1179 | @reloads = | ||||||||||||||||||||||||||||||||||||||||||
| 1180 | 0 | grep { -f $self->{ Feeds }{ $_ }->path } | |||||||||||||||||||||||||||||||||||||||||
| 1181 | 0 | keys %{ $self->{ Feeds } }; | |||||||||||||||||||||||||||||||||||||||||
| 1182 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1183 | |||||||||||||||||||||||||||||||||||||||||||
| 1184 | 0 | ▶ | unless (@reloads) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1185 | 0 | say "No feeds to reload"; | |||||||||||||||||||||||||||||||||||||||||
| 1186 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 1187 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1188 | |||||||||||||||||||||||||||||||||||||||||||
| 1189 | 0 | my %feed_updates; | |||||||||||||||||||||||||||||||||||||||||
| 1190 | |||||||||||||||||||||||||||||||||||||||||||
| 1191 | 0 | for my $r (@reloads) { | |||||||||||||||||||||||||||||||||||||||||
| 1192 | |||||||||||||||||||||||||||||||||||||||||||
| 1193 | 0 | my $new = eval { | |||||||||||||||||||||||||||||||||||||||||
| 1194 | 0 | ▶ | if ($self->{ HardReload }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1195 | 0 | $self->{ DB }->del_feeds($r); | |||||||||||||||||||||||||||||||||||||||||
| 1196 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1197 | 0 | $self->{ DB }->load_feed($self->{ Feeds }{ $r }); | |||||||||||||||||||||||||||||||||||||||||
| 1198 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 1199 | |||||||||||||||||||||||||||||||||||||||||||
| 1200 | 0 | ▶ | unless (defined $new) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1201 | 0 | my $e = $@; | |||||||||||||||||||||||||||||||||||||||||
| 1202 | 0 | chomp $e; | |||||||||||||||||||||||||||||||||||||||||
| 1203 | 0 | ▶ | if ($e ne '') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1204 | 0 | $self->err("Failed to reload $r: $e, skipping"); | |||||||||||||||||||||||||||||||||||||||||
| 1205 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1206 | 0 | $self->err("Failed to reload $r, skipping"); | |||||||||||||||||||||||||||||||||||||||||
| 1207 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1208 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 1209 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1210 | |||||||||||||||||||||||||||||||||||||||||||
| 1211 | 0 | ▶ | next if $new == 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1212 | 0 | $feed_updates{ $r } = $new; | |||||||||||||||||||||||||||||||||||||||||
| 1213 | |||||||||||||||||||||||||||||||||||||||||||
| 1214 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1215 | |||||||||||||||||||||||||||||||||||||||||||
| 1216 | 0 | ▶ | if (%feed_updates) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1217 | 0 | for my $k (sort keys %feed_updates) { | |||||||||||||||||||||||||||||||||||||||||
| 1218 | 0 | say "$k: $feed_updates{ $k } new posts"; | |||||||||||||||||||||||||||||||||||||||||
| 1219 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1220 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1221 | 0 | say "No new posts"; | |||||||||||||||||||||||||||||||||||||||||
| 1222 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1223 | |||||||||||||||||||||||||||||||||||||||||||
| 1224 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 1225 | |||||||||||||||||||||||||||||||||||||||||||
| 1226 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1227 | |||||||||||||||||||||||||||||||||||||||||||
| 1228 | 0 | ▶ | sub read_post { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
read_post: not called CC=14 SCAR=53.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1229 | |||||||||||||||||||||||||||||||||||||||||||
| 1230 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1231 | |||||||||||||||||||||||||||||||||||||||||||
| 1232 | 0 | my $feed_name = shift @{ $self->{ Args} }; | |||||||||||||||||||||||||||||||||||||||||
| 1233 | |||||||||||||||||||||||||||||||||||||||||||
| 1234 | 0 | ▶ | unless (defined $feed_name) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1235 | 0 | die "'$self->{ Cmd }' requires a feed name as argument\n"; | |||||||||||||||||||||||||||||||||||||||||
| 1236 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1237 | |||||||||||||||||||||||||||||||||||||||||||
| 1238 | 0 | ▶ | unless (exists $self->{ Feeds }{ $feed_name }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1239 | 0 | die "'$feed_name' is not the name of a feed\n"; | |||||||||||||||||||||||||||||||||||||||||
| 1240 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1241 | |||||||||||||||||||||||||||||||||||||||||||
| 1242 | 0 | my $id = shift @{ $self->{ Args } }; | |||||||||||||||||||||||||||||||||||||||||
| 1243 | |||||||||||||||||||||||||||||||||||||||||||
| 1244 | 0 | my $post; | |||||||||||||||||||||||||||||||||||||||||
| 1245 | |||||||||||||||||||||||||||||||||||||||||||
| 1246 | 0 | ▶ | if (defined $id) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1247 | 0 | ▶ | if ($id !~ /^-?\d+$/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1248 | 0 | die "Post ID must be an integar\n"; | |||||||||||||||||||||||||||||||||||||||||
| 1249 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1250 | 0 | $post = $self->{ DB }->post($feed_name, $id); | |||||||||||||||||||||||||||||||||||||||||
| 1251 | 0 | ▶ | unless (defined $post) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1252 | 0 | die "'$feed_name:$id' does not exist\n"; | |||||||||||||||||||||||||||||||||||||||||
| 1253 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1254 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1255 | 0 | $post = $self->{ DB }->first_unread($feed_name); | |||||||||||||||||||||||||||||||||||||||||
| 1256 | 0 | ▶ | unless (defined $post) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1257 | 0 | say "$feed_name has no unread posts, please manually specify a post ID"; | |||||||||||||||||||||||||||||||||||||||||
| 1258 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 1259 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1260 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1261 | |||||||||||||||||||||||||||||||||||||||||||
| 1262 | 0 | $self->{ ReadFmt } = _rm_color_codes($self->{ ReadFmt }); | |||||||||||||||||||||||||||||||||||||||||
| 1263 | |||||||||||||||||||||||||||||||||||||||||||
| 1264 | 0 | my $fmt = do { | |||||||||||||||||||||||||||||||||||||||||
| 1265 | 0 | my %fmt_codes = %POST_FMT_CODES; | |||||||||||||||||||||||||||||||||||||||||
| 1266 | 0 | for my $f (keys %fmt_codes) { | |||||||||||||||||||||||||||||||||||||||||
| 1267 | 0 | ▶ | next if $f eq 'P'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1268 | 0 | ▶ | $fmt_codes{ $f } = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1269 | 0 | escape_html($POST_FMT_CODES{ $f }->($_[0])) | |||||||||||||||||||||||||||||||||||||||||
| 1270 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 1271 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1272 | 0 | _fmt($self->{ ReadFmt }, \%fmt_codes); | |||||||||||||||||||||||||||||||||||||||||
| 1273 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 1274 | |||||||||||||||||||||||||||||||||||||||||||
| 1275 | 0 | my $dump; | |||||||||||||||||||||||||||||||||||||||||
| 1276 | |||||||||||||||||||||||||||||||||||||||||||
| 1277 | 0 | ▶ | if ($self->{ ReadHtml }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1278 | |||||||||||||||||||||||||||||||||||||||||||
| 1279 | 0 | $dump = $fmt->($post); | |||||||||||||||||||||||||||||||||||||||||
| 1280 | |||||||||||||||||||||||||||||||||||||||||||
| 1281 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1282 | |||||||||||||||||||||||||||||||||||||||||||
| 1283 | 0 | my ($tmp_html_fh, $tmp_html_nm) = tempfile(UNLINK => 1); | |||||||||||||||||||||||||||||||||||||||||
| 1284 | 0 | print { $tmp_html_fh } $fmt->($post); | |||||||||||||||||||||||||||||||||||||||||
| 1285 | 0 | close $tmp_html_fh; | |||||||||||||||||||||||||||||||||||||||||
| 1286 | |||||||||||||||||||||||||||||||||||||||||||
| 1287 | 0 | $dump = lynx_dump($tmp_html_nm, width => $self->{ LineWidth }); | |||||||||||||||||||||||||||||||||||||||||
| 1288 | |||||||||||||||||||||||||||||||||||||||||||
| 1289 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1290 | |||||||||||||||||||||||||||||||||||||||||||
| 1291 | |||||||||||||||||||||||||||||||||||||||||||
| 1292 | 0 | ▶ | if ($self->{ Stdout }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1293 | |||||||||||||||||||||||||||||||||||||||||||
| 1294 | 0 | say $dump; | |||||||||||||||||||||||||||||||||||||||||
| 1295 | |||||||||||||||||||||||||||||||||||||||||||
| 1296 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1297 | |||||||||||||||||||||||||||||||||||||||||||
| 1298 | 0 | my ($tmp_lynx_fh, $tmp_lynx_nm) = tempfile(UNLINK => 1); | |||||||||||||||||||||||||||||||||||||||||
| 1299 | 0 | print { $tmp_lynx_fh } $dump; | |||||||||||||||||||||||||||||||||||||||||
| 1300 | 0 | close $tmp_lynx_fh; | |||||||||||||||||||||||||||||||||||||||||
| 1301 | |||||||||||||||||||||||||||||||||||||||||||
| 1302 | 0 | system "$self->{ Pager } $tmp_lynx_nm"; | |||||||||||||||||||||||||||||||||||||||||
| 1303 | |||||||||||||||||||||||||||||||||||||||||||
| 1304 | 0 | ▶ | unless ($? >> 8 == 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1305 | 0 | die "Failed to run less on $tmp_lynx_nm\n"; | |||||||||||||||||||||||||||||||||||||||||
| 1306 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1307 | |||||||||||||||||||||||||||||||||||||||||||
| 1308 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1309 | |||||||||||||||||||||||||||||||||||||||||||
| 1310 | 0 | ▶ | unless ($self->{ NoMark }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1311 | $self->{ DB }->mark('read', $feed_name, $post->{ nossid }) | ||||||||||||||||||||||||||||||||||||||||||
| 1312 | 0 | ▶ | or die "Failed to mark '$feed_name:$post->{ nossid }' as read"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1313 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1314 | |||||||||||||||||||||||||||||||||||||||||||
| 1315 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 1316 | |||||||||||||||||||||||||||||||||||||||||||
| 1317 | |||||||||||||||||||||||||||||||||||||||||||
| 1318 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1319 | |||||||||||||||||||||||||||||||||||||||||||
| 1320 | 0 | ▶ | sub open_post { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
open_post: not called CC=14 SCAR=53.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1321 | |||||||||||||||||||||||||||||||||||||||||||
| 1322 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1323 | |||||||||||||||||||||||||||||||||||||||||||
| 1324 | 0 | my $feed_name = shift @{ $self->{ Args} }; | |||||||||||||||||||||||||||||||||||||||||
| 1325 | |||||||||||||||||||||||||||||||||||||||||||
| 1326 | 0 | ▶ | unless (defined $feed_name) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1327 | 0 | die "'open' requires a feed name as argument\n"; | |||||||||||||||||||||||||||||||||||||||||
| 1328 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1329 | |||||||||||||||||||||||||||||||||||||||||||
| 1330 | 0 | ▶ | unless (exists $self->{ Feeds }{ $feed_name }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1331 | 0 | die "'$feed_name' is not the name of a feed\n"; | |||||||||||||||||||||||||||||||||||||||||
| 1332 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1333 | |||||||||||||||||||||||||||||||||||||||||||
| 1334 | 0 | my $id = shift @{ $self->{ Args } }; | |||||||||||||||||||||||||||||||||||||||||
| 1335 | |||||||||||||||||||||||||||||||||||||||||||
| 1336 | 0 | my $post; | |||||||||||||||||||||||||||||||||||||||||
| 1337 | my $url; | ||||||||||||||||||||||||||||||||||||||||||
| 1338 | |||||||||||||||||||||||||||||||||||||||||||
| 1339 | 0 | ▶ | if (not defined $id) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1340 | 0 | my $feed_info = $self->{ DB }->feed($feed_name); | |||||||||||||||||||||||||||||||||||||||||
| 1341 | 0 | ▶ | if (not defined $feed_info) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1342 | 0 | die "$feed_name does not exist in noss's database, perhaps try running the update command?\n"; | |||||||||||||||||||||||||||||||||||||||||
| 1343 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1344 | 0 | $url = $feed_info->{ link }; | |||||||||||||||||||||||||||||||||||||||||
| 1345 | 0 | ▶ | if (not defined $url) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1346 | 0 | die "$feed_name does not have a homepage URL\n"; | |||||||||||||||||||||||||||||||||||||||||
| 1347 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1348 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1349 | 0 | ▶ | if ($id !~ /^-?\d+$/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1350 | 0 | die "Post ID must be an integar\n"; | |||||||||||||||||||||||||||||||||||||||||
| 1351 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1352 | 0 | $post = $self->{ DB }->post($feed_name, $id); | |||||||||||||||||||||||||||||||||||||||||
| 1353 | 0 | ▶ | if (not defined $post) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1354 | 0 | die "'$feed_name:$id' does not exist\n"; | |||||||||||||||||||||||||||||||||||||||||
| 1355 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1356 | 0 | $url = $post->{ link }; | |||||||||||||||||||||||||||||||||||||||||
| 1357 | 0 | ▶ | if (not defined $url) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1358 | 0 | die "Cannot open $feed_name:$id: Has no post URL\n"; | |||||||||||||||||||||||||||||||||||||||||
| 1359 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1360 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1361 | |||||||||||||||||||||||||||||||||||||||||||
| 1362 | 0 | ▶ | my $browser = $self->{ Feeds }{ $feed_name }->open_cmd // $self->{ Browser }; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->{"Feeds"}{$feed_name}->open_cmd // $self->{"Browser"}
MC/DC0%0/2
$self->{"Feeds"}{$feed_name}->open_cmd // $self->{"Browser"}
$self->{"Feeds"}{$feed_name}->open_cmd
$self->{"Browser"}
Truth table0%0/3
A // B
A= $self->{"Feeds"}{$feed_name}->open_cmdB= $self->{"Browser"}
| |||||||||||||||||||||||||||||||||||||||||||
| 1363 | 0 | system "$browser $url"; | |||||||||||||||||||||||||||||||||||||||||
| 1364 | |||||||||||||||||||||||||||||||||||||||||||
| 1365 | 0 | ▶ | unless ($? >> 8 == 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1366 | 0 | die "Failed to open $url with $browser\n"; | |||||||||||||||||||||||||||||||||||||||||
| 1367 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1368 | |||||||||||||||||||||||||||||||||||||||||||
| 1369 | 0 | ▶ | if (defined $id and not $self->{ NoMark }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $id and not $self->{"NoMark"}
MC/DC0%0/2
defined $id and not $self->{"NoMark"}
defined $id
not $self->{"NoMark"}
Truth table0%0/3
A and not(B)
A= defined $idB= not $self->{"NoMark"}
| |||||||||||||||||||||||||||||||||||||||||||
| 1370 | $self->{ DB }->mark('read', $feed_name, $post->{ nossid }) | ||||||||||||||||||||||||||||||||||||||||||
| 1371 | 0 | ▶ | or die "Failed to mark '$feed_name:$id' as read"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1372 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1373 | |||||||||||||||||||||||||||||||||||||||||||
| 1374 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 1375 | |||||||||||||||||||||||||||||||||||||||||||
| 1376 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1377 | |||||||||||||||||||||||||||||||||||||||||||
| 1378 | 0 | ▶ | sub cat { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cat: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1379 | |||||||||||||||||||||||||||||||||||||||||||
| 1380 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1381 | |||||||||||||||||||||||||||||||||||||||||||
| 1382 | 0 | $self->{ Stdout } = 1; | |||||||||||||||||||||||||||||||||||||||||
| 1383 | 0 | $self->read_post; | |||||||||||||||||||||||||||||||||||||||||
| 1384 | |||||||||||||||||||||||||||||||||||||||||||
| 1385 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 1386 | |||||||||||||||||||||||||||||||||||||||||||
| 1387 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1388 | |||||||||||||||||||||||||||||||||||||||||||
| 1389 | 0 | ▶ | sub look { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
look: not called CC=16 SCAR=56.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1390 | |||||||||||||||||||||||||||||||||||||||||||
| 1391 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1392 | |||||||||||||||||||||||||||||||||||||||||||
| 1393 | 0 | my @feeds; | |||||||||||||||||||||||||||||||||||||||||
| 1394 | |||||||||||||||||||||||||||||||||||||||||||
| 1395 | 0 | ▶ | if (@{ $self->{ Args } }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 1396 | 0 | my %feedset; | |||||||||||||||||||||||||||||||||||||||||
| 1397 | 0 | for my $arg (@{ $self->{ Args } }) { | |||||||||||||||||||||||||||||||||||||||||
| 1398 | 0 | ▶ | if (exists $self->{ Feeds }{ $arg }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 1399 | 0 | $feedset{ $arg } = 1; | |||||||||||||||||||||||||||||||||||||||||
| 1400 | } elsif (exists $self->{ Groups }{ $arg }) { | ||||||||||||||||||||||||||||||||||||||||||
| 1401 | 0 | for my $k (@{ $self->{ Groups }{ $arg }->feeds }) { | |||||||||||||||||||||||||||||||||||||||||
| 1402 | 0 | $feedset{ $k } = 1; | |||||||||||||||||||||||||||||||||||||||||
| 1403 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1404 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1405 | 0 | warn "'$arg' is not the name of a feed or feed group, skipping\n"; | |||||||||||||||||||||||||||||||||||||||||
| 1406 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1407 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1408 | 0 | @feeds = keys %feedset; | |||||||||||||||||||||||||||||||||||||||||
| 1409 | } elsif ($self->{ ShowHidden }) { | ||||||||||||||||||||||||||||||||||||||||||
| 1410 | 0 | @feeds = keys %{ $self->{ Feeds } }; | |||||||||||||||||||||||||||||||||||||||||
| 1411 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1412 | @feeds = | ||||||||||||||||||||||||||||||||||||||||||
| 1413 | 0 | grep { not $self->{ Feeds }{ $_ }->hidden } | |||||||||||||||||||||||||||||||||||||||||
| 1414 | 0 | keys %{ $self->{ Feeds } }; | |||||||||||||||||||||||||||||||||||||||||
| 1415 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1416 | |||||||||||||||||||||||||||||||||||||||||||
| 1417 | my $titlerx = | ||||||||||||||||||||||||||||||||||||||||||
| 1418 | defined $self->{ Title } | ||||||||||||||||||||||||||||||||||||||||||
| 1419 | ? _arg2rx($self->{ Title }) | ||||||||||||||||||||||||||||||||||||||||||
| 1420 | 0 | ▶ | : undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1421 | 0 | my @contrx = map { _arg2rx($_) } @{ $self->{ Content } }; | |||||||||||||||||||||||||||||||||||||||||
| 1422 | |||||||||||||||||||||||||||||||||||||||||||
| 1423 | 0 | ▶ | unless (@feeds) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1424 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 1425 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1426 | |||||||||||||||||||||||||||||||||||||||||||
| 1427 | 0 | ▶ | my $idlen = length($self->{ DB }->largest_id(@feeds) // 0); | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{"DB"}->largest_id(@feeds) // 0
MC/DC0%0/1
$self->{"DB"}->largest_id(@feeds) // 0
$self->{"DB"}->largest_id(@feeds)
Truth table0%0/2
A
A= $self->{"DB"}->largest_id(@feeds)
| |||||||||||||||||||||||||||||||||||||||||||
| 1428 | 0 | ▶ | my $feedlen = max(map { length } @feeds) // 1; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
&max(map({length $_;} @feeds)) // 1
MC/DC0%0/1
&max(map({length $_;} @feeds)) // 1
&max(map({length $_;} @feeds))
Truth table0%0/2
A
A= &max(map({length $_;} @feeds))
| |||||||||||||||||||||||||||||||||||||||||||
| 1429 | |||||||||||||||||||||||||||||||||||||||||||
| 1430 | 0 | my $readfmt = do { | |||||||||||||||||||||||||||||||||||||||||
| 1431 | 0 | my $fmt = $self->{ ListFmt }; | |||||||||||||||||||||||||||||||||||||||||
| 1432 | 0 | ▶ | if (not defined $fmt) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1433 | 0 | $fmt = sprintf "<7>%%s <6>%%-%df <3>%%%di <8>%%t", $feedlen, $idlen; | |||||||||||||||||||||||||||||||||||||||||
| 1434 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1435 | 0 | ▶ | if (!$self->{ UseColor }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1436 | 0 | $fmt = _rm_color_codes($fmt); | |||||||||||||||||||||||||||||||||||||||||
| 1437 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1438 | 0 | _fmt($fmt, \%POST_FMT_CODES, $self->{ ColorMap }); | |||||||||||||||||||||||||||||||||||||||||
| 1439 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 1440 | 0 | my $unreadfmt = do { | |||||||||||||||||||||||||||||||||||||||||
| 1441 | 0 | my $fmt = $self->{ ListUnreadFmt }; | |||||||||||||||||||||||||||||||||||||||||
| 1442 | 0 | ▶ | if (not defined $fmt) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1443 | 0 | ▶ | if (defined $self->{ ListFmt }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1444 | 0 | $fmt = $self->{ ListFmt }; | |||||||||||||||||||||||||||||||||||||||||
| 1445 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1446 | 0 | $fmt = sprintf "<15>%%s <14>%%-%df <11>%%%di <16>%%t", $feedlen, $idlen; | |||||||||||||||||||||||||||||||||||||||||
| 1447 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1448 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1449 | 0 | ▶ | if (!$self->{ UseColor }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1450 | 0 | $fmt = _rm_color_codes($fmt); | |||||||||||||||||||||||||||||||||||||||||
| 1451 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1452 | 0 | _fmt($fmt, \%POST_FMT_CODES, $self->{ ColorMap }); | |||||||||||||||||||||||||||||||||||||||||
| 1453 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 1454 | |||||||||||||||||||||||||||||||||||||||||||
| 1455 | 0 | ▶ | my $callback = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1456 | 0 | ▶ | print $_[0]->{ status } eq 'read' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1457 | ? $readfmt->($_[0]) | ||||||||||||||||||||||||||||||||||||||||||
| 1458 | : $unreadfmt->($_[0]); | ||||||||||||||||||||||||||||||||||||||||||
| 1459 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 1460 | |||||||||||||||||||||||||||||||||||||||||||
| 1461 | $self->{ DB }->look( | ||||||||||||||||||||||||||||||||||||||||||
| 1462 | title => $titlerx, | ||||||||||||||||||||||||||||||||||||||||||
| 1463 | feeds => \@feeds, | ||||||||||||||||||||||||||||||||||||||||||
| 1464 | status => $self->{ Status }, | ||||||||||||||||||||||||||||||||||||||||||
| 1465 | 0 | tags => [ map { qr/\Q$_\E/i } @{ $self->{ Tags } } ], | |||||||||||||||||||||||||||||||||||||||||
| 1466 | content => \@contrx, | ||||||||||||||||||||||||||||||||||||||||||
| 1467 | order => $self->{ Sort }, | ||||||||||||||||||||||||||||||||||||||||||
| 1468 | reverse => $self->{ Reverse }, | ||||||||||||||||||||||||||||||||||||||||||
| 1469 | limit => $self->{ ListLimit }, | ||||||||||||||||||||||||||||||||||||||||||
| 1470 | 0 | callback => $callback, | |||||||||||||||||||||||||||||||||||||||||
| 1471 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1472 | |||||||||||||||||||||||||||||||||||||||||||
| 1473 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 1474 | |||||||||||||||||||||||||||||||||||||||||||
| 1475 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1476 | |||||||||||||||||||||||||||||||||||||||||||
| 1477 | 0 | ▶ | sub unread { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unread: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1478 | |||||||||||||||||||||||||||||||||||||||||||
| 1479 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1480 | |||||||||||||||||||||||||||||||||||||||||||
| 1481 | 0 | $self->{ Status } = 'unread'; | |||||||||||||||||||||||||||||||||||||||||
| 1482 | |||||||||||||||||||||||||||||||||||||||||||
| 1483 | 0 | $self->look; | |||||||||||||||||||||||||||||||||||||||||
| 1484 | |||||||||||||||||||||||||||||||||||||||||||
| 1485 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 1486 | |||||||||||||||||||||||||||||||||||||||||||
| 1487 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1488 | |||||||||||||||||||||||||||||||||||||||||||
| 1489 | 0 | ▶ | sub mark { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mark: not called CC=17 SCAR=57.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1490 | |||||||||||||||||||||||||||||||||||||||||||
| 1491 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1492 | |||||||||||||||||||||||||||||||||||||||||||
| 1493 | 0 | my $status = shift @{ $self->{ Args } }; | |||||||||||||||||||||||||||||||||||||||||
| 1494 | |||||||||||||||||||||||||||||||||||||||||||
| 1495 | 0 | ▶ | unless (defined $status) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1496 | 0 | die "'mark' requires a status as argument\n"; | |||||||||||||||||||||||||||||||||||||||||
| 1497 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1498 | |||||||||||||||||||||||||||||||||||||||||||
| 1499 | 0 | ▶ | unless ($status =~ /^(un)?read$/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1500 | 0 | die "status must either be 'read' or 'unread'\n"; | |||||||||||||||||||||||||||||||||||||||||
| 1501 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1502 | |||||||||||||||||||||||||||||||||||||||||||
| 1503 | 0 | my @feeds; | |||||||||||||||||||||||||||||||||||||||||
| 1504 | my @posts; | ||||||||||||||||||||||||||||||||||||||||||
| 1505 | |||||||||||||||||||||||||||||||||||||||||||
| 1506 | 0 | my $targ = shift @{ $self->{ Args } }; | |||||||||||||||||||||||||||||||||||||||||
| 1507 | |||||||||||||||||||||||||||||||||||||||||||
| 1508 | 0 | ▶ | if (not defined $targ and not $self->{ MarkAll }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
defined $targ || $self->{'MarkAll'}
MC/DC0%0/2
defined $targ || $self->{'MarkAll'}
defined $targ
$self->{'MarkAll'}
Truth table0%0/3
A || B
A= defined $targB= $self->{'MarkAll'}
| |||||||||||||||||||||||||||||||||||||||||||
| 1509 | 0 | die "mark requires a feed name or group as argument\n"; | |||||||||||||||||||||||||||||||||||||||||
| 1510 | ▶ | } elsif (defined $targ and $self->{ MarkAll }) { | |||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
defined $targ and $self->{"MarkAll"}
MC/DC0%0/2
defined $targ and $self->{"MarkAll"}
defined $targ
$self->{"MarkAll"}
Truth table0%0/3
A and B
A= defined $targB= $self->{"MarkAll"}
| |||||||||||||||||||||||||||||||||||||||||||
| 1511 | 0 | die "mark --all should not be given a feed name or group as argument\n"; | |||||||||||||||||||||||||||||||||||||||||
| 1512 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1513 | |||||||||||||||||||||||||||||||||||||||||||
| 1514 | 0 | ▶ | if ($self->{ MarkAll }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 1515 | 0 | @feeds = keys %{ $self->{ Feeds } }; | |||||||||||||||||||||||||||||||||||||||||
| 1516 | 0 | @posts = (); | |||||||||||||||||||||||||||||||||||||||||
| 1517 | } elsif (exists $self->{ Groups }{ $targ }) { | ||||||||||||||||||||||||||||||||||||||||||
| 1518 | 0 | @feeds = @{ $self->{ Groups }{ $targ }->feeds }; | |||||||||||||||||||||||||||||||||||||||||
| 1519 | 0 | @posts = (); | |||||||||||||||||||||||||||||||||||||||||
| 1520 | } elsif (exists $self->{ Feeds }{ $targ }) { | ||||||||||||||||||||||||||||||||||||||||||
| 1521 | 0 | @feeds = ($targ); | |||||||||||||||||||||||||||||||||||||||||
| 1522 | 0 | for my $p (@{ $self->{ Args } }) { | |||||||||||||||||||||||||||||||||||||||||
| 1523 | 0 | ▶ | unless ($p =~ /^(?<from>-?[0-9]+)(-(?<to>-?[0-9]+))?$/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1524 | 0 | die "'$p' is not a post argument\n"; | |||||||||||||||||||||||||||||||||||||||||
| 1525 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1526 | 0 | my ($from, $to) = @+{ qw(from to) }; | |||||||||||||||||||||||||||||||||||||||||
| 1527 | 0 | ▶ | $to //= $from; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$to //= $from
MC/DC0%0/2
$to //= $from
$to
$from
Truth table0%0/3
A //= B
A= $toB= $from
| |||||||||||||||||||||||||||||||||||||||||||
| 1528 | 0 | ▶ | if ($from < 0 xor $to < 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/4
$from < 0 xor $to < 0
MC/DC0%0/2
$from < 0 xor $to < 0
$from < 0
$to < 0
Truth table0%0/4
A xor B
A= $from < 0B= $to < 0
| |||||||||||||||||||||||||||||||||||||||||||
| 1529 | 0 | die "cannot mix negative and positive post arguments\n"; | |||||||||||||||||||||||||||||||||||||||||
| 1530 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1531 | 0 | ▶ | push @posts, ( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1532 | $from < $to | ||||||||||||||||||||||||||||||||||||||||||
| 1533 | ? ($from .. $to) | ||||||||||||||||||||||||||||||||||||||||||
| 1534 | : ($to .. $from) | ||||||||||||||||||||||||||||||||||||||||||
| 1535 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1536 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1537 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1538 | 0 | die "'$targ' is not the name of a feed or group\n"; | |||||||||||||||||||||||||||||||||||||||||
| 1539 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1540 | |||||||||||||||||||||||||||||||||||||||||||
| 1541 | 0 | my $num = 0; | |||||||||||||||||||||||||||||||||||||||||
| 1542 | |||||||||||||||||||||||||||||||||||||||||||
| 1543 | 0 | for my $f (@feeds) { | |||||||||||||||||||||||||||||||||||||||||
| 1544 | 0 | my $n = $self->{ DB }->mark($status, $f, @posts); | |||||||||||||||||||||||||||||||||||||||||
| 1545 | 0 | $num += $n; | |||||||||||||||||||||||||||||||||||||||||
| 1546 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1547 | |||||||||||||||||||||||||||||||||||||||||||
| 1548 | 0 | say "$num posts updated"; | |||||||||||||||||||||||||||||||||||||||||
| 1549 | |||||||||||||||||||||||||||||||||||||||||||
| 1550 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 1551 | |||||||||||||||||||||||||||||||||||||||||||
| 1552 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1553 | |||||||||||||||||||||||||||||||||||||||||||
| 1554 | 0 | ▶ | sub post { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
post: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1555 | |||||||||||||||||||||||||||||||||||||||||||
| 1556 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1557 | |||||||||||||||||||||||||||||||||||||||||||
| 1558 | 0 | my $feed = shift @{ $self->{ Args } }; | |||||||||||||||||||||||||||||||||||||||||
| 1559 | 0 | my $id = shift @{ $self->{ Args } }; | |||||||||||||||||||||||||||||||||||||||||
| 1560 | |||||||||||||||||||||||||||||||||||||||||||
| 1561 | 0 | ▶ | if (not defined $feed or not defined $id) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $feed and defined $id
MC/DC0%0/2
defined $feed and defined $id
defined $feed
defined $id
Truth table0%0/3
A and B
A= defined $feedB= defined $id
| |||||||||||||||||||||||||||||||||||||||||||
| 1562 | 0 | die "post requires a feed name and post ID as argument\n"; | |||||||||||||||||||||||||||||||||||||||||
| 1563 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1564 | |||||||||||||||||||||||||||||||||||||||||||
| 1565 | 0 | ▶ | unless (exists $self->{ Feeds }{ $feed }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1566 | 0 | die "'$feed' is not the name of a feed\n"; | |||||||||||||||||||||||||||||||||||||||||
| 1567 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1568 | |||||||||||||||||||||||||||||||||||||||||||
| 1569 | 0 | ▶ | unless ($id =~ /^-?\d+$/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1570 | 0 | die "Post ID must be an integar\n"; | |||||||||||||||||||||||||||||||||||||||||
| 1571 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1572 | |||||||||||||||||||||||||||||||||||||||||||
| 1573 | 0 | my $post = $self->{ DB }->post($feed, $id); | |||||||||||||||||||||||||||||||||||||||||
| 1574 | |||||||||||||||||||||||||||||||||||||||||||
| 1575 | 0 | ▶ | unless (defined $post) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1576 | 0 | die "'$feed:$id' does not exist\n"; | |||||||||||||||||||||||||||||||||||||||||
| 1577 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1578 | |||||||||||||||||||||||||||||||||||||||||||
| 1579 | 0 | ▶ | if (!$self->{ UseColor }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1580 | 0 | $self->{ PostFmt } = _rm_color_codes($self->{ PostFmt }); | |||||||||||||||||||||||||||||||||||||||||
| 1581 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1582 | |||||||||||||||||||||||||||||||||||||||||||
| 1583 | my $fmt = _fmt( | ||||||||||||||||||||||||||||||||||||||||||
| 1584 | $self->{ PostFmt }, | ||||||||||||||||||||||||||||||||||||||||||
| 1585 | \%POST_FMT_CODES, | ||||||||||||||||||||||||||||||||||||||||||
| 1586 | $self->{ ColorMap } | ||||||||||||||||||||||||||||||||||||||||||
| 1587 | 0 | ); | |||||||||||||||||||||||||||||||||||||||||
| 1588 | |||||||||||||||||||||||||||||||||||||||||||
| 1589 | 0 | print $fmt->($post); | |||||||||||||||||||||||||||||||||||||||||
| 1590 | |||||||||||||||||||||||||||||||||||||||||||
| 1591 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 1592 | |||||||||||||||||||||||||||||||||||||||||||
| 1593 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1594 | |||||||||||||||||||||||||||||||||||||||||||
| 1595 | 0 | ▶ | sub feeds { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
feeds: not called CC=10 SCAR=47.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1596 | |||||||||||||||||||||||||||||||||||||||||||
| 1597 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1598 | |||||||||||||||||||||||||||||||||||||||||||
| 1599 | 0 | my @feeds; | |||||||||||||||||||||||||||||||||||||||||
| 1600 | |||||||||||||||||||||||||||||||||||||||||||
| 1601 | 0 | ▶ | if (@{ $self->{ Args } }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1602 | 0 | my %feedset; | |||||||||||||||||||||||||||||||||||||||||
| 1603 | 0 | for my $a (@{ $self->{ Args } }) { | |||||||||||||||||||||||||||||||||||||||||
| 1604 | 0 | ▶ | if (exists $self->{ Feeds }{ $a }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 1605 | 0 | $feedset{ $a } = 1; | |||||||||||||||||||||||||||||||||||||||||
| 1606 | } elsif (exists $self->{ Groups }{ $a }) { | ||||||||||||||||||||||||||||||||||||||||||
| 1607 | 0 | for my $f (@{ $self->{ Groups }{ $a }->feeds }) { | |||||||||||||||||||||||||||||||||||||||||
| 1608 | 0 | $feedset{ $f } = 1; | |||||||||||||||||||||||||||||||||||||||||
| 1609 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1610 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1611 | 0 | warn "'$a' is not the name of a feed or group, skipping\n"; | |||||||||||||||||||||||||||||||||||||||||
| 1612 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1613 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1614 | 0 | @feeds = sort keys %feedset; | |||||||||||||||||||||||||||||||||||||||||
| 1615 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1616 | 0 | @feeds = sort keys %{ $self->{ Feeds } }; | |||||||||||||||||||||||||||||||||||||||||
| 1617 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1618 | |||||||||||||||||||||||||||||||||||||||||||
| 1619 | 0 | ▶ | unless (@feeds) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1620 | 0 | die "No feeds can be printed\n"; | |||||||||||||||||||||||||||||||||||||||||
| 1621 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1622 | |||||||||||||||||||||||||||||||||||||||||||
| 1623 | 0 | ▶ | if (!$self->{ UseColor }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1624 | 0 | $self->{ FeedsFmt } = _rm_color_codes($self->{ FeedsFmt }); | |||||||||||||||||||||||||||||||||||||||||
| 1625 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1626 | |||||||||||||||||||||||||||||||||||||||||||
| 1627 | 0 | my $cb = _fmt($self->{ FeedsFmt }, \%FEED_FMT_CODES, $self->{ ColorMap }); | |||||||||||||||||||||||||||||||||||||||||
| 1628 | |||||||||||||||||||||||||||||||||||||||||||
| 1629 | 0 | for my $n (@feeds) { | |||||||||||||||||||||||||||||||||||||||||
| 1630 | |||||||||||||||||||||||||||||||||||||||||||
| 1631 | 0 | my $f = $self->{ DB }->feed($n, post_info => 1); | |||||||||||||||||||||||||||||||||||||||||
| 1632 | |||||||||||||||||||||||||||||||||||||||||||
| 1633 | $f //= { | ||||||||||||||||||||||||||||||||||||||||||
| 1634 | nossname => $self->{ Feeds }{ $n }->name, | ||||||||||||||||||||||||||||||||||||||||||
| 1635 | 0 | ▶ | nosslink => $self->{ Feeds }{ $n }->feed, | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$f //= {"nossname", $self->{"Feeds"}{$n}->name, "nosslink", $self->{"Feeds"}{$n}->feed}
MC/DC0%0/1
$f //= {"nossname", $self->{"Feeds"}{$n}->name, "nosslink", $self->{"Feeds"}{$n}->feed}
$f
Truth table0%0/2
A
A= $f
| |||||||||||||||||||||||||||||||||||||||||||
| 1636 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 1637 | |||||||||||||||||||||||||||||||||||||||||||
| 1638 | 0 | print $cb->($f); | |||||||||||||||||||||||||||||||||||||||||
| 1639 | |||||||||||||||||||||||||||||||||||||||||||
| 1640 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1641 | |||||||||||||||||||||||||||||||||||||||||||
| 1642 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 1643 | |||||||||||||||||||||||||||||||||||||||||||
| 1644 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1645 | |||||||||||||||||||||||||||||||||||||||||||
| 1646 | 0 | ▶ | sub groups { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
groups: not called CC=10 SCAR=47.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1647 | |||||||||||||||||||||||||||||||||||||||||||
| 1648 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1649 | |||||||||||||||||||||||||||||||||||||||||||
| 1650 | 0 | my @groups; | |||||||||||||||||||||||||||||||||||||||||
| 1651 | |||||||||||||||||||||||||||||||||||||||||||
| 1652 | 0 | ▶ | if (@{ $self->{ Args } }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1653 | 0 | for my $a (@{ $self->{ Args } }) { | |||||||||||||||||||||||||||||||||||||||||
| 1654 | 0 | ▶ | if (exists $self->{ Groups }{ $a }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1655 | 0 | push @groups, $a; | |||||||||||||||||||||||||||||||||||||||||
| 1656 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1657 | 0 | warn "'$a' is not the name of a feed group, skipping\n"; | |||||||||||||||||||||||||||||||||||||||||
| 1658 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1659 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1660 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1661 | 0 | @groups = sort keys %{ $self->{ Groups } }; | |||||||||||||||||||||||||||||||||||||||||
| 1662 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1663 | |||||||||||||||||||||||||||||||||||||||||||
| 1664 | 0 | ▶ | unless (@groups) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1665 | 0 | die "No feed groups can be printed\n"; | |||||||||||||||||||||||||||||||||||||||||
| 1666 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1667 | |||||||||||||||||||||||||||||||||||||||||||
| 1668 | 0 | for my $i (0 .. $#groups) { | |||||||||||||||||||||||||||||||||||||||||
| 1669 | |||||||||||||||||||||||||||||||||||||||||||
| 1670 | my @feeds = | ||||||||||||||||||||||||||||||||||||||||||
| 1671 | 0 | grep { exists $self->{ Feeds }{ $_ } } | |||||||||||||||||||||||||||||||||||||||||
| 1672 | 0 | @{ $self->{ Groups }{ $groups[$i] }->feeds }; | |||||||||||||||||||||||||||||||||||||||||
| 1673 | |||||||||||||||||||||||||||||||||||||||||||
| 1674 | 0 | ▶ | @feeds = ('(none)') unless @feeds; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1675 | |||||||||||||||||||||||||||||||||||||||||||
| 1676 | 0 | say $groups[$i]; | |||||||||||||||||||||||||||||||||||||||||
| 1677 | |||||||||||||||||||||||||||||||||||||||||||
| 1678 | 0 | ▶ | unless ($self->{ Brief }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1679 | 0 | for my $f (@feeds) { | |||||||||||||||||||||||||||||||||||||||||
| 1680 | 0 | say " $f"; | |||||||||||||||||||||||||||||||||||||||||
| 1681 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1682 | 0 | ▶ | print "\n" unless $i == $#groups; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1683 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1684 | |||||||||||||||||||||||||||||||||||||||||||
| 1685 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1686 | |||||||||||||||||||||||||||||||||||||||||||
| 1687 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 1688 | |||||||||||||||||||||||||||||||||||||||||||
| 1689 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1690 | |||||||||||||||||||||||||||||||||||||||||||
| 1691 | 0 | ▶ | sub clean { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clean: not called CC=10 SCAR=47.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1692 | |||||||||||||||||||||||||||||||||||||||||||
| 1693 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1694 | |||||||||||||||||||||||||||||||||||||||||||
| 1695 | 0 | for my $f (dir($self->{ FeedDir })) { | |||||||||||||||||||||||||||||||||||||||||
| 1696 | |||||||||||||||||||||||||||||||||||||||||||
| 1697 | 0 | ▶ | next unless $f =~ /\.feed$/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1698 | |||||||||||||||||||||||||||||||||||||||||||
| 1699 | 0 | my $feed = (fileparse($f, qr/\.[^.]*/))[0]; | |||||||||||||||||||||||||||||||||||||||||
| 1700 | |||||||||||||||||||||||||||||||||||||||||||
| 1701 | 0 | ▶ | unless (exists $self->{ Feeds }{ $feed }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1702 | 0 | ▶ | unlink $f or warn "Failed to unlink $f\n"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1703 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1704 | |||||||||||||||||||||||||||||||||||||||||||
| 1705 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1706 | |||||||||||||||||||||||||||||||||||||||||||
| 1707 | 0 | for my $f (dir($self->{ EtagDir })) { | |||||||||||||||||||||||||||||||||||||||||
| 1708 | |||||||||||||||||||||||||||||||||||||||||||
| 1709 | 0 | ▶ | next unless $f =~ /\.etag/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1710 | |||||||||||||||||||||||||||||||||||||||||||
| 1711 | 0 | my $feed = (fileparse($f, qr/\.[^.]*/))[0]; | |||||||||||||||||||||||||||||||||||||||||
| 1712 | |||||||||||||||||||||||||||||||||||||||||||
| 1713 | 0 | ▶ | unless (exists $self->{ Feeds }{ $feed }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1714 | 0 | ▶ | unlink $f or warn "Failed to unlink $f\n"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1715 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1716 | |||||||||||||||||||||||||||||||||||||||||||
| 1717 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1718 | |||||||||||||||||||||||||||||||||||||||||||
| 1719 | 0 | my @dbfeeds = $self->{ DB }->feeds; | |||||||||||||||||||||||||||||||||||||||||
| 1720 | |||||||||||||||||||||||||||||||||||||||||||
| 1721 | my @clean = | ||||||||||||||||||||||||||||||||||||||||||
| 1722 | 0 | grep { not exists $self->{ Feeds }{ $_ } } | |||||||||||||||||||||||||||||||||||||||||
| 1723 | 0 | map { $_->{ nossname } } | |||||||||||||||||||||||||||||||||||||||||
| 1724 | 0 | $self->{ DB }->feeds; | |||||||||||||||||||||||||||||||||||||||||
| 1725 | |||||||||||||||||||||||||||||||||||||||||||
| 1726 | 0 | ▶ | if (@clean) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1727 | 0 | $self->{ DB }->del_feeds(@clean); | |||||||||||||||||||||||||||||||||||||||||
| 1728 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1729 | |||||||||||||||||||||||||||||||||||||||||||
| 1730 | 0 | $self->{ DB }->vacuum; | |||||||||||||||||||||||||||||||||||||||||
| 1731 | |||||||||||||||||||||||||||||||||||||||||||
| 1732 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 1733 | |||||||||||||||||||||||||||||||||||||||||||
| 1734 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1735 | |||||||||||||||||||||||||||||||||||||||||||
| 1736 | 0 | ▶ | sub discover { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
discover: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1737 | |||||||||||||||||||||||||||||||||||||||||||
| 1738 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1739 | |||||||||||||||||||||||||||||||||||||||||||
| 1740 | 0 | my $url = shift @{ $self->{ Args } }; | |||||||||||||||||||||||||||||||||||||||||
| 1741 | 0 | ▶ | if (not defined $url) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1742 | 0 | die "discover requires a URL as argument\n"; | |||||||||||||||||||||||||||||||||||||||||
| 1743 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1744 | |||||||||||||||||||||||||||||||||||||||||||
| 1745 | 0 | my $tmp = do { | |||||||||||||||||||||||||||||||||||||||||
| 1746 | 0 | my ($h, $p) = tempfile(UNLINK => 1); | |||||||||||||||||||||||||||||||||||||||||
| 1747 | 0 | close $h; | |||||||||||||||||||||||||||||||||||||||||
| 1748 | 0 | $p; | |||||||||||||||||||||||||||||||||||||||||
| 1749 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 1750 | |||||||||||||||||||||||||||||||||||||||||||
| 1751 | my ($rt, undef, undef) = curl( | ||||||||||||||||||||||||||||||||||||||||||
| 1752 | $url, $tmp, | ||||||||||||||||||||||||||||||||||||||||||
| 1753 | user_agent => $self->{ UserAgent }, | ||||||||||||||||||||||||||||||||||||||||||
| 1754 | limit_rate => $self->{ RateLimit }, | ||||||||||||||||||||||||||||||||||||||||||
| 1755 | timeout => $self->{ Timeout }, | ||||||||||||||||||||||||||||||||||||||||||
| 1756 | fail => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 1757 | proxy => $self->{ Proxy }, | ||||||||||||||||||||||||||||||||||||||||||
| 1758 | proxy_user => $self->{ ProxyUser }, | ||||||||||||||||||||||||||||||||||||||||||
| 1759 | 0 | redirect => 1, | |||||||||||||||||||||||||||||||||||||||||
| 1760 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1761 | |||||||||||||||||||||||||||||||||||||||||||
| 1762 | 0 | ▶ | if ($rt != 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1763 | 0 | die sprintf "Failed to curl %s: %s\n", $url, curl_error($rt); | |||||||||||||||||||||||||||||||||||||||||
| 1764 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1765 | |||||||||||||||||||||||||||||||||||||||||||
| 1766 | 0 | my @feeds = discover_feeds($tmp); | |||||||||||||||||||||||||||||||||||||||||
| 1767 | 0 | ▶ | if (!@feeds) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1768 | 0 | say "No feeds found in $url"; | |||||||||||||||||||||||||||||||||||||||||
| 1769 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 1770 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1771 | |||||||||||||||||||||||||||||||||||||||||||
| 1772 | 0 | @feeds = uniq sort map { resolve_url($_, $url) } @feeds; | |||||||||||||||||||||||||||||||||||||||||
| 1773 | 0 | for my $f (@feeds) { | |||||||||||||||||||||||||||||||||||||||||
| 1774 | 0 | say $f; | |||||||||||||||||||||||||||||||||||||||||
| 1775 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1776 | |||||||||||||||||||||||||||||||||||||||||||
| 1777 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 1778 | |||||||||||||||||||||||||||||||||||||||||||
| 1779 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1780 | |||||||||||||||||||||||||||||||||||||||||||
| 1781 | 0 | ▶ | sub export_opml { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
export_opml: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1782 | |||||||||||||||||||||||||||||||||||||||||||
| 1783 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1784 | |||||||||||||||||||||||||||||||||||||||||||
| 1785 | 0 | my $to = shift @{ $self->{ Args } }; | |||||||||||||||||||||||||||||||||||||||||
| 1786 | |||||||||||||||||||||||||||||||||||||||||||
| 1787 | 0 | my @feeds; | |||||||||||||||||||||||||||||||||||||||||
| 1788 | |||||||||||||||||||||||||||||||||||||||||||
| 1789 | 0 | for my $f (values %{ $self->{ Feeds } }) { | |||||||||||||||||||||||||||||||||||||||||
| 1790 | 0 | ▶ | next if $f->feed =~ /^(file|shell):\/\// and !$self->{ ExportSpec }; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$f->feed =~ m[^(file|shell)://]u and not $self->{"ExportSpec"}
MC/DC0%0/2
$f->feed =~ m[^(file|shell)://]u and not $self->{"ExportSpec"}
$f->feed =~ m[^(file|shell)://]u
not $self->{"ExportSpec"}
Truth table0%0/3
A and not(B)
A= $f->feed =~ m[^(file|shell)://]uB= not $self->{"ExportSpec"}
| |||||||||||||||||||||||||||||||||||||||||||
| 1791 | push @feeds, { | ||||||||||||||||||||||||||||||||||||||||||
| 1792 | title => $f->name, | ||||||||||||||||||||||||||||||||||||||||||
| 1793 | xml_url => $f->feed, | ||||||||||||||||||||||||||||||||||||||||||
| 1794 | 0 | groups => [ map { $_->name } @{ $f->groups } ], | |||||||||||||||||||||||||||||||||||||||||
| 1795 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 1796 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1797 | |||||||||||||||||||||||||||||||||||||||||||
| 1798 | 0 | my $opml = WWW::Noss::OPML->from_perl( | |||||||||||||||||||||||||||||||||||||||||
| 1799 | title => "$PRGNAM Feed List", | ||||||||||||||||||||||||||||||||||||||||||
| 1800 | feeds => \@feeds, | ||||||||||||||||||||||||||||||||||||||||||
| 1801 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1802 | |||||||||||||||||||||||||||||||||||||||||||
| 1803 | 0 | ▶ | if (defined $to) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1804 | 0 | $opml->to_file($to, folders => !$self->{ NoGroups }); | |||||||||||||||||||||||||||||||||||||||||
| 1805 | 0 | say "Wrote OPML to $to"; | |||||||||||||||||||||||||||||||||||||||||
| 1806 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1807 | 0 | $opml->to_fh(*STDOUT, folders => !$self->{ NoGroups }); | |||||||||||||||||||||||||||||||||||||||||
| 1808 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1809 | |||||||||||||||||||||||||||||||||||||||||||
| 1810 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 1811 | |||||||||||||||||||||||||||||||||||||||||||
| 1812 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1813 | |||||||||||||||||||||||||||||||||||||||||||
| 1814 | # TODO: --merge option? | ||||||||||||||||||||||||||||||||||||||||||
| 1815 | 0 | ▶ | sub import_opml { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
import_opml: not called CC=14 SCAR=53.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1816 | |||||||||||||||||||||||||||||||||||||||||||
| 1817 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1818 | |||||||||||||||||||||||||||||||||||||||||||
| 1819 | 0 | my $file = shift @{ $self->{ Args } }; | |||||||||||||||||||||||||||||||||||||||||
| 1820 | |||||||||||||||||||||||||||||||||||||||||||
| 1821 | 0 | ▶ | unless (defined $file) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1822 | 0 | die "import requires an OPML file as argument\n"; | |||||||||||||||||||||||||||||||||||||||||
| 1823 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1824 | |||||||||||||||||||||||||||||||||||||||||||
| 1825 | 0 | my $to = shift @{ $self->{ Args } }; | |||||||||||||||||||||||||||||||||||||||||
| 1826 | |||||||||||||||||||||||||||||||||||||||||||
| 1827 | 0 | my $json = { | |||||||||||||||||||||||||||||||||||||||||
| 1828 | default => {}, | ||||||||||||||||||||||||||||||||||||||||||
| 1829 | groups => {}, | ||||||||||||||||||||||||||||||||||||||||||
| 1830 | feeds => {}, | ||||||||||||||||||||||||||||||||||||||||||
| 1831 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 1832 | |||||||||||||||||||||||||||||||||||||||||||
| 1833 | 0 | my $opml = WWW::Noss::OPML->from_xml($file); | |||||||||||||||||||||||||||||||||||||||||
| 1834 | |||||||||||||||||||||||||||||||||||||||||||
| 1835 | my %groupset = | ||||||||||||||||||||||||||||||||||||||||||
| 1836 | 0 | map { $_ =~ s/\W//gr => {} } | |||||||||||||||||||||||||||||||||||||||||
| 1837 | 0 | ▶ | map { @{ $_->{ groups } // [] } } | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$_->{"groups"} // []
MC/DC0%0/1
$_->{"groups"} // []
$_->{"groups"}
Truth table0%0/2
A
A= $_->{"groups"}
| |||||||||||||||||||||||||||||||||||||||||||
| 1838 | 0 | @{ $opml->feeds }; | |||||||||||||||||||||||||||||||||||||||||
| 1839 | |||||||||||||||||||||||||||||||||||||||||||
| 1840 | 0 | for my $f (@{ $opml->feeds }) { | |||||||||||||||||||||||||||||||||||||||||
| 1841 | |||||||||||||||||||||||||||||||||||||||||||
| 1842 | 0 | my $name = $f->{ title } =~ s/\W//gr; | |||||||||||||||||||||||||||||||||||||||||
| 1843 | |||||||||||||||||||||||||||||||||||||||||||
| 1844 | 0 | ▶ | if (exists $json->{ feeds }{ $name } and $f->{ xml_url } ne $json->{ feeds }{ $name }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
exists $json->{"feeds"}{$name} and $f->{"xml_url"} ne $json->{"feeds"}{$name}
MC/DC0%0/2
exists $json->{"feeds"}{$name} and $f->{"xml_url"} ne $json->{"feeds"}{$name}
exists $json->{"feeds"}{$name}
$f->{"xml_url"} ne $json->{"feeds"}{$name}
Truth table0%0/3
A and B
A= exists $json->{"feeds"}{$name}B= $f->{"xml_url"} ne $json->{"feeds"}{$name}
| |||||||||||||||||||||||||||||||||||||||||||
| 1845 | 0 | warn "'$name' feed name conflict, $json->{ feeds }{ $name } will be lost\n"; | |||||||||||||||||||||||||||||||||||||||||
| 1846 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1847 | |||||||||||||||||||||||||||||||||||||||||||
| 1848 | 0 | ▶ | if (exists $groupset{ $name }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1849 | 0 | warn "'$name' group name conflict, $name group will be lost\n"; | |||||||||||||||||||||||||||||||||||||||||
| 1850 | 0 | delete $groupset{ $name }; | |||||||||||||||||||||||||||||||||||||||||
| 1851 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1852 | |||||||||||||||||||||||||||||||||||||||||||
| 1853 | 0 | $json->{ feeds }{ $name } = $f->{ xml_url }; | |||||||||||||||||||||||||||||||||||||||||
| 1854 | |||||||||||||||||||||||||||||||||||||||||||
| 1855 | 0 | ▶ | for my $g (@{ $f->{ groups } // [] }) { | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$f->{"groups"} // []
MC/DC0%0/1
$f->{"groups"} // []
$f->{"groups"}
Truth table0%0/2
A
A= $f->{"groups"}
| |||||||||||||||||||||||||||||||||||||||||||
| 1856 | 0 | $g =~ s/\W//g; | |||||||||||||||||||||||||||||||||||||||||
| 1857 | 0 | ▶ | next unless exists $groupset{ $g }; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1858 | 0 | $groupset{ $g }->{ $name } = 1; | |||||||||||||||||||||||||||||||||||||||||
| 1859 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1860 | |||||||||||||||||||||||||||||||||||||||||||
| 1861 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1862 | |||||||||||||||||||||||||||||||||||||||||||
| 1863 | 0 | ▶ | unless ($self->{ NoGroups }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1864 | 0 | for my $g (keys %groupset) { | |||||||||||||||||||||||||||||||||||||||||
| 1865 | 0 | $json->{ groups }{ $g } = [ sort keys %{ $groupset{ $g } } ]; | |||||||||||||||||||||||||||||||||||||||||
| 1866 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1867 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1868 | |||||||||||||||||||||||||||||||||||||||||||
| 1869 | 0 | my $json_obj = JSON->new->pretty->canonical; | |||||||||||||||||||||||||||||||||||||||||
| 1870 | |||||||||||||||||||||||||||||||||||||||||||
| 1871 | 0 | ▶ | if (defined $to) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1872 | 0 | ▶ | open my $fh, '>', $to | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1873 | or die "Failed to open $to for writing: $!\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 1874 | 0 | print { $fh } $json_obj->encode($json); | |||||||||||||||||||||||||||||||||||||||||
| 1875 | 0 | close $fh; | |||||||||||||||||||||||||||||||||||||||||
| 1876 | 0 | say "Wrote JSON to $to"; | |||||||||||||||||||||||||||||||||||||||||
| 1877 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1878 | 0 | print $json_obj->encode($json); | |||||||||||||||||||||||||||||||||||||||||
| 1879 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1880 | |||||||||||||||||||||||||||||||||||||||||||
| 1881 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 1882 | |||||||||||||||||||||||||||||||||||||||||||
| 1883 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1884 | |||||||||||||||||||||||||||||||||||||||||||
| 1885 | 0 | ▶ | sub help { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
help: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1886 | |||||||||||||||||||||||||||||||||||||||||||
| 1887 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1888 | |||||||||||||||||||||||||||||||||||||||||||
| 1889 | 0 | my $cmd = shift @{ $self->{ Args } }; | |||||||||||||||||||||||||||||||||||||||||
| 1890 | |||||||||||||||||||||||||||||||||||||||||||
| 1891 | 0 | ▶ | if (not defined $cmd) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1892 | 0 | pod2usage( | |||||||||||||||||||||||||||||||||||||||||
| 1893 | -exitval => 'NOEXIT', | ||||||||||||||||||||||||||||||||||||||||||
| 1894 | -verbose => 99, | ||||||||||||||||||||||||||||||||||||||||||
| 1895 | -sections => [ | ||||||||||||||||||||||||||||||||||||||||||
| 1896 | 'NAME', 'SYNOPSIS', 'DESCRIPTION', 'COMMANDS', | ||||||||||||||||||||||||||||||||||||||||||
| 1897 | 'GLOBAL OPTIONS', 'CONFIGURATION', 'ENVIRONMENT' | ||||||||||||||||||||||||||||||||||||||||||
| 1898 | ], | ||||||||||||||||||||||||||||||||||||||||||
| 1899 | -output => \*STDOUT, | ||||||||||||||||||||||||||||||||||||||||||
| 1900 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1901 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 1902 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1903 | |||||||||||||||||||||||||||||||||||||||||||
| 1904 | 0 | $cmd = lc $cmd; | |||||||||||||||||||||||||||||||||||||||||
| 1905 | |||||||||||||||||||||||||||||||||||||||||||
| 1906 | 0 | ▶ | if (not exists $COMMANDS{ $cmd }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1907 | 0 | die "'$cmd' is not a command\n"; | |||||||||||||||||||||||||||||||||||||||||
| 1908 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1909 | |||||||||||||||||||||||||||||||||||||||||||
| 1910 | pod2usage( | ||||||||||||||||||||||||||||||||||||||||||
| 1911 | 0 | -exitval => 'NOEXIT', | |||||||||||||||||||||||||||||||||||||||||
| 1912 | -verbose => 99, | ||||||||||||||||||||||||||||||||||||||||||
| 1913 | -sections => "COMMANDS/$cmd", | ||||||||||||||||||||||||||||||||||||||||||
| 1914 | -output => \*STDOUT, | ||||||||||||||||||||||||||||||||||||||||||
| 1915 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1916 | |||||||||||||||||||||||||||||||||||||||||||
| 1917 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 1918 | |||||||||||||||||||||||||||||||||||||||||||
| 1919 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1920 | |||||||||||||||||||||||||||||||||||||||||||
| 1921 | 0 | ▶ | sub init { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init: not called CC=48 SCAR=77.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1922 | |||||||||||||||||||||||||||||||||||||||||||
| 1923 | 0 | my ($class, @argv) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1924 | |||||||||||||||||||||||||||||||||||||||||||
| 1925 | 0 | my $self = { | |||||||||||||||||||||||||||||||||||||||||
| 1926 | Cmd => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 1927 | Args => [], | ||||||||||||||||||||||||||||||||||||||||||
| 1928 | DataDir => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 1929 | FeedDir => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 1930 | EtagDir => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 1931 | FeedFile => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 1932 | ConfFile => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 1933 | Feeds => {}, | ||||||||||||||||||||||||||||||||||||||||||
| 1934 | Groups => {}, | ||||||||||||||||||||||||||||||||||||||||||
| 1935 | DefaultGroup => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 1936 | DB => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 1937 | AutoClean => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 1938 | TimeFmt => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 1939 | UseColor => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 1940 | ColorMap => { %COLOR_CODES }, | ||||||||||||||||||||||||||||||||||||||||||
| 1941 | RetryDir => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 1942 | # update | ||||||||||||||||||||||||||||||||||||||||||
| 1943 | NewOnly => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 1944 | NonDefaults => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 1945 | Forks => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 1946 | Unconditional => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 1947 | RateLimit => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 1948 | UserAgent => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 1949 | Timeout => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 1950 | Proxy => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 1951 | ProxyUser => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 1952 | HardReload => 0, # reload, too | ||||||||||||||||||||||||||||||||||||||||||
| 1953 | # read | ||||||||||||||||||||||||||||||||||||||||||
| 1954 | Pager => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 1955 | NoMark => 0, # open, too | ||||||||||||||||||||||||||||||||||||||||||
| 1956 | Stdout => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 1957 | LineWidth => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 1958 | ReadFmt => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 1959 | ReadHtml => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 1960 | # open | ||||||||||||||||||||||||||||||||||||||||||
| 1961 | Browser => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 1962 | # look/unread | ||||||||||||||||||||||||||||||||||||||||||
| 1963 | Title => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 1964 | Tags => [], | ||||||||||||||||||||||||||||||||||||||||||
| 1965 | Status => undef, # look only | ||||||||||||||||||||||||||||||||||||||||||
| 1966 | Content => [], | ||||||||||||||||||||||||||||||||||||||||||
| 1967 | Sort => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 1968 | Reverse => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 1969 | ListLimit => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 1970 | ShowHidden => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 1971 | ListFmt => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 1972 | ListUnreadFmt => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 1973 | # mark | ||||||||||||||||||||||||||||||||||||||||||
| 1974 | MarkAll => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 1975 | # post | ||||||||||||||||||||||||||||||||||||||||||
| 1976 | PostFmt => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 1977 | # feeds | ||||||||||||||||||||||||||||||||||||||||||
| 1978 | Brief => 0, # groups, too | ||||||||||||||||||||||||||||||||||||||||||
| 1979 | FeedsFmt => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 1980 | # export/import | ||||||||||||||||||||||||||||||||||||||||||
| 1981 | NoGroups => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 1982 | ExportSpec => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 1983 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 1984 | |||||||||||||||||||||||||||||||||||||||||||
| 1985 | 0 | Getopt::Long::config('bundling'); | |||||||||||||||||||||||||||||||||||||||||
| 1986 | 0 | Getopt::Long::config('pass_through'); | |||||||||||||||||||||||||||||||||||||||||
| 1987 | GetOptionsFromArray(\@argv, | ||||||||||||||||||||||||||||||||||||||||||
| 1988 | 'config|c=s' => \$self->{ ConfFile }, | ||||||||||||||||||||||||||||||||||||||||||
| 1989 | 'data|D=s' => \$self->{ DataDir }, | ||||||||||||||||||||||||||||||||||||||||||
| 1990 | 'feeds|f=s' => \$self->{ FeedFile }, | ||||||||||||||||||||||||||||||||||||||||||
| 1991 | 0 | ▶ | 'autoclean|A:s' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1992 | 0 | ▶ | if ($_[1] eq '' or $_[1] eq '1') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
$_[1] eq "" or $_[1] eq 1
MC/DC0%0/2
$_[1] eq "" or $_[1] eq 1
$_[1] eq ""
$_[1] eq 1
Truth table0%0/3
A or B
A= $_[1] eq ""B= $_[1] eq 1
| |||||||||||||||||||||||||||||||||||||||||||
| 1993 | 0 | $self->{ AutoClean } = 1; | |||||||||||||||||||||||||||||||||||||||||
| 1994 | } elsif ($_[1] eq '0') { | ||||||||||||||||||||||||||||||||||||||||||
| 1995 | 0 | $self->{ AutoClean } = 0; | |||||||||||||||||||||||||||||||||||||||||
| 1996 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1997 | 0 | $self->{ AutoClean } = 1; | |||||||||||||||||||||||||||||||||||||||||
| 1998 | 0 | unshift @argv, $_[1]; | |||||||||||||||||||||||||||||||||||||||||
| 1999 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2000 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 2001 | 'time-format|z=s' => \$self->{ TimeFmt }, | ||||||||||||||||||||||||||||||||||||||||||
| 2002 | 0 | ▶ | 'color|C:s' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 2003 | 0 | ▶ | if ($_[1] eq '' or $_[1] eq '1') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
$_[1] eq "" or $_[1] eq 1
MC/DC0%0/2
$_[1] eq "" or $_[1] eq 1
$_[1] eq ""
$_[1] eq 1
Truth table0%0/3
A or B
A= $_[1] eq ""B= $_[1] eq 1
| |||||||||||||||||||||||||||||||||||||||||||
| 2004 | 0 | $self->{ UseColor } = 1; | |||||||||||||||||||||||||||||||||||||||||
| 2005 | } elsif ($_[1] eq '0') { | ||||||||||||||||||||||||||||||||||||||||||
| 2006 | 0 | $self->{ UseColor } = 0; | |||||||||||||||||||||||||||||||||||||||||
| 2007 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 2008 | 0 | $self->{ UseColor } = 1; | |||||||||||||||||||||||||||||||||||||||||
| 2009 | 0 | unshift @argv, $_[1]; | |||||||||||||||||||||||||||||||||||||||||
| 2010 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2011 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 2012 | 0 | ▶ | 'no-color' => sub { $self->{ UseColor } = 0 }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 2013 | # update | ||||||||||||||||||||||||||||||||||||||||||
| 2014 | 'new-only' => \$self->{ NewOnly }, | ||||||||||||||||||||||||||||||||||||||||||
| 2015 | 'non-defaults' => \$self->{ NonDefaults }, | ||||||||||||||||||||||||||||||||||||||||||
| 2016 | 'downloads=i' => \$self->{ Forks }, | ||||||||||||||||||||||||||||||||||||||||||
| 2017 | 'unconditional' => \$self->{ Unconditional }, | ||||||||||||||||||||||||||||||||||||||||||
| 2018 | 'limit-rate=s' => \$self->{ RateLimit }, | ||||||||||||||||||||||||||||||||||||||||||
| 2019 | 'user-agent=s' => \$self->{ UserAgent }, | ||||||||||||||||||||||||||||||||||||||||||
| 2020 | 'timeout=f' => \$self->{ Timeout }, | ||||||||||||||||||||||||||||||||||||||||||
| 2021 | 'proxy=s' => \$self->{ Proxy }, | ||||||||||||||||||||||||||||||||||||||||||
| 2022 | 'proxy-user=s' => \$self->{ ProxyUser }, | ||||||||||||||||||||||||||||||||||||||||||
| 2023 | 'hard' => \$self->{ HardReload }, | ||||||||||||||||||||||||||||||||||||||||||
| 2024 | # read | ||||||||||||||||||||||||||||||||||||||||||
| 2025 | 'pager=s' => \$self->{ Pager }, | ||||||||||||||||||||||||||||||||||||||||||
| 2026 | 'no-mark' => \$self->{ NoMark }, # open, too | ||||||||||||||||||||||||||||||||||||||||||
| 2027 | 'stdout' => \$self->{ Stdout }, | ||||||||||||||||||||||||||||||||||||||||||
| 2028 | 'width=i' => \$self->{ LineWidth }, | ||||||||||||||||||||||||||||||||||||||||||
| 2029 | 'read-format=s' => \$self->{ ReadFmt }, | ||||||||||||||||||||||||||||||||||||||||||
| 2030 | 'html' => \$self->{ ReadHtml }, | ||||||||||||||||||||||||||||||||||||||||||
| 2031 | # open | ||||||||||||||||||||||||||||||||||||||||||
| 2032 | 'browser=s' => \$self->{ Browser }, | ||||||||||||||||||||||||||||||||||||||||||
| 2033 | # look/unread | ||||||||||||||||||||||||||||||||||||||||||
| 2034 | 'title=s' => \$self->{ Title }, | ||||||||||||||||||||||||||||||||||||||||||
| 2035 | 'tag=s' => $self->{ Tags }, | ||||||||||||||||||||||||||||||||||||||||||
| 2036 | 'status=s' => \$self->{ Status }, # look only | ||||||||||||||||||||||||||||||||||||||||||
| 2037 | 'content=s' => $self->{ Content }, | ||||||||||||||||||||||||||||||||||||||||||
| 2038 | 'sort=s' => \$self->{ Sort }, | ||||||||||||||||||||||||||||||||||||||||||
| 2039 | 'reverse' => \$self->{ Reverse }, | ||||||||||||||||||||||||||||||||||||||||||
| 2040 | 'list-limit=i' => \$self->{ ListLimit }, | ||||||||||||||||||||||||||||||||||||||||||
| 2041 | 'hidden' => \$self->{ ShowHidden }, | ||||||||||||||||||||||||||||||||||||||||||
| 2042 | 0 | ▶ | 'list-format=s' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 2043 | 0 | $self->{ ListFmt } = $_[1]; | |||||||||||||||||||||||||||||||||||||||||
| 2044 | 0 | $self->{ ListUnreadFmt } = $_[1]; | |||||||||||||||||||||||||||||||||||||||||
| 2045 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 2046 | # mark | ||||||||||||||||||||||||||||||||||||||||||
| 2047 | 'all' => \$self->{ MarkAll }, | ||||||||||||||||||||||||||||||||||||||||||
| 2048 | # post | ||||||||||||||||||||||||||||||||||||||||||
| 2049 | 'post-format=s' => \$self->{ PostFmt }, | ||||||||||||||||||||||||||||||||||||||||||
| 2050 | # feeds | ||||||||||||||||||||||||||||||||||||||||||
| 2051 | 'brief' => \$self->{ Brief }, # groups, too | ||||||||||||||||||||||||||||||||||||||||||
| 2052 | 'feeds-format=s' => \$self->{ FeedsFmt }, | ||||||||||||||||||||||||||||||||||||||||||
| 2053 | # export/import | ||||||||||||||||||||||||||||||||||||||||||
| 2054 | 'no-groups' => \$self->{ NoGroups }, | ||||||||||||||||||||||||||||||||||||||||||
| 2055 | 'export-special' => \$self->{ ExportSpec }, | ||||||||||||||||||||||||||||||||||||||||||
| 2056 | # misc | ||||||||||||||||||||||||||||||||||||||||||
| 2057 | 0 | ▶ | 'help|h' => sub { _HELP(*STDOUT, 0) }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 2058 | 0 | ▶ | 'version|v' => sub { _VER(*STDOUT, 0) }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 2059 | 0 | ▶ | '<>' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||
| 2060 | 0 | ▶ | if (not defined $self->{ Cmd } and $_[0] !~ /^-/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $self->{'Cmd'} || $_[0] =~ /^-/u
MC/DC0%0/2
defined $self->{'Cmd'} || $_[0] =~ /^-/u
defined $self->{'Cmd'}
$_[0] =~ /^-/u
Truth table0%0/3
A || B
A= defined $self->{'Cmd'}B= $_[0] =~ /^-/u
| |||||||||||||||||||||||||||||||||||||||||||
| 2061 | 0 | $self->{ Cmd } = $_[0]; | |||||||||||||||||||||||||||||||||||||||||
| 2062 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 2063 | 0 | ▶ | if ($_[0] =~ /^[\-0-9]+$/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 2064 | # So that negative post arguments (-1, -2, etc.) do not get | ||||||||||||||||||||||||||||||||||||||||||
| 2065 | # treated like CLI flags. | ||||||||||||||||||||||||||||||||||||||||||
| 2066 | 0 | push @{ $self->{ Args } }, $_[0]; | |||||||||||||||||||||||||||||||||||||||||
| 2067 | } elsif ($_[0] !~ /^-/) { | ||||||||||||||||||||||||||||||||||||||||||
| 2068 | 0 | push @{ $self->{ Args } }, $_[0]; | |||||||||||||||||||||||||||||||||||||||||
| 2069 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 2070 | 0 | warn "Unknown option: $_[0]\n"; | |||||||||||||||||||||||||||||||||||||||||
| 2071 | 0 | _HELP(*STDERR, 1); | |||||||||||||||||||||||||||||||||||||||||
| 2072 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2073 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2074 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 2075 | 0 | ▶ | ) or _HELP(*STDERR, 1); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2076 | |||||||||||||||||||||||||||||||||||||||||||
| 2077 | 0 | bless $self, $class; | |||||||||||||||||||||||||||||||||||||||||
| 2078 | |||||||||||||||||||||||||||||||||||||||||||
| 2079 | 0 | ▶ | if (not defined $self->{ Cmd }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2080 | 0 | _HELP(*STDERR, 0); | |||||||||||||||||||||||||||||||||||||||||
| 2081 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2082 | |||||||||||||||||||||||||||||||||||||||||||
| 2083 | 0 | ▶ | unless (exists $COMMANDS{ $self->{ Cmd } }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2084 | 0 | die "'$self->{ Cmd }' is not a valid command\n"; | |||||||||||||||||||||||||||||||||||||||||
| 2085 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2086 | |||||||||||||||||||||||||||||||||||||||||||
| 2087 | 0 | ▶ | $self->{ ConfFile } //= _default_config; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->{"ConfFile"} //= _default_config()
MC/DC0%0/2
$self->{"ConfFile"} //= _default_config()
$self->{"ConfFile"}
_default_config()
Truth table0%0/3
A //= B
A= $self->{"ConfFile"}B= _default_config()
| |||||||||||||||||||||||||||||||||||||||||||
| 2088 | |||||||||||||||||||||||||||||||||||||||||||
| 2089 | 0 | ▶ | if ($self->{ Brief } and $self->{ Cmd } eq 'feeds') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->{"Brief"} and $self->{"Cmd"} eq "feeds"
MC/DC0%0/2
$self->{"Brief"} and $self->{"Cmd"} eq "feeds"
$self->{"Brief"}
$self->{"Cmd"} eq "feeds"
Truth table0%0/3
A and B
A= $self->{"Brief"}B= $self->{"Cmd"} eq "feeds"
| |||||||||||||||||||||||||||||||||||||||||||
| 2090 | 0 | $self->{ FeedsFmt } = '%f'; | |||||||||||||||||||||||||||||||||||||||||
| 2091 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2092 | |||||||||||||||||||||||||||||||||||||||||||
| 2093 | 0 | ▶ | if (defined $self->{ ConfFile }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2094 | 0 | $self->_read_config; | |||||||||||||||||||||||||||||||||||||||||
| 2095 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2096 | |||||||||||||||||||||||||||||||||||||||||||
| 2097 | 0 | ▶ | $self->{ DataDir } //= _default_data_dir; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->{"DataDir"} //= _default_data_dir()
MC/DC0%0/2
$self->{"DataDir"} //= _default_data_dir()
$self->{"DataDir"}
_default_data_dir()
Truth table0%0/3
A //= B
A= $self->{"DataDir"}B= _default_data_dir()
| |||||||||||||||||||||||||||||||||||||||||||
| 2098 | |||||||||||||||||||||||||||||||||||||||||||
| 2099 | 0 | ▶ | unless (-d $self->{ DataDir }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2100 | mkdir $self->{ DataDir } | ||||||||||||||||||||||||||||||||||||||||||
| 2101 | 0 | ▶ | or die "Failed to mkdir $self->{ DataDir }: $!\n"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2102 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2103 | |||||||||||||||||||||||||||||||||||||||||||
| 2104 | $self->{ FeedDir } = File::Spec->catfile( | ||||||||||||||||||||||||||||||||||||||||||
| 2105 | $self->{ DataDir }, | ||||||||||||||||||||||||||||||||||||||||||
| 2106 | 0 | 'feeds' | |||||||||||||||||||||||||||||||||||||||||
| 2107 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 2108 | |||||||||||||||||||||||||||||||||||||||||||
| 2109 | 0 | ▶ | unless (-d $self->{ FeedDir }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2110 | mkdir $self->{ FeedDir } | ||||||||||||||||||||||||||||||||||||||||||
| 2111 | 0 | ▶ | or die "Failed to mkdir $self->{ FeedDir }: $!\n"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2112 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2113 | |||||||||||||||||||||||||||||||||||||||||||
| 2114 | $self->{ EtagDir } = File::Spec->catfile( | ||||||||||||||||||||||||||||||||||||||||||
| 2115 | 0 | $self->{ DataDir }, 'etag' | |||||||||||||||||||||||||||||||||||||||||
| 2116 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 2117 | 0 | ▶ | unless (-d $self->{ EtagDir }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2118 | mkdir $self->{ EtagDir } | ||||||||||||||||||||||||||||||||||||||||||
| 2119 | 0 | ▶ | or die "Failed to mkdir $self->{ EtagDir }: $!\n"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2120 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2121 | |||||||||||||||||||||||||||||||||||||||||||
| 2122 | $self->{ RetryDir } = File::Spec->catfile( | ||||||||||||||||||||||||||||||||||||||||||
| 2123 | 0 | $self->{ DataDir }, 'retry' | |||||||||||||||||||||||||||||||||||||||||
| 2124 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 2125 | 0 | ▶ | if (not -d $self->{ RetryDir }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2126 | 0 | ▶ | unlink $self->{ RetryDir } if -f $self->{ RetryDir }; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2127 | mkdir $self->{ RetryDir } | ||||||||||||||||||||||||||||||||||||||||||
| 2128 | 0 | ▶ | or die "Failed to mkdir $self->{ RetryDir }: $!\n"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2129 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2130 | |||||||||||||||||||||||||||||||||||||||||||
| 2131 | 0 | ▶ | unless (exists $DOESNT_NEED_FEED{ $self->{ Cmd } }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2132 | 0 | ▶ | $self->{ FeedFile } //= _default_feeds; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->{"FeedFile"} //= _default_feeds()
MC/DC0%0/2
$self->{"FeedFile"} //= _default_feeds()
$self->{"FeedFile"}
_default_feeds()
Truth table0%0/3
A //= B
A= $self->{"FeedFile"}B= _default_feeds()
| |||||||||||||||||||||||||||||||||||||||||||
| 2133 | 0 | ▶ | unless (defined $self->{ FeedFile }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2134 | 0 | die "$PRGNAM could not find a feeds file to read a feed list from\n"; | |||||||||||||||||||||||||||||||||||||||||
| 2135 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2136 | 0 | ▶ | unless (-f $self->{ FeedFile }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2137 | 0 | die "$self->{ FeedFile } does not exist\n"; | |||||||||||||||||||||||||||||||||||||||||
| 2138 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2139 | # For _get_url 'file://' links, to know the file's relative directory if | ||||||||||||||||||||||||||||||||||||||||||
| 2140 | # the url is not absolute. | ||||||||||||||||||||||||||||||||||||||||||
| 2141 | 0 | $self->{ FeedFile } = File::Spec->rel2abs($self->{ FeedFile }); | |||||||||||||||||||||||||||||||||||||||||
| 2142 | 0 | $self->_read_feed_file; | |||||||||||||||||||||||||||||||||||||||||
| 2143 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2144 | |||||||||||||||||||||||||||||||||||||||||||
| 2145 | 0 | ▶ | $self->{ Forks } //= $DEFAULT_FORKS; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->{"Forks"} //= $DEFAULT_FORKS
MC/DC0%0/2
$self->{"Forks"} //= $DEFAULT_FORKS
$self->{"Forks"}
$DEFAULT_FORKS
Truth table0%0/3
A //= B
A= $self->{"Forks"}B= $DEFAULT_FORKS
| |||||||||||||||||||||||||||||||||||||||||||
| 2146 | |||||||||||||||||||||||||||||||||||||||||||
| 2147 | 0 | ▶ | unless ($self->{ Forks } > 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2148 | 0 | die "Download count must be greater than 0\n"; | |||||||||||||||||||||||||||||||||||||||||
| 2149 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2150 | |||||||||||||||||||||||||||||||||||||||||||
| 2151 | 0 | ▶ | $self->{ AutoClean } //= 0; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{"AutoClean"} //= 0
MC/DC0%0/1
$self->{"AutoClean"} //= 0
$self->{"AutoClean"}
Truth table0%0/2
A
A= $self->{"AutoClean"}
| |||||||||||||||||||||||||||||||||||||||||||
| 2152 | 0 | ▶ | $self->{ UserAgent } //= $DEFAULT_AGENT; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->{"UserAgent"} //= $DEFAULT_AGENT
MC/DC0%0/2
$self->{"UserAgent"} //= $DEFAULT_AGENT
$self->{"UserAgent"}
$DEFAULT_AGENT
Truth table0%0/3
A //= B
A= $self->{"UserAgent"}B= $DEFAULT_AGENT
| |||||||||||||||||||||||||||||||||||||||||||
| 2153 | 0 | ▶ | $self->{ Pager } //= $ENV{ PAGER } // $DEFAULT_PAGER; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
$self->{"Pager"} //= $ENV{"PAGER"} // $DEFAULT_PAGER
$ENV{"PAGER"} // $DEFAULT_PAGER
MC/DC0%0/3
$self->{"Pager"} //= $ENV{"PAGER"} // $DEFAULT_PAGER
$self->{"Pager"}
$ENV{"PAGER"}
$DEFAULT_PAGER
Truth table0%0/4
A //= B // C
A= $self->{"Pager"}B= $ENV{"PAGER"}C= $DEFAULT_PAGER
| |||||||||||||||||||||||||||||||||||||||||||
| 2154 | 0 | ▶ | $self->{ Browser } //= $ENV{ BROWSER } // 'lynx'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/5
$self->{"Browser"} //= $ENV{"BROWSER"} // "lynx"
$ENV{"BROWSER"} // "lynx"
MC/DC0%0/2
$self->{"Browser"} //= $ENV{"BROWSER"} // "lynx"
$self->{"Browser"}
$ENV{"BROWSER"}
Truth table0%0/3
A //= B
A= $self->{"Browser"}B= $ENV{"BROWSER"}
| |||||||||||||||||||||||||||||||||||||||||||
| 2155 | 0 | ▶ | $self->{ ListLimit } //= 0; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{"ListLimit"} //= 0
MC/DC0%0/1
$self->{"ListLimit"} //= 0
$self->{"ListLimit"}
Truth table0%0/2
A
A= $self->{"ListLimit"}
| |||||||||||||||||||||||||||||||||||||||||||
| 2156 | 0 | ▶ | $self->{ LineWidth } //= $DEFAULT_WIDTH; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->{"LineWidth"} //= $DEFAULT_WIDTH
MC/DC0%0/2
$self->{"LineWidth"} //= $DEFAULT_WIDTH
$self->{"LineWidth"}
$DEFAULT_WIDTH
Truth table0%0/3
A //= B
A= $self->{"LineWidth"}B= $DEFAULT_WIDTH
| |||||||||||||||||||||||||||||||||||||||||||
| 2157 | 0 | ▶ | $self->{ ReadFmt } //= $DEFAULT_READ_FMT; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->{"ReadFmt"} //= $DEFAULT_READ_FMT
MC/DC0%0/2
$self->{"ReadFmt"} //= $DEFAULT_READ_FMT
$self->{"ReadFmt"}
$DEFAULT_READ_FMT
Truth table0%0/3
A //= B
A= $self->{"ReadFmt"}B= $DEFAULT_READ_FMT
| |||||||||||||||||||||||||||||||||||||||||||
| 2158 | 0 | ▶ | $self->{ PostFmt } //= $DEFAULT_POST_FMT; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->{"PostFmt"} //= $DEFAULT_POST_FMT
MC/DC0%0/2
$self->{"PostFmt"} //= $DEFAULT_POST_FMT
$self->{"PostFmt"}
$DEFAULT_POST_FMT
Truth table0%0/3
A //= B
A= $self->{"PostFmt"}B= $DEFAULT_POST_FMT
| |||||||||||||||||||||||||||||||||||||||||||
| 2159 | 0 | ▶ | $self->{ FeedsFmt } //= $DEFAULT_FEED_FMT; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->{"FeedsFmt"} //= $DEFAULT_FEED_FMT
MC/DC0%0/2
$self->{"FeedsFmt"} //= $DEFAULT_FEED_FMT
$self->{"FeedsFmt"}
$DEFAULT_FEED_FMT
Truth table0%0/3
A //= B
A= $self->{"FeedsFmt"}B= $DEFAULT_FEED_FMT
| |||||||||||||||||||||||||||||||||||||||||||
| 2160 | |||||||||||||||||||||||||||||||||||||||||||
| 2161 | 0 | ▶ | unless ($self->{ LineWidth } > 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2162 | 0 | die "width must be greater than 0\n"; | |||||||||||||||||||||||||||||||||||||||||
| 2163 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2164 | |||||||||||||||||||||||||||||||||||||||||||
| 2165 | 0 | ▶ | if (defined $self->{ Status } and $self->{ Status } !~ /^(un)?read$/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $self->{"Status"} and not $self->{"Status"} =~ /^(un)?read$/u
MC/DC0%0/2
defined $self->{"Status"} and not $self->{"Status"} =~ /^(un)?read$/u
defined $self->{"Status"}
not $self->{"Status"} =~ /^(un)?read$/u
Truth table0%0/3
A and not(B)
A= defined $self->{"Status"}B= not $self->{"Status"} =~ /^(un)?read$/u
| |||||||||||||||||||||||||||||||||||||||||||
| 2166 | 0 | die "status must either be 'read' or 'unread'\n"; | |||||||||||||||||||||||||||||||||||||||||
| 2167 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2168 | |||||||||||||||||||||||||||||||||||||||||||
| 2169 | 0 | ▶ | $self->{ Sort } //= 'date'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{"Sort"} //= "date"
MC/DC0%0/1
$self->{"Sort"} //= "date"
$self->{"Sort"}
Truth table0%0/2
A
A= $self->{"Sort"}
| |||||||||||||||||||||||||||||||||||||||||||
| 2170 | |||||||||||||||||||||||||||||||||||||||||||
| 2171 | 0 | ▶ | unless (exists $VALID_SORTS{ $self->{ Sort } }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2172 | 0 | die sprintf | |||||||||||||||||||||||||||||||||||||||||
| 2173 | "--sort must be one of the following: %s\n", | ||||||||||||||||||||||||||||||||||||||||||
| 2174 | join(', ', sort keys %VALID_SORTS); | ||||||||||||||||||||||||||||||||||||||||||
| 2175 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2176 | |||||||||||||||||||||||||||||||||||||||||||
| 2177 | 0 | ▶ | if (defined $self->{ RateLimit } and $self->{ RateLimit } !~ $RATE_RX) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $self->{"RateLimit"} and not $self->{"RateLimit"} =~ /$RATE_RX/u
MC/DC0%0/2
defined $self->{"RateLimit"} and not $self->{"RateLimit"} =~ /$RATE_RX/u
defined $self->{"RateLimit"}
not $self->{"RateLimit"} =~ /$RATE_RX/u
Truth table0%0/3
A and not(B)
A= defined $self->{"RateLimit"}B= not $self->{"RateLimit"} =~ /$RATE_RX/u
| |||||||||||||||||||||||||||||||||||||||||||
| 2178 | 0 | die "Invalid argument to --limit-rate\n"; | |||||||||||||||||||||||||||||||||||||||||
| 2179 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2180 | |||||||||||||||||||||||||||||||||||||||||||
| 2181 | 0 | ▶ | unless ($DOESNT_NEED_FEED{ $self->{ Cmd } }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2182 | $self->{ DB } = WWW::Noss::DB->new( | ||||||||||||||||||||||||||||||||||||||||||
| 2183 | 0 | File::Spec->catfile($self->{ DataDir }, 'database.sqlite3') | |||||||||||||||||||||||||||||||||||||||||
| 2184 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 2185 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2186 | |||||||||||||||||||||||||||||||||||||||||||
| 2187 | 0 | ▶ | if (defined $self->{ TimeFmt }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2188 | 0 | _set_z_fmt($self->{ TimeFmt }); | |||||||||||||||||||||||||||||||||||||||||
| 2189 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2190 | |||||||||||||||||||||||||||||||||||||||||||
| 2191 | 0 | ▶ | if (not defined $self->{ UseColor }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2192 | 0 | ▶ | if (-t STDOUT) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2193 | 0 | $self->{ UseColor } = 1; | |||||||||||||||||||||||||||||||||||||||||
| 2194 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 2195 | 0 | $self->{ UseColor } = 0; | |||||||||||||||||||||||||||||||||||||||||
| 2196 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2197 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2198 | |||||||||||||||||||||||||||||||||||||||||||
| 2199 | # Windows terminals do not support ANSI color codes. | ||||||||||||||||||||||||||||||||||||||||||
| 2200 | 0 | ▶ | if ($^O eq 'MSWin32') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2201 | 0 | $self->{ UseColor } = 0; | |||||||||||||||||||||||||||||||||||||||||
| 2202 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2203 | |||||||||||||||||||||||||||||||||||||||||||
| 2204 | 0 | ▶ | if (not defined $self->{ Timeout }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2205 | 0 | $self->{ Timeout } = 45; | |||||||||||||||||||||||||||||||||||||||||
| 2206 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2207 | |||||||||||||||||||||||||||||||||||||||||||
| 2208 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 2209 | |||||||||||||||||||||||||||||||||||||||||||
| 2210 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2211 | |||||||||||||||||||||||||||||||||||||||||||
| 2212 | 0 | ▶ | sub run { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 2213 | |||||||||||||||||||||||||||||||||||||||||||
| 2214 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 2215 | |||||||||||||||||||||||||||||||||||||||||||
| 2216 | 0 | $COMMANDS{ $self->{ Cmd } }->($self); | |||||||||||||||||||||||||||||||||||||||||
| 2217 | |||||||||||||||||||||||||||||||||||||||||||
| 2218 | 0 | ▶ | if ($self->{ AutoClean } and not $DOESNT_NEED_FEED{ $self->{ Cmd } }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->{"AutoClean"} and not $DOESNT_NEED_FEED{$self->{"Cmd"}}
MC/DC0%0/2
$self->{"AutoClean"} and not $DOESNT_NEED_FEED{$self->{"Cmd"}}
$self->{"AutoClean"}
not $DOESNT_NEED_FEED{$self->{"Cmd"}}
Truth table0%0/3
A and not(B)
A= $self->{"AutoClean"}B= not $DOESNT_NEED_FEED{$self->{"Cmd"}}
| |||||||||||||||||||||||||||||||||||||||||||
| 2219 | 0 | $self->clean; | |||||||||||||||||||||||||||||||||||||||||
| 2220 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2221 | |||||||||||||||||||||||||||||||||||||||||||
| 2222 | # Delete outdated retry caches | ||||||||||||||||||||||||||||||||||||||||||
| 2223 | 0 | my $now = time; | |||||||||||||||||||||||||||||||||||||||||
| 2224 | 0 | for my $f (values %{ $self->{ Feeds } }) { | |||||||||||||||||||||||||||||||||||||||||
| 2225 | 0 | my $retry = $f->retry; | |||||||||||||||||||||||||||||||||||||||||
| 2226 | 0 | ▶ | next if not defined $retry; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2227 | 0 | ▶ | if ($now >= $retry) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2228 | 0 | ▶ | unlink $f->retry_cache | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2229 | or warn sprintf "Failed to unlink %s: %s\n", $f->retry_cache, $!; | ||||||||||||||||||||||||||||||||||||||||||
| 2230 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2231 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2232 | |||||||||||||||||||||||||||||||||||||||||||
| 2233 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 2234 | |||||||||||||||||||||||||||||||||||||||||||
| 2235 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2236 | |||||||||||||||||||||||||||||||||||||||||||
| 2237 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 2238 | |||||||||||||||||||||||||||||||||||||||||||
| 2239 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||
| 2240 | |||||||||||||||||||||||||||||||||||||||||||
| 2241 | WWW::Noss - RSS/Atom feed reader and aggregator | ||||||||||||||||||||||||||||||||||||||||||
| 2242 | |||||||||||||||||||||||||||||||||||||||||||
| 2243 | =head1 USAGE | ||||||||||||||||||||||||||||||||||||||||||
| 2244 | |||||||||||||||||||||||||||||||||||||||||||
| 2245 | use WWW::Noss; | ||||||||||||||||||||||||||||||||||||||||||
| 2246 | |||||||||||||||||||||||||||||||||||||||||||
| 2247 | my $noss = WWW::Noss->init(@ARGV); | ||||||||||||||||||||||||||||||||||||||||||
| 2248 | $noss->run; | ||||||||||||||||||||||||||||||||||||||||||
| 2249 | |||||||||||||||||||||||||||||||||||||||||||
| 2250 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||
| 2251 | |||||||||||||||||||||||||||||||||||||||||||
| 2252 | B<WWW::Noss> is the backend module providing L<noss>'s functionality. This is | ||||||||||||||||||||||||||||||||||||||||||
| 2253 | a private module, please consult the L<noss> manual for user documentation. | ||||||||||||||||||||||||||||||||||||||||||
| 2254 | |||||||||||||||||||||||||||||||||||||||||||
| 2255 | =head1 METHODS | ||||||||||||||||||||||||||||||||||||||||||
| 2256 | |||||||||||||||||||||||||||||||||||||||||||
| 2257 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||
| 2258 | |||||||||||||||||||||||||||||||||||||||||||
| 2259 | =item $noss = WWW::Noss->init(@argv) | ||||||||||||||||||||||||||||||||||||||||||
| 2260 | |||||||||||||||||||||||||||||||||||||||||||
| 2261 | Reads command-line arguments from C<@argv> and returns a blessed B<WWW::Noss> | ||||||||||||||||||||||||||||||||||||||||||
| 2262 | object. You would usually pass C<@ARGV> to it. | ||||||||||||||||||||||||||||||||||||||||||
| 2263 | |||||||||||||||||||||||||||||||||||||||||||
| 2264 | Consult the L<noss> manual for documentation on what options/arguments are | ||||||||||||||||||||||||||||||||||||||||||
| 2265 | available. | ||||||||||||||||||||||||||||||||||||||||||
| 2266 | |||||||||||||||||||||||||||||||||||||||||||
| 2267 | =item $noss->run() | ||||||||||||||||||||||||||||||||||||||||||
| 2268 | |||||||||||||||||||||||||||||||||||||||||||
| 2269 | Runs L<noss> based on the parameters processed during C<init()>. | ||||||||||||||||||||||||||||||||||||||||||
| 2270 | |||||||||||||||||||||||||||||||||||||||||||
| 2271 | =item $noss->update() | ||||||||||||||||||||||||||||||||||||||||||
| 2272 | |||||||||||||||||||||||||||||||||||||||||||
| 2273 | Method implementing the C<update> command. | ||||||||||||||||||||||||||||||||||||||||||
| 2274 | |||||||||||||||||||||||||||||||||||||||||||
| 2275 | =item $noss->reload() | ||||||||||||||||||||||||||||||||||||||||||
| 2276 | |||||||||||||||||||||||||||||||||||||||||||
| 2277 | Method implementing the C<reload> command. | ||||||||||||||||||||||||||||||||||||||||||
| 2278 | |||||||||||||||||||||||||||||||||||||||||||
| 2279 | =item $noss->read_post() | ||||||||||||||||||||||||||||||||||||||||||
| 2280 | |||||||||||||||||||||||||||||||||||||||||||
| 2281 | Method implementing the C<read> command. | ||||||||||||||||||||||||||||||||||||||||||
| 2282 | |||||||||||||||||||||||||||||||||||||||||||
| 2283 | =item $noss->open_post() | ||||||||||||||||||||||||||||||||||||||||||
| 2284 | |||||||||||||||||||||||||||||||||||||||||||
| 2285 | Method implementing the C<open> command. | ||||||||||||||||||||||||||||||||||||||||||
| 2286 | |||||||||||||||||||||||||||||||||||||||||||
| 2287 | =item $noss->cat() | ||||||||||||||||||||||||||||||||||||||||||
| 2288 | |||||||||||||||||||||||||||||||||||||||||||
| 2289 | Method implementing the C<cat> command. | ||||||||||||||||||||||||||||||||||||||||||
| 2290 | |||||||||||||||||||||||||||||||||||||||||||
| 2291 | =item $noss->look() | ||||||||||||||||||||||||||||||||||||||||||
| 2292 | |||||||||||||||||||||||||||||||||||||||||||
| 2293 | Method implementing the C<list> command. | ||||||||||||||||||||||||||||||||||||||||||
| 2294 | |||||||||||||||||||||||||||||||||||||||||||
| 2295 | =item $noss->unread() | ||||||||||||||||||||||||||||||||||||||||||
| 2296 | |||||||||||||||||||||||||||||||||||||||||||
| 2297 | Method implementing the C<unread> command. | ||||||||||||||||||||||||||||||||||||||||||
| 2298 | |||||||||||||||||||||||||||||||||||||||||||
| 2299 | =item $noss->mark() | ||||||||||||||||||||||||||||||||||||||||||
| 2300 | |||||||||||||||||||||||||||||||||||||||||||
| 2301 | Method implementing the C<mark> command. | ||||||||||||||||||||||||||||||||||||||||||
| 2302 | |||||||||||||||||||||||||||||||||||||||||||
| 2303 | =item $noss->post() | ||||||||||||||||||||||||||||||||||||||||||
| 2304 | |||||||||||||||||||||||||||||||||||||||||||
| 2305 | Method implementing the C<post> command. | ||||||||||||||||||||||||||||||||||||||||||
| 2306 | |||||||||||||||||||||||||||||||||||||||||||
| 2307 | =item $noss->feeds() | ||||||||||||||||||||||||||||||||||||||||||
| 2308 | |||||||||||||||||||||||||||||||||||||||||||
| 2309 | Method implementing the C<feeds> command. | ||||||||||||||||||||||||||||||||||||||||||
| 2310 | |||||||||||||||||||||||||||||||||||||||||||
| 2311 | =item $noss->groups() | ||||||||||||||||||||||||||||||||||||||||||
| 2312 | |||||||||||||||||||||||||||||||||||||||||||
| 2313 | Method implementing the C<groups> command. | ||||||||||||||||||||||||||||||||||||||||||
| 2314 | |||||||||||||||||||||||||||||||||||||||||||
| 2315 | =item $noss->clean() | ||||||||||||||||||||||||||||||||||||||||||
| 2316 | |||||||||||||||||||||||||||||||||||||||||||
| 2317 | Method implementing the C<clean> command. | ||||||||||||||||||||||||||||||||||||||||||
| 2318 | |||||||||||||||||||||||||||||||||||||||||||
| 2319 | =item $noss->discover() | ||||||||||||||||||||||||||||||||||||||||||
| 2320 | |||||||||||||||||||||||||||||||||||||||||||
| 2321 | Method implementing the C<discover> command. | ||||||||||||||||||||||||||||||||||||||||||
| 2322 | |||||||||||||||||||||||||||||||||||||||||||
| 2323 | =item $noss->export_opml() | ||||||||||||||||||||||||||||||||||||||||||
| 2324 | |||||||||||||||||||||||||||||||||||||||||||
| 2325 | Method implementing the C<export> command. | ||||||||||||||||||||||||||||||||||||||||||
| 2326 | |||||||||||||||||||||||||||||||||||||||||||
| 2327 | =item $noss->import_opml() | ||||||||||||||||||||||||||||||||||||||||||
| 2328 | |||||||||||||||||||||||||||||||||||||||||||
| 2329 | Method implementing the C<import> command. | ||||||||||||||||||||||||||||||||||||||||||
| 2330 | |||||||||||||||||||||||||||||||||||||||||||
| 2331 | =item $noss->help() | ||||||||||||||||||||||||||||||||||||||||||
| 2332 | |||||||||||||||||||||||||||||||||||||||||||
| 2333 | Method implementing the C<help> command. | ||||||||||||||||||||||||||||||||||||||||||
| 2334 | |||||||||||||||||||||||||||||||||||||||||||
| 2335 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 2336 | |||||||||||||||||||||||||||||||||||||||||||
| 2337 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||
| 2338 | |||||||||||||||||||||||||||||||||||||||||||
| 2339 | Written by Samuel Young, E<lt>samyoung12788@gmail.comE<gt>. | ||||||||||||||||||||||||||||||||||||||||||
| 2340 | |||||||||||||||||||||||||||||||||||||||||||
| 2341 | This project's source can be found on its | ||||||||||||||||||||||||||||||||||||||||||
| 2342 | L<Codeberg page|https://codeberg.org/1-1sam/noss.git>. Comments and pull | ||||||||||||||||||||||||||||||||||||||||||
| 2343 | requests are welcome! | ||||||||||||||||||||||||||||||||||||||||||
| 2344 | |||||||||||||||||||||||||||||||||||||||||||
| 2345 | =head1 COPYRIGHT | ||||||||||||||||||||||||||||||||||||||||||
| 2346 | |||||||||||||||||||||||||||||||||||||||||||
| 2347 | Copyright (C) 2025-2026 Samuel Young | ||||||||||||||||||||||||||||||||||||||||||
| 2348 | |||||||||||||||||||||||||||||||||||||||||||
| 2349 | This program is free software: you can redistribute it and/or modify | ||||||||||||||||||||||||||||||||||||||||||
| 2350 | it under the terms of the GNU General Public License as published by | ||||||||||||||||||||||||||||||||||||||||||
| 2351 | the Free Software Foundation, either version 3 of the License, or | ||||||||||||||||||||||||||||||||||||||||||
| 2352 | (at your option) any later version. | ||||||||||||||||||||||||||||||||||||||||||
| 2353 | |||||||||||||||||||||||||||||||||||||||||||
| 2354 | =head1 SEE ALSO | ||||||||||||||||||||||||||||||||||||||||||
| 2355 | |||||||||||||||||||||||||||||||||||||||||||
| 2356 | L<noss> | ||||||||||||||||||||||||||||||||||||||||||
| 2357 | |||||||||||||||||||||||||||||||||||||||||||
| 2358 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 2359 | |||||||||||||||||||||||||||||||||||||||||||
| 2360 | # vim: expandtab shiftwidth=4 | ||||||||||||||||||||||||||||||||||||||||||