| 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.03'; | |||||||||||||||||||||||||||||||||||||||||
| 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::GroupConfig; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | 1 | ▶ | use WWW::Noss::Home qw(home); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 26 | 1 | ▶ | use WWW::Noss::Lynx qw(lynx_dump); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 27 | 1 | ▶ | use WWW::Noss::OPML; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 28 | 1 | ▶ | use WWW::Noss::TextToHtml qw(escape_html); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 29 | 1 | ▶ | use WWW::Noss::Util qw(dir resolve_url); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||
| 31 | 1 | my $PRGNAM = 'noss'; | |||||||||||||||||||||||||||||||||||||||||
| 32 | 1 | my $PRGVER = $VERSION; | |||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||
| 34 | # TODO: Command aliases? | ||||||||||||||||||||||||||||||||||||||||||
| 35 | # TODO: "open" feed setting? (command to use for opening post URLs) | ||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||
| 37 | # TODO: Have list --limit ... only show the latest posts rather than earliest | ||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||
| 39 | 1 | my %COMMANDS = ( | |||||||||||||||||||||||||||||||||||||||||
| 40 | 'update' => \&update, | ||||||||||||||||||||||||||||||||||||||||||
| 41 | 'reload' => \&reload, | ||||||||||||||||||||||||||||||||||||||||||
| 42 | 'read' => \&read_post, | ||||||||||||||||||||||||||||||||||||||||||
| 43 | 'open' => \&open_post, | ||||||||||||||||||||||||||||||||||||||||||
| 44 | 'cat' => \&cat, | ||||||||||||||||||||||||||||||||||||||||||
| 45 | 'list' => \&look, | ||||||||||||||||||||||||||||||||||||||||||
| 46 | 'unread' => \&unread, | ||||||||||||||||||||||||||||||||||||||||||
| 47 | 'mark' => \&mark, | ||||||||||||||||||||||||||||||||||||||||||
| 48 | 'post' => \&post, | ||||||||||||||||||||||||||||||||||||||||||
| 49 | 'feeds' => \&feeds, | ||||||||||||||||||||||||||||||||||||||||||
| 50 | 'groups' => \&groups, | ||||||||||||||||||||||||||||||||||||||||||
| 51 | 'clean' => \&clean, | ||||||||||||||||||||||||||||||||||||||||||
| 52 | 'discover' => \&discover, | ||||||||||||||||||||||||||||||||||||||||||
| 53 | 'export' => \&export_opml, | ||||||||||||||||||||||||||||||||||||||||||
| 54 | 'import' => \&import_opml, | ||||||||||||||||||||||||||||||||||||||||||
| 55 | 'help' => \&help, | ||||||||||||||||||||||||||||||||||||||||||
| 56 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||
| 58 | 1 | my $DOT_LOCAL = File::Spec->catfile(home, '.local/share'); | |||||||||||||||||||||||||||||||||||||||||
| 59 | 1 | my $DOT_CONFIG = File::Spec->catfile(home, '.config'); | |||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||
| 61 | 1 | my $DEFAULT_AGENT = "$PRGNAM/$PRGVER ($^O; perl $^V)"; | |||||||||||||||||||||||||||||||||||||||||
| 62 | 1 | ▶ | my $DEFAULT_PAGER = $^O eq 'MSWin32' ? 'more' : 'less'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 63 | 1 | my $DEFAULT_FORKS = 10; | |||||||||||||||||||||||||||||||||||||||||
| 64 | 1 | my $DEFAULT_WIDTH = 80; | |||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||
| 66 | 1 | my %VALID_SORTS = map { $_ => 1 } qw( | |||||||||||||||||||||||||||||||||||||||||
| 67 | feed | ||||||||||||||||||||||||||||||||||||||||||
| 68 | title | ||||||||||||||||||||||||||||||||||||||||||
| 69 | date | ||||||||||||||||||||||||||||||||||||||||||
| 70 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||
| 72 | 1 | my $Z_FMT = '%c'; | |||||||||||||||||||||||||||||||||||||||||
| 73 | 1 | my $Z_UNK = strftime($Z_FMT, localtime 0) =~ s/\w/?/gr; | |||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||
| 75 | 1 | my $RATE_RX = qr/^\d+[kmg]?$/i; | |||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||
| 77 | my %POST_FMT_CODES = ( | ||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | ▶ | '%' => sub { '%' }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | ▶ | 'f' => sub { $_[0]->{ feed } }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | ▶ | 'i' => sub { $_[0]->{ nossid } }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 81 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||
| 82 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||
| 83 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | ▶ | 'c' => sub { join ', ', @{ $_[0]->{ category } } }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | ▶ | 's' => sub { $_[0]->{ status } eq 'read' ? 'r' : 'U' }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | ▶ | 'S' => sub { $_[0]->{ status } eq 'read' ? 'read' : 'unread' }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 87 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||
| 88 | 'C' => sub { | ||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | ▶ | strftime('%c', localtime($_[0]->{ updated } // $_[0]->{ published } // return 'N/A')) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
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"}
| |||||||||||||||||||||||||||||||||||||||||||
| 90 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 91 | 'd' => sub { | ||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | ▶ | strftime('%d', localtime($_[0]->{ updated } // $_[0]->{ published } // return '??')) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
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"}
| |||||||||||||||||||||||||||||||||||||||||||
| 93 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 94 | 'w' => sub { | ||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | ▶ | strftime('%a', localtime($_[0]->{ updated } // $_[0]->{ published } // return '???')) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
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"}
| |||||||||||||||||||||||||||||||||||||||||||
| 96 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 97 | 'W' => sub { | ||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | ▶ | strftime('%A', localtime($_[0]->{ updated } // $_[0]->{ published } // return '???')) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
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"}
| |||||||||||||||||||||||||||||||||||||||||||
| 99 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 100 | 'm' => sub { | ||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | ▶ | strftime('%b', localtime($_[0]->{ updated } // $_[0]->{ published } // return '???')) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
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"}
| |||||||||||||||||||||||||||||||||||||||||||
| 102 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 103 | 'M' => sub { | ||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | ▶ | strftime('%B', localtime($_[0]->{ updated } // $_[0]->{ published } // return '???')) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
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"}
| |||||||||||||||||||||||||||||||||||||||||||
| 105 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 106 | 'n' => sub { | ||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | ▶ | strftime('%m', localtime($_[0]->{ updated } // $_[0]->{ published } // return '??')) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
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"}
| |||||||||||||||||||||||||||||||||||||||||||
| 108 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 109 | 'y' => sub { | ||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | ▶ | strftime('%g', localtime($_[0]->{ updated } // $_[0]->{ published } // return '??')) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
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"}
| |||||||||||||||||||||||||||||||||||||||||||
| 111 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 112 | 'Y' => sub { | ||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | ▶ | strftime('%G', localtime($_[0]->{ updated } // $_[0]->{ published } // return '????')) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
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"}
| |||||||||||||||||||||||||||||||||||||||||||
| 114 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 115 | 'z' => sub { | ||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | ▶ | my $t = $_[0]->{ updated } // $_[0]->{ published }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
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"}
| |||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | ▶ | if (defined $t) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | return strftime($Z_FMT, localtime $t); | |||||||||||||||||||||||||||||||||||||||||
| 119 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | return $Z_UNK; | |||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||
| 122 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 123 | 1 | ); | |||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||
| 125 | my %FEED_FMT_CODES = ( | ||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | ▶ | '%' => sub { '%' }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | ▶ | 'f' => sub { $_[0]->{ nossname } }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | ▶ | 'l' => sub { $_[0]->{ nosslink } }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 129 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||
| 130 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||
| 131 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||
| 132 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||
| 133 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||
| 134 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||
| 135 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||
| 136 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||
| 137 | 'C' => sub { | ||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | ▶ | strftime('%c', localtime($_[0]->{ updated } // return 'N/A')) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
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"}
| |||||||||||||||||||||||||||||||||||||||||||
| 139 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 140 | 'd' => sub { | ||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | ▶ | strftime('%d', localtime($_[0]->{ updated } // return '??')) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Condition0%0/2
$_[0]{"updated"} // (return "??")
MC/DC0%0/1
$_[0]{"updated"} // (return "??")
$_[0]{"updated"}
Truth table0%0/2
A
A= $_[0]{"updated"}
| |||||||||||||||||||||||||||||||||||||||||||
| 142 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 143 | 'w' => sub { | ||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | ▶ | strftime('%a', localtime($_[0]->{ updated } // return '???')) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Condition0%0/2
$_[0]{"updated"} // (return "???")
MC/DC0%0/1
$_[0]{"updated"} // (return "???")
$_[0]{"updated"}
Truth table0%0/2
A
A= $_[0]{"updated"}
| |||||||||||||||||||||||||||||||||||||||||||
| 145 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 146 | 'W' => sub { | ||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | ▶ | strftime('%A', localtime($_[0]->{ updated } // return '???')) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Condition0%0/2
$_[0]{"updated"} // (return "???")
MC/DC0%0/1
$_[0]{"updated"} // (return "???")
$_[0]{"updated"}
Truth table0%0/2
A
A= $_[0]{"updated"}
| |||||||||||||||||||||||||||||||||||||||||||
| 148 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 149 | 'm' => sub { | ||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | ▶ | strftime('%b', localtime($_[0]->{ updated } // return '???')) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Condition0%0/2
$_[0]{"updated"} // (return "???")
MC/DC0%0/1
$_[0]{"updated"} // (return "???")
$_[0]{"updated"}
Truth table0%0/2
A
A= $_[0]{"updated"}
| |||||||||||||||||||||||||||||||||||||||||||
| 151 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 152 | 'M' => sub { | ||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | ▶ | strftime('%B', localtime($_[0]->{ updated } // return '???')) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Condition0%0/2
$_[0]{"updated"} // (return "???")
MC/DC0%0/1
$_[0]{"updated"} // (return "???")
$_[0]{"updated"}
Truth table0%0/2
A
A= $_[0]{"updated"}
| |||||||||||||||||||||||||||||||||||||||||||
| 154 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 155 | 'n' => sub { | ||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | ▶ | strftime('%m', localtime($_[0]->{ updated } // return '??')) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Condition0%0/2
$_[0]{"updated"} // (return "??")
MC/DC0%0/1
$_[0]{"updated"} // (return "??")
$_[0]{"updated"}
Truth table0%0/2
A
A= $_[0]{"updated"}
| |||||||||||||||||||||||||||||||||||||||||||
| 157 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 158 | 'y' => sub { | ||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | ▶ | strftime('%g', localtime($_[0]->{ updated } // return '??')) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Condition0%0/2
$_[0]{"updated"} // (return "??")
MC/DC0%0/1
$_[0]{"updated"} // (return "??")
$_[0]{"updated"}
Truth table0%0/2
A
A= $_[0]{"updated"}
| |||||||||||||||||||||||||||||||||||||||||||
| 160 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 161 | 'Y' => sub { | ||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | ▶ | strftime('%G', localtime($_[0]->{ updated } // return '????')) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Condition0%0/2
$_[0]{"updated"} // (return "????")
MC/DC0%0/1
$_[0]{"updated"} // (return "????")
$_[0]{"updated"}
Truth table0%0/2
A
A= $_[0]{"updated"}
| |||||||||||||||||||||||||||||||||||||||||||
| 163 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 164 | 'z' => sub { | ||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | ▶ | my $t = $_[0]->{ updated }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | ▶ | if (defined $t) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | return strftime($Z_FMT, localtime $t); | |||||||||||||||||||||||||||||||||||||||||
| 168 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | return $Z_UNK; | |||||||||||||||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||||||||||||||||
| 171 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 172 | 1 | ); | |||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||
| 174 | 1 | my $DEFAULT_READ_FMT = <<'HERE'; | |||||||||||||||||||||||||||||||||||||||||
| 175 | <h1>%f - %t</h1> | ||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||
| 177 | <div> | ||||||||||||||||||||||||||||||||||||||||||
| 178 | %P | ||||||||||||||||||||||||||||||||||||||||||
| 179 | </div> | ||||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||
| 181 | <p> | ||||||||||||||||||||||||||||||||||||||||||
| 182 | Link: %u | ||||||||||||||||||||||||||||||||||||||||||
| 183 | </p> | ||||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||
| 185 | <p> | ||||||||||||||||||||||||||||||||||||||||||
| 186 | Updated: %z | ||||||||||||||||||||||||||||||||||||||||||
| 187 | </p> | ||||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||
| 189 | HERE | ||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||
| 191 | 1 | my $DEFAULT_POST_FMT = <<'HERE'; | |||||||||||||||||||||||||||||||||||||||||
| 192 | <14>%f<0>:<15>%i<0> | ||||||||||||||||||||||||||||||||||||||||||
| 193 | <16>Title<0>: %t | ||||||||||||||||||||||||||||||||||||||||||
| 194 | <16>Link<0>: %u | ||||||||||||||||||||||||||||||||||||||||||
| 195 | <16>Author<0>: %a | ||||||||||||||||||||||||||||||||||||||||||
| 196 | <16>Tags<0>: %c | ||||||||||||||||||||||||||||||||||||||||||
| 197 | <16>Updated<0>: %z | ||||||||||||||||||||||||||||||||||||||||||
| 198 | <16>Status<0>: %S | ||||||||||||||||||||||||||||||||||||||||||
| 199 | HERE | ||||||||||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||||||||||
| 201 | 1 | my $DEFAULT_FEED_FMT = <<'HERE'; | |||||||||||||||||||||||||||||||||||||||||
| 202 | <14>%f<0> | ||||||||||||||||||||||||||||||||||||||||||
| 203 | <16>Title<0>: %t | ||||||||||||||||||||||||||||||||||||||||||
| 204 | <16>Source<0>: %l | ||||||||||||||||||||||||||||||||||||||||||
| 205 | <16>Link<0>: %u | ||||||||||||||||||||||||||||||||||||||||||
| 206 | <16>Author<0>: %a | ||||||||||||||||||||||||||||||||||||||||||
| 207 | <16>Updated<0>: %z | ||||||||||||||||||||||||||||||||||||||||||
| 208 | <16>Posts<0>: %p | ||||||||||||||||||||||||||||||||||||||||||
| 209 | <16>Unread<0>: %U/%p | ||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||
| 211 | HERE | ||||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||
| 213 | 1 | my %DOESNT_NEED_FEED = map { $_ => 1 } qw( | |||||||||||||||||||||||||||||||||||||||||
| 214 | discover import help | ||||||||||||||||||||||||||||||||||||||||||
| 215 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||
| 217 | 1 | my $COLOR_CODE_RX = qr/(?:1[0-6]|[0-9])/; | |||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||
| 219 | 1 | my %COLOR_CODES = ( | |||||||||||||||||||||||||||||||||||||||||
| 220 | 0 => 'clear', | ||||||||||||||||||||||||||||||||||||||||||
| 221 | 1 => 'black', | ||||||||||||||||||||||||||||||||||||||||||
| 222 | 2 => 'red', | ||||||||||||||||||||||||||||||||||||||||||
| 223 | 3 => 'green', | ||||||||||||||||||||||||||||||||||||||||||
| 224 | 4 => 'yellow', | ||||||||||||||||||||||||||||||||||||||||||
| 225 | 5 => 'blue', | ||||||||||||||||||||||||||||||||||||||||||
| 226 | 6 => 'magenta', | ||||||||||||||||||||||||||||||||||||||||||
| 227 | 7 => 'cyan', | ||||||||||||||||||||||||||||||||||||||||||
| 228 | 8 => 'white', | ||||||||||||||||||||||||||||||||||||||||||
| 229 | 9 => 'bold black', | ||||||||||||||||||||||||||||||||||||||||||
| 230 | 10 => 'bold red', | ||||||||||||||||||||||||||||||||||||||||||
| 231 | 11 => 'bold green', | ||||||||||||||||||||||||||||||||||||||||||
| 232 | 12 => 'bold yellow', | ||||||||||||||||||||||||||||||||||||||||||
| 233 | 13 => 'bold blue', | ||||||||||||||||||||||||||||||||||||||||||
| 234 | 14 => 'bold magenta', | ||||||||||||||||||||||||||||||||||||||||||
| 235 | 15 => 'bold cyan', | ||||||||||||||||||||||||||||||||||||||||||
| 236 | 16 => 'bold white', | ||||||||||||||||||||||||||||||||||||||||||
| 237 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||||
| 239 | sub _HELP { | ||||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | ▶ | my ($fh, $rt) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_HELP: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | pod2usage( | |||||||||||||||||||||||||||||||||||||||||
| 244 | -exitval => 'NOEXIT', | ||||||||||||||||||||||||||||||||||||||||||
| 245 | -verbose => 99, | ||||||||||||||||||||||||||||||||||||||||||
| 246 | -sections => 'SYNOPSIS', | ||||||||||||||||||||||||||||||||||||||||||
| 247 | -output => \$fh, | ||||||||||||||||||||||||||||||||||||||||||
| 248 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||
| 250 | 0 | ▶ | if (defined $rt) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | exit $rt; | |||||||||||||||||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||
| 256 | sub _VER { | ||||||||||||||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | ▶ | my ($fh, $rt) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_VER: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | print { $fh } <<"HERE"; | |||||||||||||||||||||||||||||||||||||||||
| 261 | $PRGNAM - $PRGVER | ||||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||
| 263 | Copyright (C) 2025-2026 Samuel Young | ||||||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||||||
| 265 | This program is free software: you can redistribute it and/or modify | ||||||||||||||||||||||||||||||||||||||||||
| 266 | it under the terms of the GNU General Public License as published by | ||||||||||||||||||||||||||||||||||||||||||
| 267 | the Free Software Foundation, either version 3 of the License, or | ||||||||||||||||||||||||||||||||||||||||||
| 268 | (at your option) any later version. | ||||||||||||||||||||||||||||||||||||||||||
| 269 | HERE | ||||||||||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | ▶ | if (defined $rt) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | exit $rt; | |||||||||||||||||||||||||||||||||||||||||
| 273 | } | ||||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||
| 275 | } | ||||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||
| 277 | sub _set_z_fmt { | ||||||||||||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | ▶ | my ($z) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_set_z_fmt: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | $Z_FMT = $z; | |||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | $Z_UNK = strftime($Z_FMT, localtime 0) =~ s/\w/?/gr; | |||||||||||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||||||||||||
| 284 | } | ||||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||
| 286 | sub _default_data_dir { | ||||||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | ▶ | my $data; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_default_data_dir: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | ▶ | if (exists $ENV{ NOSS_DATA }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 291 | 0 | $data = $ENV{ NOSS_DATA }; | |||||||||||||||||||||||||||||||||||||||||
| 292 | ▶ | } 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"}
| |||||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | $data = File::Spec->catfile($ENV{ XDG_DATA_HOME }, $PRGNAM); | |||||||||||||||||||||||||||||||||||||||||
| 294 | } elsif (-d $DOT_LOCAL) { | ||||||||||||||||||||||||||||||||||||||||||
| 295 | 0 | $data = File::Spec->catfile($DOT_LOCAL, $PRGNAM); | |||||||||||||||||||||||||||||||||||||||||
| 296 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | $data = File::Spec->catfile(home, ".$PRGNAM"); | |||||||||||||||||||||||||||||||||||||||||
| 298 | } | ||||||||||||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | return $data; | |||||||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||||||||
| 302 | } | ||||||||||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||||||||||
| 304 | sub _default_config { | ||||||||||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | ▶ | my $cf; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_default_config: not called CC=9 SCAR=45.0
| |||||||||||||||||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | ▶ | if (exists $ENV{ NOSS_CONFIG }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | return $ENV{ NOSS_CONFIG }; | |||||||||||||||||||||||||||||||||||||||||
| 310 | } | ||||||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||||||
| 312 | 0 | ▶ | if (exists $ENV{ XDG_CONFIG_HOME }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||||||||
| 314 | $cf = File::Spec->catfile( | ||||||||||||||||||||||||||||||||||||||||||
| 315 | $ENV{ XDG_CONFIG_HOME }, | ||||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | $PRGNAM, | |||||||||||||||||||||||||||||||||||||||||
| 317 | "$PRGNAM.conf" | ||||||||||||||||||||||||||||||||||||||||||
| 318 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | ▶ | return $cf if -f $cf; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||||||||||||||||
| 321 | $cf = File::Spec->catfile( | ||||||||||||||||||||||||||||||||||||||||||
| 322 | $ENV{ XDG_CONFIG_HOME }, | ||||||||||||||||||||||||||||||||||||||||||
| 323 | 0 | "$PRGNAM.conf" | |||||||||||||||||||||||||||||||||||||||||
| 324 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | ▶ | return $cf if -f $cf; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||||||||||||
| 327 | } | ||||||||||||||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||||||||||||
| 329 | 0 | ▶ | if (-d $DOT_CONFIG) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||||||||||||||||
| 331 | 0 | $cf = File::Spec->catfile( | |||||||||||||||||||||||||||||||||||||||||
| 332 | $DOT_CONFIG, | ||||||||||||||||||||||||||||||||||||||||||
| 333 | $PRGNAM, | ||||||||||||||||||||||||||||||||||||||||||
| 334 | "$PRGNAM.conf" | ||||||||||||||||||||||||||||||||||||||||||
| 335 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | ▶ | return $cf if -f $cf; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | $cf = File::Spec->catfile( | |||||||||||||||||||||||||||||||||||||||||
| 339 | $DOT_CONFIG, | ||||||||||||||||||||||||||||||||||||||||||
| 340 | "$PRGNAM.conf" | ||||||||||||||||||||||||||||||||||||||||||
| 341 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 342 | 0 | ▶ | return $cf if -f $cf; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||||||||||||||||
| 344 | } | ||||||||||||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | $cf = File::Spec->catfile(home, ".$PRGNAM.conf"); | |||||||||||||||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||||||||||||||||
| 348 | 0 | ▶ | return $cf if -f $cf; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||||||||||||
| 352 | } | ||||||||||||||||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||||||||||||||||
| 354 | sub _default_feeds { | ||||||||||||||||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||||||||||||||||
| 356 | 0 | ▶ | my $ff; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_default_feeds: not called CC=9 SCAR=45.0
| |||||||||||||||||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||||||||||||||||
| 358 | 0 | ▶ | if (exists $ENV{ NOSS_FEEDS }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 359 | 0 | return $ENV{ NOSS_FEEDS }; | |||||||||||||||||||||||||||||||||||||||||
| 360 | } | ||||||||||||||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||||||||||||
| 362 | 0 | ▶ | if (exists $ENV{ XDG_CONFIG_HOME }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||||||||||||||||
| 364 | $ff = File::Spec->catfile( | ||||||||||||||||||||||||||||||||||||||||||
| 365 | $ENV{ XDG_CONFIG_HOME }, | ||||||||||||||||||||||||||||||||||||||||||
| 366 | 0 | $PRGNAM, | |||||||||||||||||||||||||||||||||||||||||
| 367 | "$PRGNAM.feeds" | ||||||||||||||||||||||||||||||||||||||||||
| 368 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 369 | 0 | ▶ | return $ff if -f $ff; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||||||||||||||||
| 371 | $ff = File::Spec->catfile( | ||||||||||||||||||||||||||||||||||||||||||
| 372 | $ENV{ XDG_CONFIG_HOME }, | ||||||||||||||||||||||||||||||||||||||||||
| 373 | 0 | "$PRGNAM.feeds" | |||||||||||||||||||||||||||||||||||||||||
| 374 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 375 | 0 | ▶ | return $ff if -f $ff; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||||||||||||||||
| 377 | } | ||||||||||||||||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||||||||||||||||
| 379 | 0 | ▶ | if (-d $DOT_CONFIG) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||||||||||||||||
| 381 | 0 | $ff = File::Spec->catfile( | |||||||||||||||||||||||||||||||||||||||||
| 382 | $DOT_CONFIG, | ||||||||||||||||||||||||||||||||||||||||||
| 383 | $PRGNAM, | ||||||||||||||||||||||||||||||||||||||||||
| 384 | "$PRGNAM.feeds" | ||||||||||||||||||||||||||||||||||||||||||
| 385 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 386 | 0 | ▶ | return $ff if -f $ff; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||||||||||||
| 388 | 0 | $ff = File::Spec->catfile( | |||||||||||||||||||||||||||||||||||||||||
| 389 | $DOT_CONFIG, | ||||||||||||||||||||||||||||||||||||||||||
| 390 | "$PRGNAM.feeds" | ||||||||||||||||||||||||||||||||||||||||||
| 391 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 392 | 0 | ▶ | return $ff if -f $ff; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||||||||||||||||
| 394 | } | ||||||||||||||||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||||||||||||||||
| 396 | 0 | $ff = File::Spec->catfile(home, ".$PRGNAM.feeds"); | |||||||||||||||||||||||||||||||||||||||||
| 397 | 0 | ▶ | return $ff if -f $ff; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||||||||||||||||
| 399 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||||||||||||||||
| 401 | } | ||||||||||||||||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||||||||||||||||
| 403 | sub _read_config { | ||||||||||||||||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||||||||||||||||
| 405 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_read_config: not called CC=72 SCAR=85.7
| |||||||||||||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||||||||||||
| 407 | 0 | my $cd = dirname(File::Spec->rel2abs($self->{ ConfFile })); | |||||||||||||||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||||||||||||||||
| 409 | open my $fh, '<', $self->{ ConfFile } | ||||||||||||||||||||||||||||||||||||||||||
| 410 | 0 | ▶ | or die "Failed to open $self->{ ConfFile } for reading: $!\n"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 411 | 0 | my $slurp = do { local $/ = undef; readline $fh }; | |||||||||||||||||||||||||||||||||||||||||
| 412 | 0 | close $fh; | |||||||||||||||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||||||||||||||||
| 414 | 0 | my $json_obj = JSON->new->relaxed; | |||||||||||||||||||||||||||||||||||||||||
| 415 | 0 | my $json = $json_obj->decode($slurp); | |||||||||||||||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||||||||||||||||
| 417 | 0 | ▶ | unless (ref $json eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 418 | 0 | die "$self->{ ConfFile } is not a valid $PRGNAM configuration file\n"; | |||||||||||||||||||||||||||||||||||||||||
| 419 | } | ||||||||||||||||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||||||||||||||||
| 421 | 0 | ▶ | if (defined $json->{ feeds }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 422 | 0 | ▶ | if (not ref $json->{ feeds }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 423 | 0 | my $p = $json->{ feeds } =~ s/^~/@{[ home ]}/r; | |||||||||||||||||||||||||||||||||||||||||
| 424 | $self->{ FeedFile } //= | ||||||||||||||||||||||||||||||||||||||||||
| 425 | File::Spec->file_name_is_absolute($p) | ||||||||||||||||||||||||||||||||||||||||||
| 426 | ? $json->{ feeds } | ||||||||||||||||||||||||||||||||||||||||||
| 427 | 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)
| |||||||||||||||||||||||||||||||||||||||||||
| 428 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 429 | 0 | warn "'feeds' is not a string, ignoring\n"; | |||||||||||||||||||||||||||||||||||||||||
| 430 | } | ||||||||||||||||||||||||||||||||||||||||||
| 431 | } | ||||||||||||||||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||||||||||||||||
| 433 | 0 | ▶ | if (defined $json->{ data }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 434 | 0 | ▶ | if (not ref $json->{ data }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 435 | 0 | my $p = $json->{ data } =~ s/^~/@{[ home ]}/r; | |||||||||||||||||||||||||||||||||||||||||
| 436 | $self->{ DataDir } //= | ||||||||||||||||||||||||||||||||||||||||||
| 437 | File::Spec->file_name_is_absolute($p) | ||||||||||||||||||||||||||||||||||||||||||
| 438 | ? $json->{ data } | ||||||||||||||||||||||||||||||||||||||||||
| 439 | 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)
| |||||||||||||||||||||||||||||||||||||||||||
| 440 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 441 | 0 | warn "'data' is not a string, ignoring\n"; | |||||||||||||||||||||||||||||||||||||||||
| 442 | } | ||||||||||||||||||||||||||||||||||||||||||
| 443 | } | ||||||||||||||||||||||||||||||||||||||||||
| 444 | |||||||||||||||||||||||||||||||||||||||||||
| 445 | 0 | ▶ | if (defined $json->{ downloads }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 446 | 0 | ▶ | if ($json->{ downloads } =~ /^\d+$/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 447 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||
| 448 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 449 | 0 | warn "'downloads' ($json->{ downloads }) is not an integar, ignoring\n"; | |||||||||||||||||||||||||||||||||||||||||
| 450 | } | ||||||||||||||||||||||||||||||||||||||||||
| 451 | } | ||||||||||||||||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||||||||||||||||
| 453 | 0 | ▶ | if (defined $json->{ pager }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 454 | 0 | ▶ | if (not ref $self->{ pager }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 455 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||
| 456 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 457 | 0 | warn "'pager' is not a string, ignoring\n"; | |||||||||||||||||||||||||||||||||||||||||
| 458 | } | ||||||||||||||||||||||||||||||||||||||||||
| 459 | } | ||||||||||||||||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||||||||||||||||
| 461 | 0 | ▶ | if (defined $json->{ browser }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 462 | 0 | ▶ | if (not ref $self->{ browser }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 463 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||
| 464 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 465 | 0 | warn "'browser' is not a string, ignoring\n"; | |||||||||||||||||||||||||||||||||||||||||
| 466 | } | ||||||||||||||||||||||||||||||||||||||||||
| 467 | } | ||||||||||||||||||||||||||||||||||||||||||
| 468 | |||||||||||||||||||||||||||||||||||||||||||
| 469 | 0 | ▶ | if (defined $json->{ limit_rate }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 470 | 0 | ▶ | if ($self->{ RateLimit } =~ $RATE_RX) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 471 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||
| 472 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 473 | 0 | warn "limit_rate' ($json->{ limit_rate }) is not a valid speed, ignoring\n"; | |||||||||||||||||||||||||||||||||||||||||
| 474 | } | ||||||||||||||||||||||||||||||||||||||||||
| 475 | } | ||||||||||||||||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||||||||||||||||
| 477 | 0 | ▶ | if (defined $json->{ user_agent }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 478 | 0 | ▶ | if (ref $json->{ user_agent }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 479 | 0 | warn "'user_agent' is not a string, ignoring\n"; | |||||||||||||||||||||||||||||||||||||||||
| 480 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 481 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||
| 482 | } | ||||||||||||||||||||||||||||||||||||||||||
| 483 | } | ||||||||||||||||||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||||||||||||||||
| 485 | 0 | ▶ | if (defined $json->{ timeout }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 486 | 0 | ▶ | if ($json->{ timeout } =~ /^\d+(\.\d+)?$/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 487 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||
| 488 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 489 | 0 | warn "'timeout' ($json->{ timeout }) is not numerical, ignoring\n"; | |||||||||||||||||||||||||||||||||||||||||
| 490 | } | ||||||||||||||||||||||||||||||||||||||||||
| 491 | } | ||||||||||||||||||||||||||||||||||||||||||
| 492 | |||||||||||||||||||||||||||||||||||||||||||
| 493 | 0 | ▶ | if (defined $json->{ proxy }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 494 | 0 | ▶ | if (ref $json->{ proxy }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 495 | 0 | warn "'proxy' is not a string, ignoring\n"; | |||||||||||||||||||||||||||||||||||||||||
| 496 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 497 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||
| 498 | } | ||||||||||||||||||||||||||||||||||||||||||
| 499 | } | ||||||||||||||||||||||||||||||||||||||||||
| 500 | |||||||||||||||||||||||||||||||||||||||||||
| 501 | 0 | ▶ | if (defined $json->{ proxy_user }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 502 | 0 | ▶ | if ($json->{ proxy_user } =~ /^[^:]+:[^:]+$/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 503 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||
| 504 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 505 | 0 | warn "'proxy_user' ($json->{ proxy_user }) is not a valid proxy user string, ignoring\n"; | |||||||||||||||||||||||||||||||||||||||||
| 506 | } | ||||||||||||||||||||||||||||||||||||||||||
| 507 | } | ||||||||||||||||||||||||||||||||||||||||||
| 508 | |||||||||||||||||||||||||||||||||||||||||||
| 509 | 0 | ▶ | if (defined $json->{ sort }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 510 | 0 | ▶ | if (exists $VALID_SORTS{ $json->{ sort } }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 511 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||
| 512 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 513 | 0 | warn sprintf "'sort' must be one of the following: %s\n", join(', ', sort keys %VALID_SORTS); | |||||||||||||||||||||||||||||||||||||||||
| 514 | } | ||||||||||||||||||||||||||||||||||||||||||
| 515 | } | ||||||||||||||||||||||||||||||||||||||||||
| 516 | |||||||||||||||||||||||||||||||||||||||||||
| 517 | 0 | ▶ | if (defined $json->{ line_width }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 518 | 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
| |||||||||||||||||||||||||||||||||||||||||||
| 519 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||
| 520 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 521 | 0 | warn "'line_width' must be an integar greater than 0, ignoring\n"; | |||||||||||||||||||||||||||||||||||||||||
| 522 | } | ||||||||||||||||||||||||||||||||||||||||||
| 523 | } | ||||||||||||||||||||||||||||||||||||||||||
| 524 | |||||||||||||||||||||||||||||||||||||||||||
| 525 | 0 | ▶ | if (defined $json->{ list_format }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 526 | 0 | ▶ | if (ref $json->{ list_format }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 527 | 0 | warn "'list_format' is not a format string, ignoring\n"; | |||||||||||||||||||||||||||||||||||||||||
| 528 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 529 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||
| 530 | } | ||||||||||||||||||||||||||||||||||||||||||
| 531 | } | ||||||||||||||||||||||||||||||||||||||||||
| 532 | |||||||||||||||||||||||||||||||||||||||||||
| 533 | 0 | ▶ | if (defined $json->{ read_format }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 534 | 0 | ▶ | if (ref $json->{ read_format }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 535 | 0 | warn "'read_format' is not a format string, ignoring\n"; | |||||||||||||||||||||||||||||||||||||||||
| 536 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 537 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||
| 538 | } | ||||||||||||||||||||||||||||||||||||||||||
| 539 | } | ||||||||||||||||||||||||||||||||||||||||||
| 540 | |||||||||||||||||||||||||||||||||||||||||||
| 541 | 0 | ▶ | if (defined $json->{ post_format }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 542 | 0 | ▶ | if (ref $json->{ post_format }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 543 | 0 | warn "'post_format' is not a format string, ignoring\n"; | |||||||||||||||||||||||||||||||||||||||||
| 544 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 545 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||
| 546 | } | ||||||||||||||||||||||||||||||||||||||||||
| 547 | } | ||||||||||||||||||||||||||||||||||||||||||
| 548 | |||||||||||||||||||||||||||||||||||||||||||
| 549 | 0 | ▶ | if (defined $json->{ feeds_format }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 550 | 0 | ▶ | if (ref $json->{ feeds_format }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 551 | 0 | warn "'feeds_format' is not a format string, ignoring\n"; | |||||||||||||||||||||||||||||||||||||||||
| 552 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 553 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||
| 554 | } | ||||||||||||||||||||||||||||||||||||||||||
| 555 | } | ||||||||||||||||||||||||||||||||||||||||||
| 556 | |||||||||||||||||||||||||||||||||||||||||||
| 557 | 0 | ▶ | if (defined $json->{ autoclean }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 558 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||
| 559 | } | ||||||||||||||||||||||||||||||||||||||||||
| 560 | |||||||||||||||||||||||||||||||||||||||||||
| 561 | 0 | ▶ | if (defined $json->{ time_format }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 562 | 0 | ▶ | if (ref $json->{ time_format }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 563 | 0 | warn "'time_format' is not a format string, ignoring\n"; | |||||||||||||||||||||||||||||||||||||||||
| 564 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 565 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||
| 566 | } | ||||||||||||||||||||||||||||||||||||||||||
| 567 | } | ||||||||||||||||||||||||||||||||||||||||||
| 568 | |||||||||||||||||||||||||||||||||||||||||||
| 569 | 0 | ▶ | if (defined $json->{ list_limit }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 570 | 0 | ▶ | if ($json->{ list_limit } =~ /^-?\d+$/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 571 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||
| 572 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 573 | 0 | warn "'list_limit' ($json->{ list_limit }) is not an integar, ignoring\n"; | |||||||||||||||||||||||||||||||||||||||||
| 574 | } | ||||||||||||||||||||||||||||||||||||||||||
| 575 | } | ||||||||||||||||||||||||||||||||||||||||||
| 576 | |||||||||||||||||||||||||||||||||||||||||||
| 577 | 0 | ▶ | if (defined $json->{ colors }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 578 | 0 | ▶ | if (ref $json->{ colors } ne 'HASH') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 579 | 0 | warn "'colors' is not a key-value map, ignoring\n"; | |||||||||||||||||||||||||||||||||||||||||
| 580 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 581 | 0 | for my $k (keys %{ $json->{ colors } }) { | |||||||||||||||||||||||||||||||||||||||||
| 582 | 0 | ▶ | if (not exists $self->{ ColorMap }{ $k }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 583 | 0 | warn "'$k' is not a valid color code, ignoring\n"; | |||||||||||||||||||||||||||||||||||||||||
| 584 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 585 | } | ||||||||||||||||||||||||||||||||||||||||||
| 586 | 0 | $self->{ ColorMap }{ $k } = $json->{ colors }{ $k }; | |||||||||||||||||||||||||||||||||||||||||
| 587 | } | ||||||||||||||||||||||||||||||||||||||||||
| 588 | } | ||||||||||||||||||||||||||||||||||||||||||
| 589 | } | ||||||||||||||||||||||||||||||||||||||||||
| 590 | |||||||||||||||||||||||||||||||||||||||||||
| 591 | 0 | ▶ | if (defined $json->{ list_unread_format }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 592 | 0 | ▶ | if (ref $json->{ list_unread_format }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 593 | 0 | warn "'list_unread_format' is not a format string, ignoring\n"; | |||||||||||||||||||||||||||||||||||||||||
| 594 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 595 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||
| 596 | } | ||||||||||||||||||||||||||||||||||||||||||
| 597 | } | ||||||||||||||||||||||||||||||||||||||||||
| 598 | |||||||||||||||||||||||||||||||||||||||||||
| 599 | 0 | ▶ | if (defined $json->{ colored_output }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 600 | # If true, set to undef so that noss can automatically disable the use | ||||||||||||||||||||||||||||||||||||||||||
| 601 | # of color when not writing to a terminal. | ||||||||||||||||||||||||||||||||||||||||||
| 602 | 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
| |||||||||||||||||||||||||||||||||||||||||||
| 603 | } | ||||||||||||||||||||||||||||||||||||||||||
| 604 | |||||||||||||||||||||||||||||||||||||||||||
| 605 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 606 | |||||||||||||||||||||||||||||||||||||||||||
| 607 | } | ||||||||||||||||||||||||||||||||||||||||||
| 608 | |||||||||||||||||||||||||||||||||||||||||||
| 609 | # Note to a confused future self: | ||||||||||||||||||||||||||||||||||||||||||
| 610 | # When adding a new feed parameter, the following locations should be updated: | ||||||||||||||||||||||||||||||||||||||||||
| 611 | # * This _feed_params subroutine | ||||||||||||||||||||||||||||||||||||||||||
| 612 | # * BaseConfig attributes | ||||||||||||||||||||||||||||||||||||||||||
| 613 | # * FeedConfig group attribute initialization | ||||||||||||||||||||||||||||||||||||||||||
| 614 | # * (Base|Feed|Group)Config documentation | ||||||||||||||||||||||||||||||||||||||||||
| 615 | # * FeedConfig tests | ||||||||||||||||||||||||||||||||||||||||||
| 616 | # * Feed configuration section in manual | ||||||||||||||||||||||||||||||||||||||||||
| 617 | sub _feed_params { | ||||||||||||||||||||||||||||||||||||||||||
| 618 | |||||||||||||||||||||||||||||||||||||||||||
| 619 | 0 | ▶ | my ($ref) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_feed_params: not called CC=25 SCAR=64.8
| |||||||||||||||||||||||||||||||||||||||||||
| 620 | |||||||||||||||||||||||||||||||||||||||||||
| 621 | 0 | my %params; | |||||||||||||||||||||||||||||||||||||||||
| 622 | |||||||||||||||||||||||||||||||||||||||||||
| 623 | 0 | ▶ | if (defined $ref->{ limit }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 624 | 0 | ▶ | if ($ref->{ limit } =~ /^\d+$/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 625 | 0 | $params{ limit } = $ref->{ limit }; | |||||||||||||||||||||||||||||||||||||||||
| 626 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 627 | 0 | warn "'limit' ($ref->{ limit }) is not an integar, ignoring\n"; | |||||||||||||||||||||||||||||||||||||||||
| 628 | } | ||||||||||||||||||||||||||||||||||||||||||
| 629 | } | ||||||||||||||||||||||||||||||||||||||||||
| 630 | |||||||||||||||||||||||||||||||||||||||||||
| 631 | 0 | ▶ | if (defined $ref->{ respect_skip }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 632 | 0 | $params{ respect_skip } = !! $ref->{ respect_skip }; | |||||||||||||||||||||||||||||||||||||||||
| 633 | } | ||||||||||||||||||||||||||||||||||||||||||
| 634 | |||||||||||||||||||||||||||||||||||||||||||
| 635 | 0 | ▶ | if (defined $ref->{ include_title }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 636 | 0 | ▶ | if (ref $ref->{ include_title } eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 637 | 0 | $params{ include_title } = [ map { _arg2rx($_) } @{ $ref->{ include_title } } ]; | |||||||||||||||||||||||||||||||||||||||||
| 638 | } elsif (not ref $ref->{ include_title }) { | ||||||||||||||||||||||||||||||||||||||||||
| 639 | 0 | $params{ include_title } = [ _arg2rx($ref->{ include_title }) ]; | |||||||||||||||||||||||||||||||||||||||||
| 640 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 641 | 0 | warn "'include_title' is not an array or string, ignoring\n"; | |||||||||||||||||||||||||||||||||||||||||
| 642 | } | ||||||||||||||||||||||||||||||||||||||||||
| 643 | } | ||||||||||||||||||||||||||||||||||||||||||
| 644 | |||||||||||||||||||||||||||||||||||||||||||
| 645 | 0 | ▶ | if (defined $ref->{ exclude_title }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 646 | 0 | ▶ | if (ref $ref->{ exclude_title } eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 647 | 0 | $params{ exclude_title } = [ map { _arg2rx($_) } @{ $ref->{ exclude_title } } ]; | |||||||||||||||||||||||||||||||||||||||||
| 648 | } elsif (not ref $ref->{ exclude_title }) { | ||||||||||||||||||||||||||||||||||||||||||
| 649 | 0 | $params{ exclude_title } = [ _arg2rx($ref->{ exclude_title }) ]; | |||||||||||||||||||||||||||||||||||||||||
| 650 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 651 | 0 | warn "'exclude_title' is not an array or string, ignoring\n"; | |||||||||||||||||||||||||||||||||||||||||
| 652 | } | ||||||||||||||||||||||||||||||||||||||||||
| 653 | } | ||||||||||||||||||||||||||||||||||||||||||
| 654 | |||||||||||||||||||||||||||||||||||||||||||
| 655 | 0 | ▶ | if (defined $ref->{ include_content }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 656 | 0 | ▶ | if (ref $ref->{ include_content } eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 657 | 0 | $params{ include_content } = [ map { _arg2rx($_) } @{ $ref->{ include_content } } ]; | |||||||||||||||||||||||||||||||||||||||||
| 658 | } elsif (not ref $ref->{ include_content }) { | ||||||||||||||||||||||||||||||||||||||||||
| 659 | 0 | $params{ include_content } = [ _arg2rx($ref->{ include_content }) ]; | |||||||||||||||||||||||||||||||||||||||||
| 660 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 661 | 0 | warn "'include_content' is not an array or string, ignoring\n"; | |||||||||||||||||||||||||||||||||||||||||
| 662 | } | ||||||||||||||||||||||||||||||||||||||||||
| 663 | } | ||||||||||||||||||||||||||||||||||||||||||
| 664 | |||||||||||||||||||||||||||||||||||||||||||
| 665 | 0 | ▶ | if (defined $ref->{ exclude_content }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 666 | 0 | ▶ | if (ref $ref->{ exclude_content } eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 667 | 0 | $params{ exclude_content } = [ map { _arg2rx($_) } @{ $ref->{ exclude_content } } ]; | |||||||||||||||||||||||||||||||||||||||||
| 668 | } elsif (not ref $ref->{ exclude_content }) { | ||||||||||||||||||||||||||||||||||||||||||
| 669 | 0 | $params{ exclude_content } = [ _arg2rx($ref->{ exclude_content }) ]; | |||||||||||||||||||||||||||||||||||||||||
| 670 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 671 | 0 | warn "'exclude_content' is not an array or string, ignoring\n"; | |||||||||||||||||||||||||||||||||||||||||
| 672 | } | ||||||||||||||||||||||||||||||||||||||||||
| 673 | } | ||||||||||||||||||||||||||||||||||||||||||
| 674 | |||||||||||||||||||||||||||||||||||||||||||
| 675 | 0 | ▶ | if (defined $ref->{ include_tags }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 676 | 0 | ▶ | if (ref $ref->{ include_tags } eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 677 | 0 | $params{ include_tags } = $ref->{ include_tags }; | |||||||||||||||||||||||||||||||||||||||||
| 678 | } elsif (not ref $ref->{ include_tags }) { | ||||||||||||||||||||||||||||||||||||||||||
| 679 | 0 | $params{ include_tags } = [ $ref->{ include_tags } ]; | |||||||||||||||||||||||||||||||||||||||||
| 680 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 681 | 0 | warn "'include_tags' is not an array or string, ignoring\n"; | |||||||||||||||||||||||||||||||||||||||||
| 682 | } | ||||||||||||||||||||||||||||||||||||||||||
| 683 | } | ||||||||||||||||||||||||||||||||||||||||||
| 684 | |||||||||||||||||||||||||||||||||||||||||||
| 685 | 0 | ▶ | if (defined $ref->{ exclude_tags }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 686 | 0 | ▶ | if (ref $ref->{ exclude_tags } eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 687 | 0 | $params{ exclude_tags } = $ref->{ exclude_tags }; | |||||||||||||||||||||||||||||||||||||||||
| 688 | } elsif (not ref $ref->{ exclude_tags }) { | ||||||||||||||||||||||||||||||||||||||||||
| 689 | 0 | $params{ exclude_tags } = [ $ref->{ exclude_tags } ]; | |||||||||||||||||||||||||||||||||||||||||
| 690 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 691 | 0 | warn "'exclude_tags' is not an array or string, ignoring\n"; | |||||||||||||||||||||||||||||||||||||||||
| 692 | } | ||||||||||||||||||||||||||||||||||||||||||
| 693 | } | ||||||||||||||||||||||||||||||||||||||||||
| 694 | |||||||||||||||||||||||||||||||||||||||||||
| 695 | 0 | ▶ | if (defined $ref->{ autoread }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 696 | 0 | $params{ autoread } = !! $ref->{ autoread }; | |||||||||||||||||||||||||||||||||||||||||
| 697 | } | ||||||||||||||||||||||||||||||||||||||||||
| 698 | |||||||||||||||||||||||||||||||||||||||||||
| 699 | 0 | ▶ | if (defined $ref->{ default_update }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 700 | 0 | $params{ default_update } = !! $ref->{ default_update }; | |||||||||||||||||||||||||||||||||||||||||
| 701 | } | ||||||||||||||||||||||||||||||||||||||||||
| 702 | |||||||||||||||||||||||||||||||||||||||||||
| 703 | 0 | ▶ | if (defined $ref->{ hidden }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 704 | 0 | $params{ hidden } = !! $ref->{ hidden }; | |||||||||||||||||||||||||||||||||||||||||
| 705 | } | ||||||||||||||||||||||||||||||||||||||||||
| 706 | |||||||||||||||||||||||||||||||||||||||||||
| 707 | 0 | return %params; | |||||||||||||||||||||||||||||||||||||||||
| 708 | |||||||||||||||||||||||||||||||||||||||||||
| 709 | } | ||||||||||||||||||||||||||||||||||||||||||
| 710 | |||||||||||||||||||||||||||||||||||||||||||
| 711 | sub _read_feed_file { | ||||||||||||||||||||||||||||||||||||||||||
| 712 | |||||||||||||||||||||||||||||||||||||||||||
| 713 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_read_feed_file: not called CC=27 SCAR=66.3
| |||||||||||||||||||||||||||||||||||||||||||
| 714 | |||||||||||||||||||||||||||||||||||||||||||
| 715 | open my $fh, '<', $self->{ FeedFile } | ||||||||||||||||||||||||||||||||||||||||||
| 716 | 0 | ▶ | or die "Failed to open $self->{ FeedFile } for reading: $!\n"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 717 | 0 | my $slurp = do { local $/ = undef; readline $fh }; | |||||||||||||||||||||||||||||||||||||||||
| 718 | 0 | close $fh; | |||||||||||||||||||||||||||||||||||||||||
| 719 | |||||||||||||||||||||||||||||||||||||||||||
| 720 | 0 | my $json_obj = JSON->new->relaxed; | |||||||||||||||||||||||||||||||||||||||||
| 721 | 0 | my $json = $json_obj->decode($slurp); | |||||||||||||||||||||||||||||||||||||||||
| 722 | |||||||||||||||||||||||||||||||||||||||||||
| 723 | 0 | ▶ | unless (ref $json eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 724 | 0 | die "$self->{ FeedFile } is not a valid feed file\n"; | |||||||||||||||||||||||||||||||||||||||||
| 725 | } | ||||||||||||||||||||||||||||||||||||||||||
| 726 | |||||||||||||||||||||||||||||||||||||||||||
| 727 | 0 | ▶ | unless (exists $json->{ feeds }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 728 | 0 | die "Failed to read $self->{ FeedFile }: missing 'feeds' list\n"; | |||||||||||||||||||||||||||||||||||||||||
| 729 | } | ||||||||||||||||||||||||||||||||||||||||||
| 730 | |||||||||||||||||||||||||||||||||||||||||||
| 731 | 0 | my $feeds = $json->{ feeds }; | |||||||||||||||||||||||||||||||||||||||||
| 732 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||
| 733 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||
| 734 | |||||||||||||||||||||||||||||||||||||||||||
| 735 | 0 | ▶ | unless (ref $feeds eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 736 | 0 | die "Failed to read $self->{ FeedFile }: 'feeds' must be a key-value map\n"; | |||||||||||||||||||||||||||||||||||||||||
| 737 | } | ||||||||||||||||||||||||||||||||||||||||||
| 738 | |||||||||||||||||||||||||||||||||||||||||||
| 739 | 0 | ▶ | unless (ref $groups eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 740 | 0 | die "Failed to read $self->{ FeedFile }: 'groups' must be a key-value map\n"; | |||||||||||||||||||||||||||||||||||||||||
| 741 | } | ||||||||||||||||||||||||||||||||||||||||||
| 742 | |||||||||||||||||||||||||||||||||||||||||||
| 743 | 0 | ▶ | unless (ref $default eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 744 | 0 | die "Failed to read $self->{ FeedFile }: 'default' must be a key-value map\n"; | |||||||||||||||||||||||||||||||||||||||||
| 745 | } | ||||||||||||||||||||||||||||||||||||||||||
| 746 | |||||||||||||||||||||||||||||||||||||||||||
| 747 | 0 | for my $k (keys %$groups) { | |||||||||||||||||||||||||||||||||||||||||
| 748 | 0 | ▶ | unless ($k =~ /^\w+$/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 749 | 0 | warn "'$k' is not a valid feed group: name contains invalid characters, ignoring\n"; | |||||||||||||||||||||||||||||||||||||||||
| 750 | 0 | delete $groups->{ $k }; | |||||||||||||||||||||||||||||||||||||||||
| 751 | } | ||||||||||||||||||||||||||||||||||||||||||
| 752 | 0 | ▶ | if (exists $feeds->{ $k }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 753 | 0 | die "'$k' is both the name of a feed and group\n"; | |||||||||||||||||||||||||||||||||||||||||
| 754 | } | ||||||||||||||||||||||||||||||||||||||||||
| 755 | } | ||||||||||||||||||||||||||||||||||||||||||
| 756 | |||||||||||||||||||||||||||||||||||||||||||
| 757 | 0 | for my $k (keys %$feeds) { | |||||||||||||||||||||||||||||||||||||||||
| 758 | 0 | ▶ | unless ($k =~ /^\w+$/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 759 | 0 | warn "'$k' is not a valid feed name: contains invalid characters, ignoring\n"; | |||||||||||||||||||||||||||||||||||||||||
| 760 | 0 | delete $feeds->{ $k }; | |||||||||||||||||||||||||||||||||||||||||
| 761 | } | ||||||||||||||||||||||||||||||||||||||||||
| 762 | } | ||||||||||||||||||||||||||||||||||||||||||
| 763 | |||||||||||||||||||||||||||||||||||||||||||
| 764 | |||||||||||||||||||||||||||||||||||||||||||
| 765 | 0 | ▶ | if (%$default) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 766 | 0 | my %params = _feed_params($default); | |||||||||||||||||||||||||||||||||||||||||
| 767 | 0 | $self->{ DefaultGroup } = WWW::Noss::GroupConfig->new( | |||||||||||||||||||||||||||||||||||||||||
| 768 | name => ':all', | ||||||||||||||||||||||||||||||||||||||||||
| 769 | feeds => [ keys %$feeds ], | ||||||||||||||||||||||||||||||||||||||||||
| 770 | %params | ||||||||||||||||||||||||||||||||||||||||||
| 771 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 772 | } | ||||||||||||||||||||||||||||||||||||||||||
| 773 | |||||||||||||||||||||||||||||||||||||||||||
| 774 | 0 | for my $k (keys %$groups) { | |||||||||||||||||||||||||||||||||||||||||
| 775 | 0 | my $g = $groups->{ $k }; | |||||||||||||||||||||||||||||||||||||||||
| 776 | |||||||||||||||||||||||||||||||||||||||||||
| 777 | 0 | ▶ | if (ref $g eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 778 | 0 | $g = { feeds => $g }; | |||||||||||||||||||||||||||||||||||||||||
| 779 | } elsif (ref $g ne 'HASH') { | ||||||||||||||||||||||||||||||||||||||||||
| 780 | 0 | warn "'$k' is neither a feed list or key-value map, skipping\n"; | |||||||||||||||||||||||||||||||||||||||||
| 781 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 782 | } | ||||||||||||||||||||||||||||||||||||||||||
| 783 | |||||||||||||||||||||||||||||||||||||||||||
| 784 | 0 | ▶ | unless (ref $g->{ feeds } eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 785 | 0 | warn "'$k' group does not contain a feed list, skipping\n"; | |||||||||||||||||||||||||||||||||||||||||
| 786 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 787 | } | ||||||||||||||||||||||||||||||||||||||||||
| 788 | |||||||||||||||||||||||||||||||||||||||||||
| 789 | 0 | my %params = _feed_params($g); | |||||||||||||||||||||||||||||||||||||||||
| 790 | |||||||||||||||||||||||||||||||||||||||||||
| 791 | $self->{ Groups }{ $k } = WWW::Noss::GroupConfig->new( | ||||||||||||||||||||||||||||||||||||||||||
| 792 | name => $k, | ||||||||||||||||||||||||||||||||||||||||||
| 793 | feeds => $g->{ feeds }, | ||||||||||||||||||||||||||||||||||||||||||
| 794 | 0 | %params | |||||||||||||||||||||||||||||||||||||||||
| 795 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 796 | |||||||||||||||||||||||||||||||||||||||||||
| 797 | } | ||||||||||||||||||||||||||||||||||||||||||
| 798 | |||||||||||||||||||||||||||||||||||||||||||
| 799 | 0 | for my $k (keys %$feeds) { | |||||||||||||||||||||||||||||||||||||||||
| 800 | 0 | my $f = $feeds->{ $k }; | |||||||||||||||||||||||||||||||||||||||||
| 801 | |||||||||||||||||||||||||||||||||||||||||||
| 802 | 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
| |||||||||||||||||||||||||||||||||||||||||||
| 803 | 0 | $f = { feed => $f }; | |||||||||||||||||||||||||||||||||||||||||
| 804 | } elsif (ref $f ne 'HASH') { | ||||||||||||||||||||||||||||||||||||||||||
| 805 | 0 | warn "'$k' is neither a feed link or a key-value map, skipping\n"; | |||||||||||||||||||||||||||||||||||||||||
| 806 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 807 | } | ||||||||||||||||||||||||||||||||||||||||||
| 808 | |||||||||||||||||||||||||||||||||||||||||||
| 809 | 0 | ▶ | unless (exists $f->{ feed }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 810 | 0 | warn "'$k' feed does not contain a feed link, skipping\n"; | |||||||||||||||||||||||||||||||||||||||||
| 811 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 812 | } | ||||||||||||||||||||||||||||||||||||||||||
| 813 | |||||||||||||||||||||||||||||||||||||||||||
| 814 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||
| 815 | 0 | warn "'$k' feed link is not a string, skipping\n"; | |||||||||||||||||||||||||||||||||||||||||
| 816 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 817 | } | ||||||||||||||||||||||||||||||||||||||||||
| 818 | |||||||||||||||||||||||||||||||||||||||||||
| 819 | 0 | my @groups = grep { $_->has_feed($k) } values %{ $self->{ Groups } }; | |||||||||||||||||||||||||||||||||||||||||
| 820 | |||||||||||||||||||||||||||||||||||||||||||
| 821 | 0 | my %params = _feed_params($f); | |||||||||||||||||||||||||||||||||||||||||
| 822 | |||||||||||||||||||||||||||||||||||||||||||
| 823 | $self->{ Feeds }{ $k } = WWW::Noss::FeedConfig->new( | ||||||||||||||||||||||||||||||||||||||||||
| 824 | name => $k, | ||||||||||||||||||||||||||||||||||||||||||
| 825 | feed => $f->{ feed }, | ||||||||||||||||||||||||||||||||||||||||||
| 826 | default => $self->{ DefaultGroup }, | ||||||||||||||||||||||||||||||||||||||||||
| 827 | groups => \@groups, | ||||||||||||||||||||||||||||||||||||||||||
| 828 | path => File::Spec->catfile($self->{ FeedDir }, "$k.feed"), | ||||||||||||||||||||||||||||||||||||||||||
| 829 | etag => File::Spec->catfile($self->{ EtagDir }, "$k.etag"), | ||||||||||||||||||||||||||||||||||||||||||
| 830 | 0 | retry_cache => File::Spec->catfile($self->{ RetryDir }, "$k.retry"), | |||||||||||||||||||||||||||||||||||||||||
| 831 | %params | ||||||||||||||||||||||||||||||||||||||||||
| 832 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 833 | |||||||||||||||||||||||||||||||||||||||||||
| 834 | } | ||||||||||||||||||||||||||||||||||||||||||
| 835 | |||||||||||||||||||||||||||||||||||||||||||
| 836 | 0 | ▶ | unless (%{ $self->{ Feeds } }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 837 | 0 | die "$PRGNAM found no feeds in $self->{ FeedFile }\n"; | |||||||||||||||||||||||||||||||||||||||||
| 838 | } | ||||||||||||||||||||||||||||||||||||||||||
| 839 | |||||||||||||||||||||||||||||||||||||||||||
| 840 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 841 | |||||||||||||||||||||||||||||||||||||||||||
| 842 | } | ||||||||||||||||||||||||||||||||||||||||||
| 843 | |||||||||||||||||||||||||||||||||||||||||||
| 844 | sub _arg2rx { | ||||||||||||||||||||||||||||||||||||||||||
| 845 | |||||||||||||||||||||||||||||||||||||||||||
| 846 | 0 | ▶ | my ($str) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_arg2rx: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 847 | |||||||||||||||||||||||||||||||||||||||||||
| 848 | 0 | ▶ | if ($str =~ /^\/(.*)\/$/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 849 | 0 | return qr/$1/i; | |||||||||||||||||||||||||||||||||||||||||
| 850 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 851 | 0 | return qr/\Q$str\E/i; | |||||||||||||||||||||||||||||||||||||||||
| 852 | } | ||||||||||||||||||||||||||||||||||||||||||
| 853 | |||||||||||||||||||||||||||||||||||||||||||
| 854 | } | ||||||||||||||||||||||||||||||||||||||||||
| 855 | |||||||||||||||||||||||||||||||||||||||||||
| 856 | sub _fmt { | ||||||||||||||||||||||||||||||||||||||||||
| 857 | |||||||||||||||||||||||||||||||||||||||||||
| 858 | 0 | ▶ | my ($fmt, $codes, $colors) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_fmt: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||||||||||||||||
| 859 | 0 | ▶ | $colors //= {}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$colors //= {}
MC/DC0%0/1
$colors //= {}
$colors
Truth table0%0/2
A
A= $colors
| |||||||||||||||||||||||||||||||||||||||||||
| 860 | |||||||||||||||||||||||||||||||||||||||||||
| 861 | 0 | ▶ | $fmt .= "\n" unless $fmt =~ /\n$/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 862 | |||||||||||||||||||||||||||||||||||||||||||
| 863 | 0 | my @subs; | |||||||||||||||||||||||||||||||||||||||||
| 864 | 0 | my $colored = 0; | |||||||||||||||||||||||||||||||||||||||||
| 865 | |||||||||||||||||||||||||||||||||||||||||||
| 866 | 0 | $fmt =~ s{(?<Fmt>%(?:[+\-]?\d+)?.)|(?<Color><$COLOR_CODE_RX>)}{ | |||||||||||||||||||||||||||||||||||||||||
| 867 | 0 | ▶ | if (defined $+{ Fmt }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 868 | 0 | my $code = substr $+{ Fmt }, 1; | |||||||||||||||||||||||||||||||||||||||||
| 869 | 0 | my $c = chop $code; | |||||||||||||||||||||||||||||||||||||||||
| 870 | 0 | ▶ | unless (exists $codes->{ $c }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 871 | 0 | die "'%$code$c' is not a valid formatting code\n"; | |||||||||||||||||||||||||||||||||||||||||
| 872 | } | ||||||||||||||||||||||||||||||||||||||||||
| 873 | 0 | push @subs, $codes->{ $c }; | |||||||||||||||||||||||||||||||||||||||||
| 874 | 0 | '%' . $code . 's'; | |||||||||||||||||||||||||||||||||||||||||
| 875 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 876 | 0 | my $code = substr $+{ Color }, 1, -1; | |||||||||||||||||||||||||||||||||||||||||
| 877 | 0 | ▶ | if (not exists $colors->{ $code }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 878 | 0 | $+{ Color }; | |||||||||||||||||||||||||||||||||||||||||
| 879 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 880 | 0 | $colored = 1; | |||||||||||||||||||||||||||||||||||||||||
| 881 | 0 | color($colors->{ $code }); | |||||||||||||||||||||||||||||||||||||||||
| 882 | } | ||||||||||||||||||||||||||||||||||||||||||
| 883 | } | ||||||||||||||||||||||||||||||||||||||||||
| 884 | }ge; | ||||||||||||||||||||||||||||||||||||||||||
| 885 | |||||||||||||||||||||||||||||||||||||||||||
| 886 | 0 | ▶ | if ($colored) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 887 | 0 | $fmt .= color('reset'); | |||||||||||||||||||||||||||||||||||||||||
| 888 | } | ||||||||||||||||||||||||||||||||||||||||||
| 889 | |||||||||||||||||||||||||||||||||||||||||||
| 890 | 0 | ▶ | return sub { sprintf $fmt, map { $_->($_[0]) } @subs }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 891 | |||||||||||||||||||||||||||||||||||||||||||
| 892 | } | ||||||||||||||||||||||||||||||||||||||||||
| 893 | |||||||||||||||||||||||||||||||||||||||||||
| 894 | sub _rm_color_codes { | ||||||||||||||||||||||||||||||||||||||||||
| 895 | |||||||||||||||||||||||||||||||||||||||||||
| 896 | 0 | ▶ | my ($str) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_rm_color_codes: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 897 | |||||||||||||||||||||||||||||||||||||||||||
| 898 | 0 | return $str =~ s/<$COLOR_CODE_RX>//gr; | |||||||||||||||||||||||||||||||||||||||||
| 899 | |||||||||||||||||||||||||||||||||||||||||||
| 900 | } | ||||||||||||||||||||||||||||||||||||||||||
| 901 | |||||||||||||||||||||||||||||||||||||||||||
| 902 | sub err { | ||||||||||||||||||||||||||||||||||||||||||
| 903 | |||||||||||||||||||||||||||||||||||||||||||
| 904 | 0 | ▶ | my ($self, @args) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
err: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 905 | |||||||||||||||||||||||||||||||||||||||||||
| 906 | 0 | my $err = join '', @args; | |||||||||||||||||||||||||||||||||||||||||
| 907 | |||||||||||||||||||||||||||||||||||||||||||
| 908 | 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
| |||||||||||||||||||||||||||||||||||||||||||
| 909 | 0 | warn colored($err, 'bold red') . "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 910 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 911 | 0 | warn "$err\n"; | |||||||||||||||||||||||||||||||||||||||||
| 912 | } | ||||||||||||||||||||||||||||||||||||||||||
| 913 | |||||||||||||||||||||||||||||||||||||||||||
| 914 | } | ||||||||||||||||||||||||||||||||||||||||||
| 915 | |||||||||||||||||||||||||||||||||||||||||||
| 916 | sub _get_feed { | ||||||||||||||||||||||||||||||||||||||||||
| 917 | |||||||||||||||||||||||||||||||||||||||||||
| 918 | 0 | ▶ | my ($self, $feed) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_feed: not called CC=21 SCAR=61.4
| |||||||||||||||||||||||||||||||||||||||||||
| 919 | |||||||||||||||||||||||||||||||||||||||||||
| 920 | 0 | ▶ | if ($feed->feed =~ /^file:\/\//) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 921 | |||||||||||||||||||||||||||||||||||||||||||
| 922 | 0 | my $f = $feed->feed =~ s/^file:\/\///r; | |||||||||||||||||||||||||||||||||||||||||
| 923 | |||||||||||||||||||||||||||||||||||||||||||
| 924 | 0 | $f =~ s/^~/@{[ home ]}/; | |||||||||||||||||||||||||||||||||||||||||
| 925 | |||||||||||||||||||||||||||||||||||||||||||
| 926 | 0 | ▶ | unless (File::Spec->file_name_is_absolute($f)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 927 | $f = File::Spec->catfile( | ||||||||||||||||||||||||||||||||||||||||||
| 928 | 0 | dirname($self->{ FeedFile }), | |||||||||||||||||||||||||||||||||||||||||
| 929 | $f | ||||||||||||||||||||||||||||||||||||||||||
| 930 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 931 | } | ||||||||||||||||||||||||||||||||||||||||||
| 932 | |||||||||||||||||||||||||||||||||||||||||||
| 933 | 0 | ▶ | copy($f, $feed->path) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 934 | or die sprintf "Failed to copy %s to %s: %s\n", $f, $feed->path, $!; | ||||||||||||||||||||||||||||||||||||||||||
| 935 | # Copy over access and mod times | ||||||||||||||||||||||||||||||||||||||||||
| 936 | 0 | utime((stat($f))[8, 9], $feed->path); | |||||||||||||||||||||||||||||||||||||||||
| 937 | |||||||||||||||||||||||||||||||||||||||||||
| 938 | 0 | return $feed->path; | |||||||||||||||||||||||||||||||||||||||||
| 939 | |||||||||||||||||||||||||||||||||||||||||||
| 940 | } elsif ($feed->feed =~ /^shell:\/\//) { | ||||||||||||||||||||||||||||||||||||||||||
| 941 | |||||||||||||||||||||||||||||||||||||||||||
| 942 | 0 | my $cmd = $feed->feed =~ s/^shell:\/\///r; | |||||||||||||||||||||||||||||||||||||||||
| 943 | |||||||||||||||||||||||||||||||||||||||||||
| 944 | 0 | ▶ | open my $fh, '>', $feed->path | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 945 | or die sprintf "Failed to open %s for writing: %s\n", $feed->path, $!; | ||||||||||||||||||||||||||||||||||||||||||
| 946 | |||||||||||||||||||||||||||||||||||||||||||
| 947 | # cd into feed file directory, so that shell command is ran from said | ||||||||||||||||||||||||||||||||||||||||||
| 948 | # directory. | ||||||||||||||||||||||||||||||||||||||||||
| 949 | 0 | my $cwd = cwd; | |||||||||||||||||||||||||||||||||||||||||
| 950 | |||||||||||||||||||||||||||||||||||||||||||
| 951 | chdir dirname($self->{ FeedFile }) | ||||||||||||||||||||||||||||||||||||||||||
| 952 | 0 | ▶ | or die "Failed to chdir to $self->{ FeedFile }: $!\n"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 953 | |||||||||||||||||||||||||||||||||||||||||||
| 954 | 0 | my $qx = qx/$cmd/; | |||||||||||||||||||||||||||||||||||||||||
| 955 | |||||||||||||||||||||||||||||||||||||||||||
| 956 | 0 | ▶ | unless ($? >> 8 == 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 957 | 0 | ▶ | chdir $cwd or die "Failed to chdir to $cwd: $!\n"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 958 | 0 | die "Failed to execute '$cmd'\n"; | |||||||||||||||||||||||||||||||||||||||||
| 959 | } | ||||||||||||||||||||||||||||||||||||||||||
| 960 | |||||||||||||||||||||||||||||||||||||||||||
| 961 | 0 | print { $fh } $qx; | |||||||||||||||||||||||||||||||||||||||||
| 962 | |||||||||||||||||||||||||||||||||||||||||||
| 963 | 0 | close $fh; | |||||||||||||||||||||||||||||||||||||||||
| 964 | |||||||||||||||||||||||||||||||||||||||||||
| 965 | 0 | ▶ | chdir $cwd or die "Failed to chdir to $cwd: $!\n"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 966 | |||||||||||||||||||||||||||||||||||||||||||
| 967 | 0 | return $feed->path; | |||||||||||||||||||||||||||||||||||||||||
| 968 | |||||||||||||||||||||||||||||||||||||||||||
| 969 | # Otherwise, just try to curl the URL | ||||||||||||||||||||||||||||||||||||||||||
| 970 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 971 | |||||||||||||||||||||||||||||||||||||||||||
| 972 | my ($rt, $resp, $head) = curl( | ||||||||||||||||||||||||||||||||||||||||||
| 973 | $feed->feed, | ||||||||||||||||||||||||||||||||||||||||||
| 974 | $feed->path, | ||||||||||||||||||||||||||||||||||||||||||
| 975 | verbose => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 976 | remote_time => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 977 | etag_save => $feed->etag, | ||||||||||||||||||||||||||||||||||||||||||
| 978 | limit_rate => $self->{ RateLimit }, | ||||||||||||||||||||||||||||||||||||||||||
| 979 | user_agent => $self->{ UserAgent }, | ||||||||||||||||||||||||||||||||||||||||||
| 980 | timeout => $self->{ Timeout }, | ||||||||||||||||||||||||||||||||||||||||||
| 981 | fail => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 982 | proxy => $self->{ Proxy }, | ||||||||||||||||||||||||||||||||||||||||||
| 983 | proxy_user => $self->{ ProxyUser }, | ||||||||||||||||||||||||||||||||||||||||||
| 984 | ( | ||||||||||||||||||||||||||||||||||||||||||
| 985 | 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
| |||||||||||||||||||||||||||||||||||||||||||
| 986 | ? ( | ||||||||||||||||||||||||||||||||||||||||||
| 987 | time_cond => $feed->path, | ||||||||||||||||||||||||||||||||||||||||||
| 988 | etag_compare => (-s $feed->etag ? $feed->etag : undef), | ||||||||||||||||||||||||||||||||||||||||||
| 989 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 990 | : () | ||||||||||||||||||||||||||||||||||||||||||
| 991 | ), | ||||||||||||||||||||||||||||||||||||||||||
| 992 | redirect => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 993 | compressed => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 994 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 995 | |||||||||||||||||||||||||||||||||||||||||||
| 996 | 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
| |||||||||||||||||||||||||||||||||||||||||||
| 997 | 0 | my $retry = $head->{ 'retry-after' }; | |||||||||||||||||||||||||||||||||||||||||
| 998 | 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
| |||||||||||||||||||||||||||||||||||||||||||
| 999 | 0 | $feed->set_retry($retry + time); | |||||||||||||||||||||||||||||||||||||||||
| 1000 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1001 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1002 | |||||||||||||||||||||||||||||||||||||||||||
| 1003 | 0 | ▶ | if ($rt != 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1004 | 0 | my $e; | |||||||||||||||||||||||||||||||||||||||||
| 1005 | 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
| |||||||||||||||||||||||||||||||||||||||||||
| 1006 | 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])
| |||||||||||||||||||||||||||||||||||||||||||
| 1007 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1008 | 0 | $e = curl_error($rt); | |||||||||||||||||||||||||||||||||||||||||
| 1009 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1010 | 0 | die "$e\n"; | |||||||||||||||||||||||||||||||||||||||||
| 1011 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1012 | |||||||||||||||||||||||||||||||||||||||||||
| 1013 | 0 | return $feed->path; | |||||||||||||||||||||||||||||||||||||||||
| 1014 | |||||||||||||||||||||||||||||||||||||||||||
| 1015 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1016 | |||||||||||||||||||||||||||||||||||||||||||
| 1017 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1018 | |||||||||||||||||||||||||||||||||||||||||||
| 1019 | sub update { | ||||||||||||||||||||||||||||||||||||||||||
| 1020 | |||||||||||||||||||||||||||||||||||||||||||
| 1021 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
update: not called CC=30 SCAR=68.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1022 | |||||||||||||||||||||||||||||||||||||||||||
| 1023 | 0 | require Parallel::ForkManager; | |||||||||||||||||||||||||||||||||||||||||
| 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 $pm = Parallel::ForkManager->new($self->{ Forks }); | |||||||||||||||||||||||||||||||||||||||||
| 1067 | $pm->run_on_finish(sub { | ||||||||||||||||||||||||||||||||||||||||||
| 1068 | 0 | ▶ | push @change, ${ $_[5] } if defined $_[5]; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1069 | 0 | }); | |||||||||||||||||||||||||||||||||||||||||
| 1070 | 0 | DOWNLOAD: for my $u (@updates) { | |||||||||||||||||||||||||||||||||||||||||
| 1071 | |||||||||||||||||||||||||||||||||||||||||||
| 1072 | 0 | ▶ | $pm->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 | $pm->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 | $pm->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 | $pm->finish(0, \$name); | |||||||||||||||||||||||||||||||||||||||||
| 1107 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1108 | 0 | ▶ | $pm->finish(0, $changed ? \$name : undef); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1109 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1110 | |||||||||||||||||||||||||||||||||||||||||||
| 1111 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1112 | |||||||||||||||||||||||||||||||||||||||||||
| 1113 | 0 | $pm->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 | sub reload { | ||||||||||||||||||||||||||||||||||||||||||
| 1151 | |||||||||||||||||||||||||||||||||||||||||||
| 1152 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
reload: not called CC=16 SCAR=56.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 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 | sub read_post { | ||||||||||||||||||||||||||||||||||||||||||
| 1229 | |||||||||||||||||||||||||||||||||||||||||||
| 1230 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
read_post: not called CC=14 SCAR=53.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 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 | $fmt_codes{ $f } = sub { | ||||||||||||||||||||||||||||||||||||||||||
| 1269 | 0 | ▶ | escape_html($POST_FMT_CODES{ $f }->($_[0])) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 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 | sub open_post { | ||||||||||||||||||||||||||||||||||||||||||
| 1321 | |||||||||||||||||||||||||||||||||||||||||||
| 1322 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
open_post: not called CC=13 SCAR=52.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 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 | system "$self->{ Browser } $url"; | |||||||||||||||||||||||||||||||||||||||||
| 1363 | |||||||||||||||||||||||||||||||||||||||||||
| 1364 | 0 | ▶ | unless ($? >> 8 == 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1365 | 0 | die "Failed to open $url with $self->{ Browser }\n"; | |||||||||||||||||||||||||||||||||||||||||
| 1366 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1367 | |||||||||||||||||||||||||||||||||||||||||||
| 1368 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||
| 1369 | $self->{ DB }->mark('read', $feed_name, $post->{ nossid }) | ||||||||||||||||||||||||||||||||||||||||||
| 1370 | 0 | ▶ | or die "Failed to mark '$feed_name:$id' as read"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1371 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1372 | |||||||||||||||||||||||||||||||||||||||||||
| 1373 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 1374 | |||||||||||||||||||||||||||||||||||||||||||
| 1375 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1376 | |||||||||||||||||||||||||||||||||||||||||||
| 1377 | sub cat { | ||||||||||||||||||||||||||||||||||||||||||
| 1378 | |||||||||||||||||||||||||||||||||||||||||||
| 1379 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cat: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1380 | |||||||||||||||||||||||||||||||||||||||||||
| 1381 | 0 | $self->{ Stdout } = 1; | |||||||||||||||||||||||||||||||||||||||||
| 1382 | 0 | $self->read_post; | |||||||||||||||||||||||||||||||||||||||||
| 1383 | |||||||||||||||||||||||||||||||||||||||||||
| 1384 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 1385 | |||||||||||||||||||||||||||||||||||||||||||
| 1386 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1387 | |||||||||||||||||||||||||||||||||||||||||||
| 1388 | sub look { | ||||||||||||||||||||||||||||||||||||||||||
| 1389 | |||||||||||||||||||||||||||||||||||||||||||
| 1390 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
look: not called CC=16 SCAR=56.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1391 | |||||||||||||||||||||||||||||||||||||||||||
| 1392 | 0 | my @feeds; | |||||||||||||||||||||||||||||||||||||||||
| 1393 | |||||||||||||||||||||||||||||||||||||||||||
| 1394 | 0 | ▶ | if (@{ $self->{ Args } }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 1395 | 0 | my %feedset; | |||||||||||||||||||||||||||||||||||||||||
| 1396 | 0 | for my $arg (@{ $self->{ Args } }) { | |||||||||||||||||||||||||||||||||||||||||
| 1397 | 0 | ▶ | if (exists $self->{ Feeds }{ $arg }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 1398 | 0 | $feedset{ $arg } = 1; | |||||||||||||||||||||||||||||||||||||||||
| 1399 | } elsif (exists $self->{ Groups }{ $arg }) { | ||||||||||||||||||||||||||||||||||||||||||
| 1400 | 0 | for my $k (@{ $self->{ Groups }{ $arg }->feeds }) { | |||||||||||||||||||||||||||||||||||||||||
| 1401 | 0 | $feedset{ $k } = 1; | |||||||||||||||||||||||||||||||||||||||||
| 1402 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1403 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1404 | 0 | warn "'$arg' is not the name of a feed or feed group, skipping\n"; | |||||||||||||||||||||||||||||||||||||||||
| 1405 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1406 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1407 | 0 | @feeds = keys %feedset; | |||||||||||||||||||||||||||||||||||||||||
| 1408 | } elsif ($self->{ ShowHidden }) { | ||||||||||||||||||||||||||||||||||||||||||
| 1409 | 0 | @feeds = keys %{ $self->{ Feeds } }; | |||||||||||||||||||||||||||||||||||||||||
| 1410 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1411 | @feeds = | ||||||||||||||||||||||||||||||||||||||||||
| 1412 | 0 | grep { not $self->{ Feeds }{ $_ }->hidden } | |||||||||||||||||||||||||||||||||||||||||
| 1413 | 0 | keys %{ $self->{ Feeds } }; | |||||||||||||||||||||||||||||||||||||||||
| 1414 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1415 | |||||||||||||||||||||||||||||||||||||||||||
| 1416 | my $titlerx = | ||||||||||||||||||||||||||||||||||||||||||
| 1417 | defined $self->{ Title } | ||||||||||||||||||||||||||||||||||||||||||
| 1418 | ? _arg2rx($self->{ Title }) | ||||||||||||||||||||||||||||||||||||||||||
| 1419 | 0 | ▶ | : undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1420 | 0 | my @contrx = map { _arg2rx($_) } @{ $self->{ Content } }; | |||||||||||||||||||||||||||||||||||||||||
| 1421 | |||||||||||||||||||||||||||||||||||||||||||
| 1422 | 0 | ▶ | unless (@feeds) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1423 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 1424 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1425 | |||||||||||||||||||||||||||||||||||||||||||
| 1426 | 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)
| |||||||||||||||||||||||||||||||||||||||||||
| 1427 | 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))
| |||||||||||||||||||||||||||||||||||||||||||
| 1428 | |||||||||||||||||||||||||||||||||||||||||||
| 1429 | 0 | my $readfmt = do { | |||||||||||||||||||||||||||||||||||||||||
| 1430 | 0 | my $fmt = $self->{ ListFmt }; | |||||||||||||||||||||||||||||||||||||||||
| 1431 | 0 | ▶ | if (not defined $fmt) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1432 | 0 | $fmt = sprintf "<7>%%s <6>%%-%df <3>%%%di <8>%%t", $feedlen, $idlen; | |||||||||||||||||||||||||||||||||||||||||
| 1433 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1434 | 0 | ▶ | if (!$self->{ UseColor }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1435 | 0 | $fmt = _rm_color_codes($fmt); | |||||||||||||||||||||||||||||||||||||||||
| 1436 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1437 | 0 | _fmt($fmt, \%POST_FMT_CODES, $self->{ ColorMap }); | |||||||||||||||||||||||||||||||||||||||||
| 1438 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 1439 | 0 | my $unreadfmt = do { | |||||||||||||||||||||||||||||||||||||||||
| 1440 | 0 | my $fmt = $self->{ ListUnreadFmt }; | |||||||||||||||||||||||||||||||||||||||||
| 1441 | 0 | ▶ | if (not defined $fmt) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1442 | 0 | ▶ | if (defined $self->{ ListFmt }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1443 | 0 | $fmt = $self->{ ListFmt }; | |||||||||||||||||||||||||||||||||||||||||
| 1444 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1445 | 0 | $fmt = sprintf "<15>%%s <14>%%-%df <11>%%%di <16>%%t", $feedlen, $idlen; | |||||||||||||||||||||||||||||||||||||||||
| 1446 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1447 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1448 | 0 | ▶ | if (!$self->{ UseColor }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1449 | 0 | $fmt = _rm_color_codes($fmt); | |||||||||||||||||||||||||||||||||||||||||
| 1450 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1451 | 0 | _fmt($fmt, \%POST_FMT_CODES, $self->{ ColorMap }); | |||||||||||||||||||||||||||||||||||||||||
| 1452 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 1453 | |||||||||||||||||||||||||||||||||||||||||||
| 1454 | my $callback = sub { | ||||||||||||||||||||||||||||||||||||||||||
| 1455 | 0 | ▶ | print $_[0]->{ status } eq 'read' | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1456 | ? $readfmt->($_[0]) | ||||||||||||||||||||||||||||||||||||||||||
| 1457 | : $unreadfmt->($_[0]); | ||||||||||||||||||||||||||||||||||||||||||
| 1458 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 1459 | |||||||||||||||||||||||||||||||||||||||||||
| 1460 | $self->{ DB }->look( | ||||||||||||||||||||||||||||||||||||||||||
| 1461 | title => $titlerx, | ||||||||||||||||||||||||||||||||||||||||||
| 1462 | feeds => \@feeds, | ||||||||||||||||||||||||||||||||||||||||||
| 1463 | status => $self->{ Status }, | ||||||||||||||||||||||||||||||||||||||||||
| 1464 | 0 | tags => [ map { qr/\Q$_\E/i } @{ $self->{ Tags } } ], | |||||||||||||||||||||||||||||||||||||||||
| 1465 | content => \@contrx, | ||||||||||||||||||||||||||||||||||||||||||
| 1466 | order => $self->{ Sort }, | ||||||||||||||||||||||||||||||||||||||||||
| 1467 | reverse => $self->{ Reverse }, | ||||||||||||||||||||||||||||||||||||||||||
| 1468 | limit => $self->{ ListLimit }, | ||||||||||||||||||||||||||||||||||||||||||
| 1469 | 0 | callback => $callback, | |||||||||||||||||||||||||||||||||||||||||
| 1470 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1471 | |||||||||||||||||||||||||||||||||||||||||||
| 1472 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 1473 | |||||||||||||||||||||||||||||||||||||||||||
| 1474 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1475 | |||||||||||||||||||||||||||||||||||||||||||
| 1476 | sub unread { | ||||||||||||||||||||||||||||||||||||||||||
| 1477 | |||||||||||||||||||||||||||||||||||||||||||
| 1478 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unread: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1479 | |||||||||||||||||||||||||||||||||||||||||||
| 1480 | 0 | $self->{ Status } = 'unread'; | |||||||||||||||||||||||||||||||||||||||||
| 1481 | |||||||||||||||||||||||||||||||||||||||||||
| 1482 | 0 | $self->look; | |||||||||||||||||||||||||||||||||||||||||
| 1483 | |||||||||||||||||||||||||||||||||||||||||||
| 1484 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 1485 | |||||||||||||||||||||||||||||||||||||||||||
| 1486 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1487 | |||||||||||||||||||||||||||||||||||||||||||
| 1488 | sub mark { | ||||||||||||||||||||||||||||||||||||||||||
| 1489 | |||||||||||||||||||||||||||||||||||||||||||
| 1490 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mark: not called CC=14 SCAR=53.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1491 | |||||||||||||||||||||||||||||||||||||||||||
| 1492 | 0 | my $status = shift @{ $self->{ Args } }; | |||||||||||||||||||||||||||||||||||||||||
| 1493 | |||||||||||||||||||||||||||||||||||||||||||
| 1494 | 0 | ▶ | unless (defined $status) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1495 | 0 | die "'mark' requires a status as argument\n"; | |||||||||||||||||||||||||||||||||||||||||
| 1496 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1497 | |||||||||||||||||||||||||||||||||||||||||||
| 1498 | 0 | ▶ | unless ($status =~ /^(un)?read$/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1499 | 0 | die "status must either be 'read' or 'unread'\n"; | |||||||||||||||||||||||||||||||||||||||||
| 1500 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1501 | |||||||||||||||||||||||||||||||||||||||||||
| 1502 | 0 | my @feeds; | |||||||||||||||||||||||||||||||||||||||||
| 1503 | my @posts; | ||||||||||||||||||||||||||||||||||||||||||
| 1504 | |||||||||||||||||||||||||||||||||||||||||||
| 1505 | 0 | my $targ = shift @{ $self->{ Args } }; | |||||||||||||||||||||||||||||||||||||||||
| 1506 | |||||||||||||||||||||||||||||||||||||||||||
| 1507 | 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'}
| |||||||||||||||||||||||||||||||||||||||||||
| 1508 | 0 | die "mark requires a feed name or group as argument\n"; | |||||||||||||||||||||||||||||||||||||||||
| 1509 | ▶ | } 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"}
| |||||||||||||||||||||||||||||||||||||||||||
| 1510 | 0 | die "mark --all should not be given a feed name or group as argument\n"; | |||||||||||||||||||||||||||||||||||||||||
| 1511 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1512 | |||||||||||||||||||||||||||||||||||||||||||
| 1513 | 0 | ▶ | if ($self->{ MarkAll }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 1514 | 0 | @feeds = keys %{ $self->{ Feeds } }; | |||||||||||||||||||||||||||||||||||||||||
| 1515 | 0 | @posts = (); | |||||||||||||||||||||||||||||||||||||||||
| 1516 | } elsif (exists $self->{ Groups }{ $targ }) { | ||||||||||||||||||||||||||||||||||||||||||
| 1517 | 0 | @feeds = @{ $self->{ Groups }{ $targ }->feeds }; | |||||||||||||||||||||||||||||||||||||||||
| 1518 | 0 | @posts = (); | |||||||||||||||||||||||||||||||||||||||||
| 1519 | } elsif (exists $self->{ Feeds }{ $targ }) { | ||||||||||||||||||||||||||||||||||||||||||
| 1520 | 0 | @feeds = ($targ); | |||||||||||||||||||||||||||||||||||||||||
| 1521 | 0 | for my $p (@{ $self->{ Args } }) { | |||||||||||||||||||||||||||||||||||||||||
| 1522 | 0 | ▶ | unless ($p =~ /^(?<from>\d+)(-(?<to>\d+))?$/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1523 | 0 | die "'$p' is not a post argument\n"; | |||||||||||||||||||||||||||||||||||||||||
| 1524 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1525 | 0 | ▶ | push @posts, $+{ from } .. $+{ to } // $+{ from }; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$+{"to"} // $+{"from"}
MC/DC0%0/2
$+{"to"} // $+{"from"}
$+{"to"}
$+{"from"}
Truth table0%0/3
A // B
A= $+{"to"}B= $+{"from"}
| |||||||||||||||||||||||||||||||||||||||||||
| 1526 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1527 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1528 | 0 | die "'$targ' is not the name of a feed or group\n"; | |||||||||||||||||||||||||||||||||||||||||
| 1529 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1530 | |||||||||||||||||||||||||||||||||||||||||||
| 1531 | 0 | my $num = 0; | |||||||||||||||||||||||||||||||||||||||||
| 1532 | |||||||||||||||||||||||||||||||||||||||||||
| 1533 | 0 | for my $f (@feeds) { | |||||||||||||||||||||||||||||||||||||||||
| 1534 | 0 | my $n = $self->{ DB }->mark($status, $f, @posts); | |||||||||||||||||||||||||||||||||||||||||
| 1535 | 0 | $num += $n; | |||||||||||||||||||||||||||||||||||||||||
| 1536 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1537 | |||||||||||||||||||||||||||||||||||||||||||
| 1538 | 0 | say "$num posts updated"; | |||||||||||||||||||||||||||||||||||||||||
| 1539 | |||||||||||||||||||||||||||||||||||||||||||
| 1540 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 1541 | |||||||||||||||||||||||||||||||||||||||||||
| 1542 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1543 | |||||||||||||||||||||||||||||||||||||||||||
| 1544 | sub post { | ||||||||||||||||||||||||||||||||||||||||||
| 1545 | |||||||||||||||||||||||||||||||||||||||||||
| 1546 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
post: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1547 | |||||||||||||||||||||||||||||||||||||||||||
| 1548 | 0 | my $feed = shift @{ $self->{ Args } }; | |||||||||||||||||||||||||||||||||||||||||
| 1549 | 0 | my $id = shift @{ $self->{ Args } }; | |||||||||||||||||||||||||||||||||||||||||
| 1550 | |||||||||||||||||||||||||||||||||||||||||||
| 1551 | 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
| |||||||||||||||||||||||||||||||||||||||||||
| 1552 | 0 | die "post requires a feed name and post ID as argument\n"; | |||||||||||||||||||||||||||||||||||||||||
| 1553 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1554 | |||||||||||||||||||||||||||||||||||||||||||
| 1555 | 0 | ▶ | unless (exists $self->{ Feeds }{ $feed }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1556 | 0 | die "'$feed' is not the name of a feed\n"; | |||||||||||||||||||||||||||||||||||||||||
| 1557 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1558 | |||||||||||||||||||||||||||||||||||||||||||
| 1559 | 0 | ▶ | unless ($id =~ /^-?\d+$/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1560 | 0 | die "Post ID must be an integar\n"; | |||||||||||||||||||||||||||||||||||||||||
| 1561 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1562 | |||||||||||||||||||||||||||||||||||||||||||
| 1563 | 0 | my $post = $self->{ DB }->post($feed, $id); | |||||||||||||||||||||||||||||||||||||||||
| 1564 | |||||||||||||||||||||||||||||||||||||||||||
| 1565 | 0 | ▶ | unless (defined $post) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1566 | 0 | die "'$feed:$id' does not exist\n"; | |||||||||||||||||||||||||||||||||||||||||
| 1567 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1568 | |||||||||||||||||||||||||||||||||||||||||||
| 1569 | 0 | ▶ | if (!$self->{ UseColor }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1570 | 0 | $self->{ PostFmt } = _rm_color_codes($self->{ PostFmt }); | |||||||||||||||||||||||||||||||||||||||||
| 1571 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1572 | |||||||||||||||||||||||||||||||||||||||||||
| 1573 | my $fmt = _fmt( | ||||||||||||||||||||||||||||||||||||||||||
| 1574 | $self->{ PostFmt }, | ||||||||||||||||||||||||||||||||||||||||||
| 1575 | \%POST_FMT_CODES, | ||||||||||||||||||||||||||||||||||||||||||
| 1576 | $self->{ ColorMap } | ||||||||||||||||||||||||||||||||||||||||||
| 1577 | 0 | ); | |||||||||||||||||||||||||||||||||||||||||
| 1578 | |||||||||||||||||||||||||||||||||||||||||||
| 1579 | 0 | print $fmt->($post); | |||||||||||||||||||||||||||||||||||||||||
| 1580 | |||||||||||||||||||||||||||||||||||||||||||
| 1581 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 1582 | |||||||||||||||||||||||||||||||||||||||||||
| 1583 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1584 | |||||||||||||||||||||||||||||||||||||||||||
| 1585 | sub feeds { | ||||||||||||||||||||||||||||||||||||||||||
| 1586 | |||||||||||||||||||||||||||||||||||||||||||
| 1587 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
feeds: not called CC=10 SCAR=47.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1588 | |||||||||||||||||||||||||||||||||||||||||||
| 1589 | 0 | my @feeds; | |||||||||||||||||||||||||||||||||||||||||
| 1590 | |||||||||||||||||||||||||||||||||||||||||||
| 1591 | 0 | ▶ | if (@{ $self->{ Args } }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1592 | 0 | my %feedset; | |||||||||||||||||||||||||||||||||||||||||
| 1593 | 0 | for my $a (@{ $self->{ Args } }) { | |||||||||||||||||||||||||||||||||||||||||
| 1594 | 0 | ▶ | if (exists $self->{ Feeds }{ $a }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 1595 | 0 | $feedset{ $a } = 1; | |||||||||||||||||||||||||||||||||||||||||
| 1596 | } elsif (exists $self->{ Groups }{ $a }) { | ||||||||||||||||||||||||||||||||||||||||||
| 1597 | 0 | for my $f (@{ $self->{ Groups }{ $a }->feeds }) { | |||||||||||||||||||||||||||||||||||||||||
| 1598 | 0 | $feedset{ $f } = 1; | |||||||||||||||||||||||||||||||||||||||||
| 1599 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1600 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1601 | 0 | warn "'$a' is not the name of a feed or group, skipping\n"; | |||||||||||||||||||||||||||||||||||||||||
| 1602 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1603 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1604 | 0 | @feeds = sort keys %feedset; | |||||||||||||||||||||||||||||||||||||||||
| 1605 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1606 | 0 | @feeds = sort keys %{ $self->{ Feeds } }; | |||||||||||||||||||||||||||||||||||||||||
| 1607 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1608 | |||||||||||||||||||||||||||||||||||||||||||
| 1609 | 0 | ▶ | unless (@feeds) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1610 | 0 | die "No feeds can be printed\n"; | |||||||||||||||||||||||||||||||||||||||||
| 1611 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1612 | |||||||||||||||||||||||||||||||||||||||||||
| 1613 | 0 | ▶ | if (!$self->{ UseColor }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1614 | 0 | $self->{ FeedsFmt } = _rm_color_codes($self->{ FeedsFmt }); | |||||||||||||||||||||||||||||||||||||||||
| 1615 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1616 | |||||||||||||||||||||||||||||||||||||||||||
| 1617 | 0 | my $cb = _fmt($self->{ FeedsFmt }, \%FEED_FMT_CODES, $self->{ ColorMap }); | |||||||||||||||||||||||||||||||||||||||||
| 1618 | |||||||||||||||||||||||||||||||||||||||||||
| 1619 | 0 | for my $n (@feeds) { | |||||||||||||||||||||||||||||||||||||||||
| 1620 | |||||||||||||||||||||||||||||||||||||||||||
| 1621 | 0 | my $f = $self->{ DB }->feed($n, post_info => 1); | |||||||||||||||||||||||||||||||||||||||||
| 1622 | |||||||||||||||||||||||||||||||||||||||||||
| 1623 | $f //= { | ||||||||||||||||||||||||||||||||||||||||||
| 1624 | nossname => $self->{ Feeds }{ $n }->name, | ||||||||||||||||||||||||||||||||||||||||||
| 1625 | 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
| |||||||||||||||||||||||||||||||||||||||||||
| 1626 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 1627 | |||||||||||||||||||||||||||||||||||||||||||
| 1628 | 0 | print $cb->($f); | |||||||||||||||||||||||||||||||||||||||||
| 1629 | |||||||||||||||||||||||||||||||||||||||||||
| 1630 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1631 | |||||||||||||||||||||||||||||||||||||||||||
| 1632 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 1633 | |||||||||||||||||||||||||||||||||||||||||||
| 1634 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1635 | |||||||||||||||||||||||||||||||||||||||||||
| 1636 | sub groups { | ||||||||||||||||||||||||||||||||||||||||||
| 1637 | |||||||||||||||||||||||||||||||||||||||||||
| 1638 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
groups: not called CC=10 SCAR=47.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1639 | |||||||||||||||||||||||||||||||||||||||||||
| 1640 | 0 | my @groups; | |||||||||||||||||||||||||||||||||||||||||
| 1641 | |||||||||||||||||||||||||||||||||||||||||||
| 1642 | 0 | ▶ | if (@{ $self->{ Args } }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1643 | 0 | for my $a (@{ $self->{ Args } }) { | |||||||||||||||||||||||||||||||||||||||||
| 1644 | 0 | ▶ | if (exists $self->{ Groups }{ $a }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1645 | 0 | push @groups, $a; | |||||||||||||||||||||||||||||||||||||||||
| 1646 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1647 | 0 | warn "'$a' is not the name of a feed group, skipping\n"; | |||||||||||||||||||||||||||||||||||||||||
| 1648 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1649 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1650 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1651 | 0 | @groups = sort keys %{ $self->{ Groups } }; | |||||||||||||||||||||||||||||||||||||||||
| 1652 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1653 | |||||||||||||||||||||||||||||||||||||||||||
| 1654 | 0 | ▶ | unless (@groups) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1655 | 0 | die "No feed groups can be printed\n"; | |||||||||||||||||||||||||||||||||||||||||
| 1656 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1657 | |||||||||||||||||||||||||||||||||||||||||||
| 1658 | 0 | for my $i (0 .. $#groups) { | |||||||||||||||||||||||||||||||||||||||||
| 1659 | |||||||||||||||||||||||||||||||||||||||||||
| 1660 | my @feeds = | ||||||||||||||||||||||||||||||||||||||||||
| 1661 | 0 | grep { exists $self->{ Feeds }{ $_ } } | |||||||||||||||||||||||||||||||||||||||||
| 1662 | 0 | @{ $self->{ Groups }{ $groups[$i] }->feeds }; | |||||||||||||||||||||||||||||||||||||||||
| 1663 | |||||||||||||||||||||||||||||||||||||||||||
| 1664 | 0 | ▶ | @feeds = ('(none)') unless @feeds; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1665 | |||||||||||||||||||||||||||||||||||||||||||
| 1666 | 0 | say $groups[$i]; | |||||||||||||||||||||||||||||||||||||||||
| 1667 | |||||||||||||||||||||||||||||||||||||||||||
| 1668 | 0 | ▶ | unless ($self->{ Brief }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1669 | 0 | for my $f (@feeds) { | |||||||||||||||||||||||||||||||||||||||||
| 1670 | 0 | say " $f"; | |||||||||||||||||||||||||||||||||||||||||
| 1671 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1672 | 0 | ▶ | print "\n" unless $i == $#groups; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1673 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1674 | |||||||||||||||||||||||||||||||||||||||||||
| 1675 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1676 | |||||||||||||||||||||||||||||||||||||||||||
| 1677 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 1678 | |||||||||||||||||||||||||||||||||||||||||||
| 1679 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1680 | |||||||||||||||||||||||||||||||||||||||||||
| 1681 | sub clean { | ||||||||||||||||||||||||||||||||||||||||||
| 1682 | |||||||||||||||||||||||||||||||||||||||||||
| 1683 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clean: not called CC=10 SCAR=47.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1684 | |||||||||||||||||||||||||||||||||||||||||||
| 1685 | 0 | for my $f (dir($self->{ FeedDir })) { | |||||||||||||||||||||||||||||||||||||||||
| 1686 | |||||||||||||||||||||||||||||||||||||||||||
| 1687 | 0 | ▶ | next unless $f =~ /\.feed$/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1688 | |||||||||||||||||||||||||||||||||||||||||||
| 1689 | 0 | my $feed = (fileparse($f, qr/\.[^.]*/))[0]; | |||||||||||||||||||||||||||||||||||||||||
| 1690 | |||||||||||||||||||||||||||||||||||||||||||
| 1691 | 0 | ▶ | unless (exists $self->{ Feeds }{ $feed }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1692 | 0 | ▶ | unlink $f or warn "Failed to unlink $f\n"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1693 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1694 | |||||||||||||||||||||||||||||||||||||||||||
| 1695 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1696 | |||||||||||||||||||||||||||||||||||||||||||
| 1697 | 0 | for my $f (dir($self->{ EtagDir })) { | |||||||||||||||||||||||||||||||||||||||||
| 1698 | |||||||||||||||||||||||||||||||||||||||||||
| 1699 | 0 | ▶ | next unless $f =~ /\.etag/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1700 | |||||||||||||||||||||||||||||||||||||||||||
| 1701 | 0 | my $feed = (fileparse($f, qr/\.[^.]*/))[0]; | |||||||||||||||||||||||||||||||||||||||||
| 1702 | |||||||||||||||||||||||||||||||||||||||||||
| 1703 | 0 | ▶ | unless (exists $self->{ Feeds }{ $feed }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1704 | 0 | ▶ | unlink $f or warn "Failed to unlink $f\n"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1705 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1706 | |||||||||||||||||||||||||||||||||||||||||||
| 1707 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1708 | |||||||||||||||||||||||||||||||||||||||||||
| 1709 | 0 | my @dbfeeds = $self->{ DB }->feeds; | |||||||||||||||||||||||||||||||||||||||||
| 1710 | |||||||||||||||||||||||||||||||||||||||||||
| 1711 | my @clean = | ||||||||||||||||||||||||||||||||||||||||||
| 1712 | 0 | grep { not exists $self->{ Feeds }{ $_ } } | |||||||||||||||||||||||||||||||||||||||||
| 1713 | 0 | map { $_->{ nossname } } | |||||||||||||||||||||||||||||||||||||||||
| 1714 | 0 | $self->{ DB }->feeds; | |||||||||||||||||||||||||||||||||||||||||
| 1715 | |||||||||||||||||||||||||||||||||||||||||||
| 1716 | 0 | ▶ | if (@clean) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1717 | 0 | $self->{ DB }->del_feeds(@clean); | |||||||||||||||||||||||||||||||||||||||||
| 1718 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1719 | |||||||||||||||||||||||||||||||||||||||||||
| 1720 | 0 | $self->{ DB }->vacuum; | |||||||||||||||||||||||||||||||||||||||||
| 1721 | |||||||||||||||||||||||||||||||||||||||||||
| 1722 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 1723 | |||||||||||||||||||||||||||||||||||||||||||
| 1724 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1725 | |||||||||||||||||||||||||||||||||||||||||||
| 1726 | sub discover { | ||||||||||||||||||||||||||||||||||||||||||
| 1727 | |||||||||||||||||||||||||||||||||||||||||||
| 1728 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
discover: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1729 | |||||||||||||||||||||||||||||||||||||||||||
| 1730 | 0 | my $url = shift @{ $self->{ Args } }; | |||||||||||||||||||||||||||||||||||||||||
| 1731 | 0 | ▶ | if (not defined $url) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1732 | 0 | die "discover requires a URL as argument\n"; | |||||||||||||||||||||||||||||||||||||||||
| 1733 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1734 | |||||||||||||||||||||||||||||||||||||||||||
| 1735 | 0 | my $tmp = do { | |||||||||||||||||||||||||||||||||||||||||
| 1736 | 0 | my ($h, $p) = tempfile(UNLINK => 1); | |||||||||||||||||||||||||||||||||||||||||
| 1737 | 0 | close $h; | |||||||||||||||||||||||||||||||||||||||||
| 1738 | 0 | $p; | |||||||||||||||||||||||||||||||||||||||||
| 1739 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 1740 | |||||||||||||||||||||||||||||||||||||||||||
| 1741 | my ($rt, undef, undef) = curl( | ||||||||||||||||||||||||||||||||||||||||||
| 1742 | $url, $tmp, | ||||||||||||||||||||||||||||||||||||||||||
| 1743 | user_agent => $self->{ UserAgent }, | ||||||||||||||||||||||||||||||||||||||||||
| 1744 | limit_rate => $self->{ RateLimit }, | ||||||||||||||||||||||||||||||||||||||||||
| 1745 | timeout => $self->{ Timeout }, | ||||||||||||||||||||||||||||||||||||||||||
| 1746 | fail => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 1747 | proxy => $self->{ Proxy }, | ||||||||||||||||||||||||||||||||||||||||||
| 1748 | proxy_user => $self->{ ProxyUser }, | ||||||||||||||||||||||||||||||||||||||||||
| 1749 | 0 | redirect => 1, | |||||||||||||||||||||||||||||||||||||||||
| 1750 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1751 | |||||||||||||||||||||||||||||||||||||||||||
| 1752 | 0 | ▶ | if ($rt != 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1753 | 0 | die sprintf "Failed to curl %s: %s\n", $url, curl_error($rt); | |||||||||||||||||||||||||||||||||||||||||
| 1754 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1755 | |||||||||||||||||||||||||||||||||||||||||||
| 1756 | 0 | my @feeds = discover_feeds($tmp); | |||||||||||||||||||||||||||||||||||||||||
| 1757 | 0 | ▶ | if (!@feeds) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1758 | 0 | say "No feeds found in $url"; | |||||||||||||||||||||||||||||||||||||||||
| 1759 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 1760 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1761 | |||||||||||||||||||||||||||||||||||||||||||
| 1762 | 0 | @feeds = uniq sort map { resolve_url($_, $url) } @feeds; | |||||||||||||||||||||||||||||||||||||||||
| 1763 | 0 | for my $f (@feeds) { | |||||||||||||||||||||||||||||||||||||||||
| 1764 | 0 | say $f; | |||||||||||||||||||||||||||||||||||||||||
| 1765 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1766 | |||||||||||||||||||||||||||||||||||||||||||
| 1767 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 1768 | |||||||||||||||||||||||||||||||||||||||||||
| 1769 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1770 | |||||||||||||||||||||||||||||||||||||||||||
| 1771 | sub export_opml { | ||||||||||||||||||||||||||||||||||||||||||
| 1772 | |||||||||||||||||||||||||||||||||||||||||||
| 1773 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
export_opml: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1774 | |||||||||||||||||||||||||||||||||||||||||||
| 1775 | 0 | my $to = shift @{ $self->{ Args } }; | |||||||||||||||||||||||||||||||||||||||||
| 1776 | |||||||||||||||||||||||||||||||||||||||||||
| 1777 | 0 | my @feeds; | |||||||||||||||||||||||||||||||||||||||||
| 1778 | |||||||||||||||||||||||||||||||||||||||||||
| 1779 | 0 | for my $f (values %{ $self->{ Feeds } }) { | |||||||||||||||||||||||||||||||||||||||||
| 1780 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||
| 1781 | push @feeds, { | ||||||||||||||||||||||||||||||||||||||||||
| 1782 | title => $f->name, | ||||||||||||||||||||||||||||||||||||||||||
| 1783 | xml_url => $f->feed, | ||||||||||||||||||||||||||||||||||||||||||
| 1784 | 0 | groups => [ map { $_->name } @{ $f->groups } ], | |||||||||||||||||||||||||||||||||||||||||
| 1785 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 1786 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1787 | |||||||||||||||||||||||||||||||||||||||||||
| 1788 | 0 | my $opml = WWW::Noss::OPML->from_perl( | |||||||||||||||||||||||||||||||||||||||||
| 1789 | title => "$PRGNAM Feed List", | ||||||||||||||||||||||||||||||||||||||||||
| 1790 | feeds => \@feeds, | ||||||||||||||||||||||||||||||||||||||||||
| 1791 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1792 | |||||||||||||||||||||||||||||||||||||||||||
| 1793 | 0 | ▶ | if (defined $to) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1794 | 0 | $opml->to_file($to, folders => !$self->{ NoGroups }); | |||||||||||||||||||||||||||||||||||||||||
| 1795 | 0 | say "Wrote OPML to $to"; | |||||||||||||||||||||||||||||||||||||||||
| 1796 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1797 | 0 | $opml->to_fh(*STDOUT, folders => !$self->{ NoGroups }); | |||||||||||||||||||||||||||||||||||||||||
| 1798 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1799 | |||||||||||||||||||||||||||||||||||||||||||
| 1800 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 1801 | |||||||||||||||||||||||||||||||||||||||||||
| 1802 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1803 | |||||||||||||||||||||||||||||||||||||||||||
| 1804 | # TODO: --merge option? | ||||||||||||||||||||||||||||||||||||||||||
| 1805 | sub import_opml { | ||||||||||||||||||||||||||||||||||||||||||
| 1806 | |||||||||||||||||||||||||||||||||||||||||||
| 1807 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
import_opml: not called CC=14 SCAR=53.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1808 | |||||||||||||||||||||||||||||||||||||||||||
| 1809 | 0 | my $file = shift @{ $self->{ Args } }; | |||||||||||||||||||||||||||||||||||||||||
| 1810 | |||||||||||||||||||||||||||||||||||||||||||
| 1811 | 0 | ▶ | unless (defined $file) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1812 | 0 | die "import requires an OPML file as argument\n"; | |||||||||||||||||||||||||||||||||||||||||
| 1813 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1814 | |||||||||||||||||||||||||||||||||||||||||||
| 1815 | 0 | my $to = shift @{ $self->{ Args } }; | |||||||||||||||||||||||||||||||||||||||||
| 1816 | |||||||||||||||||||||||||||||||||||||||||||
| 1817 | 0 | my $json = { | |||||||||||||||||||||||||||||||||||||||||
| 1818 | default => {}, | ||||||||||||||||||||||||||||||||||||||||||
| 1819 | groups => {}, | ||||||||||||||||||||||||||||||||||||||||||
| 1820 | feeds => {}, | ||||||||||||||||||||||||||||||||||||||||||
| 1821 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 1822 | |||||||||||||||||||||||||||||||||||||||||||
| 1823 | 0 | my $opml = WWW::Noss::OPML->from_xml($file); | |||||||||||||||||||||||||||||||||||||||||
| 1824 | |||||||||||||||||||||||||||||||||||||||||||
| 1825 | my %groupset = | ||||||||||||||||||||||||||||||||||||||||||
| 1826 | 0 | map { $_ =~ s/\W//gr => {} } | |||||||||||||||||||||||||||||||||||||||||
| 1827 | 0 | ▶ | map { @{ $_->{ groups } // [] } } | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$_->{"groups"} // []
MC/DC0%0/1
$_->{"groups"} // []
$_->{"groups"}
Truth table0%0/2
A
A= $_->{"groups"}
| |||||||||||||||||||||||||||||||||||||||||||
| 1828 | 0 | @{ $opml->feeds }; | |||||||||||||||||||||||||||||||||||||||||
| 1829 | |||||||||||||||||||||||||||||||||||||||||||
| 1830 | 0 | for my $f (@{ $opml->feeds }) { | |||||||||||||||||||||||||||||||||||||||||
| 1831 | |||||||||||||||||||||||||||||||||||||||||||
| 1832 | 0 | my $name = $f->{ title } =~ s/\W//gr; | |||||||||||||||||||||||||||||||||||||||||
| 1833 | |||||||||||||||||||||||||||||||||||||||||||
| 1834 | 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}
| |||||||||||||||||||||||||||||||||||||||||||
| 1835 | 0 | warn "'$name' feed name conflict, $json->{ feeds }{ $name } will be lost\n"; | |||||||||||||||||||||||||||||||||||||||||
| 1836 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1837 | |||||||||||||||||||||||||||||||||||||||||||
| 1838 | 0 | ▶ | if (exists $groupset{ $name }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1839 | 0 | warn "'$name' group name conflict, $name group will be lost\n"; | |||||||||||||||||||||||||||||||||||||||||
| 1840 | 0 | delete $groupset{ $name }; | |||||||||||||||||||||||||||||||||||||||||
| 1841 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1842 | |||||||||||||||||||||||||||||||||||||||||||
| 1843 | 0 | $json->{ feeds }{ $name } = $f->{ xml_url }; | |||||||||||||||||||||||||||||||||||||||||
| 1844 | |||||||||||||||||||||||||||||||||||||||||||
| 1845 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||
| 1846 | 0 | $g =~ s/\W//g; | |||||||||||||||||||||||||||||||||||||||||
| 1847 | 0 | ▶ | next unless exists $groupset{ $g }; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1848 | 0 | $groupset{ $g }->{ $name } = 1; | |||||||||||||||||||||||||||||||||||||||||
| 1849 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1850 | |||||||||||||||||||||||||||||||||||||||||||
| 1851 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1852 | |||||||||||||||||||||||||||||||||||||||||||
| 1853 | 0 | ▶ | unless ($self->{ NoGroups }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1854 | 0 | for my $g (keys %groupset) { | |||||||||||||||||||||||||||||||||||||||||
| 1855 | 0 | $json->{ groups }{ $g } = [ sort keys %{ $groupset{ $g } } ]; | |||||||||||||||||||||||||||||||||||||||||
| 1856 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1857 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1858 | |||||||||||||||||||||||||||||||||||||||||||
| 1859 | 0 | my $json_obj = JSON->new->pretty->canonical; | |||||||||||||||||||||||||||||||||||||||||
| 1860 | |||||||||||||||||||||||||||||||||||||||||||
| 1861 | 0 | ▶ | if (defined $to) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1862 | 0 | ▶ | open my $fh, '>', $to | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1863 | or die "Failed to open $to for writing: $!\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 1864 | 0 | print { $fh } $json_obj->encode($json); | |||||||||||||||||||||||||||||||||||||||||
| 1865 | 0 | close $fh; | |||||||||||||||||||||||||||||||||||||||||
| 1866 | 0 | say "Wrote JSON to $to"; | |||||||||||||||||||||||||||||||||||||||||
| 1867 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1868 | 0 | print $json_obj->encode($json); | |||||||||||||||||||||||||||||||||||||||||
| 1869 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1870 | |||||||||||||||||||||||||||||||||||||||||||
| 1871 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 1872 | |||||||||||||||||||||||||||||||||||||||||||
| 1873 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1874 | |||||||||||||||||||||||||||||||||||||||||||
| 1875 | sub help { | ||||||||||||||||||||||||||||||||||||||||||
| 1876 | |||||||||||||||||||||||||||||||||||||||||||
| 1877 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
help: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1878 | |||||||||||||||||||||||||||||||||||||||||||
| 1879 | 0 | my $cmd = shift @{ $self->{ Args } }; | |||||||||||||||||||||||||||||||||||||||||
| 1880 | |||||||||||||||||||||||||||||||||||||||||||
| 1881 | 0 | ▶ | if (not defined $cmd) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1882 | 0 | pod2usage( | |||||||||||||||||||||||||||||||||||||||||
| 1883 | -exitval => 'NOEXIT', | ||||||||||||||||||||||||||||||||||||||||||
| 1884 | -verbose => 99, | ||||||||||||||||||||||||||||||||||||||||||
| 1885 | -sections => [ | ||||||||||||||||||||||||||||||||||||||||||
| 1886 | 'NAME', 'SYNOPSIS', 'DESCRIPTION', 'COMMANDS', | ||||||||||||||||||||||||||||||||||||||||||
| 1887 | 'GLOBAL OPTIONS', 'CONFIGURATION', 'ENVIRONMENT' | ||||||||||||||||||||||||||||||||||||||||||
| 1888 | ], | ||||||||||||||||||||||||||||||||||||||||||
| 1889 | -output => \*STDOUT, | ||||||||||||||||||||||||||||||||||||||||||
| 1890 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1891 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 1892 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1893 | |||||||||||||||||||||||||||||||||||||||||||
| 1894 | 0 | $cmd = lc $cmd; | |||||||||||||||||||||||||||||||||||||||||
| 1895 | |||||||||||||||||||||||||||||||||||||||||||
| 1896 | 0 | ▶ | if (not exists $COMMANDS{ $cmd }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1897 | 0 | die "'$cmd' is not a command\n"; | |||||||||||||||||||||||||||||||||||||||||
| 1898 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1899 | |||||||||||||||||||||||||||||||||||||||||||
| 1900 | pod2usage( | ||||||||||||||||||||||||||||||||||||||||||
| 1901 | 0 | -exitval => 'NOEXIT', | |||||||||||||||||||||||||||||||||||||||||
| 1902 | -verbose => 99, | ||||||||||||||||||||||||||||||||||||||||||
| 1903 | -sections => "COMMANDS/$cmd", | ||||||||||||||||||||||||||||||||||||||||||
| 1904 | -output => \*STDOUT, | ||||||||||||||||||||||||||||||||||||||||||
| 1905 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1906 | |||||||||||||||||||||||||||||||||||||||||||
| 1907 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 1908 | |||||||||||||||||||||||||||||||||||||||||||
| 1909 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1910 | |||||||||||||||||||||||||||||||||||||||||||
| 1911 | sub init { | ||||||||||||||||||||||||||||||||||||||||||
| 1912 | |||||||||||||||||||||||||||||||||||||||||||
| 1913 | 0 | ▶ | my ($class, @argv) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init: not called CC=48 SCAR=77.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1914 | |||||||||||||||||||||||||||||||||||||||||||
| 1915 | 0 | my $self = { | |||||||||||||||||||||||||||||||||||||||||
| 1916 | Cmd => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 1917 | Args => [], | ||||||||||||||||||||||||||||||||||||||||||
| 1918 | DataDir => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 1919 | FeedDir => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 1920 | EtagDir => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 1921 | FeedFile => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 1922 | ConfFile => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 1923 | Feeds => {}, | ||||||||||||||||||||||||||||||||||||||||||
| 1924 | Groups => {}, | ||||||||||||||||||||||||||||||||||||||||||
| 1925 | DefaultGroup => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 1926 | DB => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 1927 | AutoClean => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 1928 | TimeFmt => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 1929 | UseColor => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 1930 | ColorMap => { %COLOR_CODES }, | ||||||||||||||||||||||||||||||||||||||||||
| 1931 | RetryDir => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 1932 | # update | ||||||||||||||||||||||||||||||||||||||||||
| 1933 | NewOnly => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 1934 | NonDefaults => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 1935 | Forks => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 1936 | Unconditional => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 1937 | RateLimit => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 1938 | UserAgent => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 1939 | Timeout => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 1940 | Proxy => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 1941 | ProxyUser => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 1942 | HardReload => 0, # reload, too | ||||||||||||||||||||||||||||||||||||||||||
| 1943 | # read | ||||||||||||||||||||||||||||||||||||||||||
| 1944 | Pager => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 1945 | NoMark => 0, # open, too | ||||||||||||||||||||||||||||||||||||||||||
| 1946 | Stdout => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 1947 | LineWidth => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 1948 | ReadFmt => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 1949 | ReadHtml => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 1950 | # open | ||||||||||||||||||||||||||||||||||||||||||
| 1951 | Browser => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 1952 | # look/unread | ||||||||||||||||||||||||||||||||||||||||||
| 1953 | Title => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 1954 | Tags => [], | ||||||||||||||||||||||||||||||||||||||||||
| 1955 | Status => undef, # look only | ||||||||||||||||||||||||||||||||||||||||||
| 1956 | Content => [], | ||||||||||||||||||||||||||||||||||||||||||
| 1957 | Sort => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 1958 | Reverse => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 1959 | ListLimit => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 1960 | ShowHidden => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 1961 | ListFmt => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 1962 | ListUnreadFmt => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 1963 | # mark | ||||||||||||||||||||||||||||||||||||||||||
| 1964 | MarkAll => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 1965 | # post | ||||||||||||||||||||||||||||||||||||||||||
| 1966 | PostFmt => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 1967 | # feeds | ||||||||||||||||||||||||||||||||||||||||||
| 1968 | Brief => 0, # groups, too | ||||||||||||||||||||||||||||||||||||||||||
| 1969 | FeedsFmt => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 1970 | # export/import | ||||||||||||||||||||||||||||||||||||||||||
| 1971 | NoGroups => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 1972 | ExportSpec => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 1973 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 1974 | |||||||||||||||||||||||||||||||||||||||||||
| 1975 | 0 | Getopt::Long::config('bundling'); | |||||||||||||||||||||||||||||||||||||||||
| 1976 | 0 | Getopt::Long::config('pass_through'); | |||||||||||||||||||||||||||||||||||||||||
| 1977 | GetOptionsFromArray(\@argv, | ||||||||||||||||||||||||||||||||||||||||||
| 1978 | 'config|c=s' => \$self->{ ConfFile }, | ||||||||||||||||||||||||||||||||||||||||||
| 1979 | 'data|D=s' => \$self->{ DataDir }, | ||||||||||||||||||||||||||||||||||||||||||
| 1980 | 'feeds|f=s' => \$self->{ FeedFile }, | ||||||||||||||||||||||||||||||||||||||||||
| 1981 | 'autoclean|A:s' => sub { | ||||||||||||||||||||||||||||||||||||||||||
| 1982 | 0 | ▶ | if ($_[1] eq '' or $_[1] eq '1') { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
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
| |||||||||||||||||||||||||||||||||||||||||||
| 1983 | 0 | $self->{ AutoClean } = 1; | |||||||||||||||||||||||||||||||||||||||||
| 1984 | } elsif ($_[1] eq '0') { | ||||||||||||||||||||||||||||||||||||||||||
| 1985 | 0 | $self->{ AutoClean } = 0; | |||||||||||||||||||||||||||||||||||||||||
| 1986 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1987 | 0 | $self->{ AutoClean } = 1; | |||||||||||||||||||||||||||||||||||||||||
| 1988 | 0 | unshift @argv, $_[1]; | |||||||||||||||||||||||||||||||||||||||||
| 1989 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1990 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 1991 | 'time-format|z=s' => \$self->{ TimeFmt }, | ||||||||||||||||||||||||||||||||||||||||||
| 1992 | 'color|C:s' => sub { | ||||||||||||||||||||||||||||||||||||||||||
| 1993 | 0 | ▶ | if ($_[1] eq '' or $_[1] eq '1') { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
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
| |||||||||||||||||||||||||||||||||||||||||||
| 1994 | 0 | $self->{ UseColor } = 1; | |||||||||||||||||||||||||||||||||||||||||
| 1995 | } elsif ($_[1] eq '0') { | ||||||||||||||||||||||||||||||||||||||||||
| 1996 | 0 | $self->{ UseColor } = 0; | |||||||||||||||||||||||||||||||||||||||||
| 1997 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1998 | 0 | $self->{ UseColor } = 1; | |||||||||||||||||||||||||||||||||||||||||
| 1999 | 0 | unshift @argv, $_[1]; | |||||||||||||||||||||||||||||||||||||||||
| 2000 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2001 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 2002 | 0 | ▶ | 'no-color' => sub { $self->{ UseColor } = 0 }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 2003 | # update | ||||||||||||||||||||||||||||||||||||||||||
| 2004 | 'new-only' => \$self->{ NewOnly }, | ||||||||||||||||||||||||||||||||||||||||||
| 2005 | 'non-defaults' => \$self->{ NonDefaults }, | ||||||||||||||||||||||||||||||||||||||||||
| 2006 | 'downloads=i' => \$self->{ Forks }, | ||||||||||||||||||||||||||||||||||||||||||
| 2007 | 'unconditional' => \$self->{ Unconditional }, | ||||||||||||||||||||||||||||||||||||||||||
| 2008 | 'limit-rate=s' => \$self->{ RateLimit }, | ||||||||||||||||||||||||||||||||||||||||||
| 2009 | 'user-agent=s' => \$self->{ UserAgent }, | ||||||||||||||||||||||||||||||||||||||||||
| 2010 | 'timeout=f' => \$self->{ Timeout }, | ||||||||||||||||||||||||||||||||||||||||||
| 2011 | 'proxy=s' => \$self->{ Proxy }, | ||||||||||||||||||||||||||||||||||||||||||
| 2012 | 'proxy-user=s' => \$self->{ ProxyUser }, | ||||||||||||||||||||||||||||||||||||||||||
| 2013 | 'hard' => \$self->{ HardReload }, | ||||||||||||||||||||||||||||||||||||||||||
| 2014 | # read | ||||||||||||||||||||||||||||||||||||||||||
| 2015 | 'pager=s' => \$self->{ Pager }, | ||||||||||||||||||||||||||||||||||||||||||
| 2016 | 'no-mark' => \$self->{ NoMark }, # open, too | ||||||||||||||||||||||||||||||||||||||||||
| 2017 | 'stdout' => \$self->{ Stdout }, | ||||||||||||||||||||||||||||||||||||||||||
| 2018 | 'width=i' => \$self->{ LineWidth }, | ||||||||||||||||||||||||||||||||||||||||||
| 2019 | 'read-format=s' => \$self->{ ReadFmt }, | ||||||||||||||||||||||||||||||||||||||||||
| 2020 | 'html' => \$self->{ ReadHtml }, | ||||||||||||||||||||||||||||||||||||||||||
| 2021 | # open | ||||||||||||||||||||||||||||||||||||||||||
| 2022 | 'browser=s' => \$self->{ Browser }, | ||||||||||||||||||||||||||||||||||||||||||
| 2023 | # look/unread | ||||||||||||||||||||||||||||||||||||||||||
| 2024 | 'title=s' => \$self->{ Title }, | ||||||||||||||||||||||||||||||||||||||||||
| 2025 | 'tag=s' => $self->{ Tags }, | ||||||||||||||||||||||||||||||||||||||||||
| 2026 | 'status=s' => \$self->{ Status }, # look only | ||||||||||||||||||||||||||||||||||||||||||
| 2027 | 'content=s' => $self->{ Content }, | ||||||||||||||||||||||||||||||||||||||||||
| 2028 | 'sort=s' => \$self->{ Sort }, | ||||||||||||||||||||||||||||||||||||||||||
| 2029 | 'reverse' => \$self->{ Reverse }, | ||||||||||||||||||||||||||||||||||||||||||
| 2030 | 'list-limit=i' => \$self->{ ListLimit }, | ||||||||||||||||||||||||||||||||||||||||||
| 2031 | 'hidden' => \$self->{ ShowHidden }, | ||||||||||||||||||||||||||||||||||||||||||
| 2032 | 'list-format=s' => sub { | ||||||||||||||||||||||||||||||||||||||||||
| 2033 | 0 | ▶ | $self->{ ListFmt } = $_[1]; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 2034 | 0 | $self->{ ListUnreadFmt } = $_[1]; | |||||||||||||||||||||||||||||||||||||||||
| 2035 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 2036 | # mark | ||||||||||||||||||||||||||||||||||||||||||
| 2037 | 'all' => \$self->{ MarkAll }, | ||||||||||||||||||||||||||||||||||||||||||
| 2038 | # post | ||||||||||||||||||||||||||||||||||||||||||
| 2039 | 'post-format=s' => \$self->{ PostFmt }, | ||||||||||||||||||||||||||||||||||||||||||
| 2040 | # feeds | ||||||||||||||||||||||||||||||||||||||||||
| 2041 | 'brief' => \$self->{ Brief }, # groups, too | ||||||||||||||||||||||||||||||||||||||||||
| 2042 | 'feeds-format=s' => \$self->{ FeedsFmt }, | ||||||||||||||||||||||||||||||||||||||||||
| 2043 | # export/import | ||||||||||||||||||||||||||||||||||||||||||
| 2044 | 'no-groups' => \$self->{ NoGroups }, | ||||||||||||||||||||||||||||||||||||||||||
| 2045 | 'export-special' => \$self->{ ExportSpec }, | ||||||||||||||||||||||||||||||||||||||||||
| 2046 | # misc | ||||||||||||||||||||||||||||||||||||||||||
| 2047 | 0 | ▶ | 'help|h' => sub { _HELP(*STDOUT, 0) }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 2048 | 0 | ▶ | 'version|v' => sub { _VER(*STDOUT, 0) }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 2049 | '<>' => sub { | ||||||||||||||||||||||||||||||||||||||||||
| 2050 | 0 | ▶ | if (not defined $self->{ Cmd } and $_[0] !~ /^-/) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=5 SCAR=34.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
| |||||||||||||||||||||||||||||||||||||||||||
| 2051 | 0 | $self->{ Cmd } = $_[0]; | |||||||||||||||||||||||||||||||||||||||||
| 2052 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 2053 | 0 | ▶ | if ($_[0] =~ /^-\d+$/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 2054 | # So that negative post arguments (-1, -2, etc.) do not get | ||||||||||||||||||||||||||||||||||||||||||
| 2055 | # treated like CLI flags. | ||||||||||||||||||||||||||||||||||||||||||
| 2056 | 0 | push @{ $self->{ Args } }, $_[0]; | |||||||||||||||||||||||||||||||||||||||||
| 2057 | } elsif ($_[0] !~ /^-/) { | ||||||||||||||||||||||||||||||||||||||||||
| 2058 | 0 | push @{ $self->{ Args } }, $_[0]; | |||||||||||||||||||||||||||||||||||||||||
| 2059 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 2060 | 0 | warn "Unknown option: $_[0]\n"; | |||||||||||||||||||||||||||||||||||||||||
| 2061 | 0 | _HELP(*STDERR, 1); | |||||||||||||||||||||||||||||||||||||||||
| 2062 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2063 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2064 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 2065 | 0 | ▶ | ) or _HELP(*STDERR, 1); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2066 | |||||||||||||||||||||||||||||||||||||||||||
| 2067 | 0 | bless $self, $class; | |||||||||||||||||||||||||||||||||||||||||
| 2068 | |||||||||||||||||||||||||||||||||||||||||||
| 2069 | 0 | ▶ | if (not defined $self->{ Cmd }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2070 | 0 | _HELP(*STDERR, 0); | |||||||||||||||||||||||||||||||||||||||||
| 2071 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2072 | |||||||||||||||||||||||||||||||||||||||||||
| 2073 | 0 | ▶ | unless (exists $COMMANDS{ $self->{ Cmd } }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2074 | 0 | die "'$self->{ Cmd }' is not a valid command\n"; | |||||||||||||||||||||||||||||||||||||||||
| 2075 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2076 | |||||||||||||||||||||||||||||||||||||||||||
| 2077 | 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()
| |||||||||||||||||||||||||||||||||||||||||||
| 2078 | |||||||||||||||||||||||||||||||||||||||||||
| 2079 | 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"
| |||||||||||||||||||||||||||||||||||||||||||
| 2080 | 0 | $self->{ FeedsFmt } = '%f'; | |||||||||||||||||||||||||||||||||||||||||
| 2081 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2082 | |||||||||||||||||||||||||||||||||||||||||||
| 2083 | 0 | ▶ | if (defined $self->{ ConfFile }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2084 | 0 | $self->_read_config; | |||||||||||||||||||||||||||||||||||||||||
| 2085 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2086 | |||||||||||||||||||||||||||||||||||||||||||
| 2087 | 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()
| |||||||||||||||||||||||||||||||||||||||||||
| 2088 | |||||||||||||||||||||||||||||||||||||||||||
| 2089 | 0 | ▶ | unless (-d $self->{ DataDir }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2090 | mkdir $self->{ DataDir } | ||||||||||||||||||||||||||||||||||||||||||
| 2091 | 0 | ▶ | or die "Failed to mkdir $self->{ DataDir }: $!\n"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2092 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2093 | |||||||||||||||||||||||||||||||||||||||||||
| 2094 | $self->{ FeedDir } = File::Spec->catfile( | ||||||||||||||||||||||||||||||||||||||||||
| 2095 | $self->{ DataDir }, | ||||||||||||||||||||||||||||||||||||||||||
| 2096 | 0 | 'feeds' | |||||||||||||||||||||||||||||||||||||||||
| 2097 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 2098 | |||||||||||||||||||||||||||||||||||||||||||
| 2099 | 0 | ▶ | unless (-d $self->{ FeedDir }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2100 | mkdir $self->{ FeedDir } | ||||||||||||||||||||||||||||||||||||||||||
| 2101 | 0 | ▶ | or die "Failed to mkdir $self->{ FeedDir }: $!\n"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2102 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2103 | |||||||||||||||||||||||||||||||||||||||||||
| 2104 | $self->{ EtagDir } = File::Spec->catfile( | ||||||||||||||||||||||||||||||||||||||||||
| 2105 | 0 | $self->{ DataDir }, 'etag' | |||||||||||||||||||||||||||||||||||||||||
| 2106 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 2107 | 0 | ▶ | unless (-d $self->{ EtagDir }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2108 | mkdir $self->{ EtagDir } | ||||||||||||||||||||||||||||||||||||||||||
| 2109 | 0 | ▶ | or die "Failed to mkdir $self->{ EtagDir }: $!\n"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2110 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2111 | |||||||||||||||||||||||||||||||||||||||||||
| 2112 | $self->{ RetryDir } = File::Spec->catfile( | ||||||||||||||||||||||||||||||||||||||||||
| 2113 | 0 | $self->{ DataDir }, 'retry' | |||||||||||||||||||||||||||||||||||||||||
| 2114 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 2115 | 0 | ▶ | if (not -d $self->{ RetryDir }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2116 | 0 | ▶ | unlink $self->{ RetryDir } if -f $self->{ RetryDir }; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2117 | mkdir $self->{ RetryDir } | ||||||||||||||||||||||||||||||||||||||||||
| 2118 | 0 | ▶ | or die "Failed to mkdir $self->{ RetryDir }: $!\n"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2119 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2120 | |||||||||||||||||||||||||||||||||||||||||||
| 2121 | 0 | ▶ | unless (exists $DOESNT_NEED_FEED{ $self->{ Cmd } }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2122 | 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()
| |||||||||||||||||||||||||||||||||||||||||||
| 2123 | 0 | ▶ | unless (defined $self->{ FeedFile }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2124 | 0 | die "$PRGNAM could not find a feeds file to read a feed list from\n"; | |||||||||||||||||||||||||||||||||||||||||
| 2125 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2126 | 0 | ▶ | unless (-f $self->{ FeedFile }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2127 | 0 | die "$self->{ FeedFile } does not exist\n"; | |||||||||||||||||||||||||||||||||||||||||
| 2128 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2129 | # For _get_url 'file://' links, to know the file's relative directory if | ||||||||||||||||||||||||||||||||||||||||||
| 2130 | # the url is not absolute. | ||||||||||||||||||||||||||||||||||||||||||
| 2131 | 0 | $self->{ FeedFile } = File::Spec->rel2abs($self->{ FeedFile }); | |||||||||||||||||||||||||||||||||||||||||
| 2132 | 0 | $self->_read_feed_file; | |||||||||||||||||||||||||||||||||||||||||
| 2133 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2134 | |||||||||||||||||||||||||||||||||||||||||||
| 2135 | 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
| |||||||||||||||||||||||||||||||||||||||||||
| 2136 | |||||||||||||||||||||||||||||||||||||||||||
| 2137 | 0 | ▶ | unless ($self->{ Forks } > 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2138 | 0 | die "Download count must be greater than 0\n"; | |||||||||||||||||||||||||||||||||||||||||
| 2139 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2140 | |||||||||||||||||||||||||||||||||||||||||||
| 2141 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||
| 2142 | 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
| |||||||||||||||||||||||||||||||||||||||||||
| 2143 | 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
| |||||||||||||||||||||||||||||||||||||||||||
| 2144 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||
| 2145 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||
| 2146 | 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
| |||||||||||||||||||||||||||||||||||||||||||
| 2147 | 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
| |||||||||||||||||||||||||||||||||||||||||||
| 2148 | 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
| |||||||||||||||||||||||||||||||||||||||||||
| 2149 | 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
| |||||||||||||||||||||||||||||||||||||||||||
| 2150 | |||||||||||||||||||||||||||||||||||||||||||
| 2151 | 0 | ▶ | unless ($self->{ LineWidth } > 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2152 | 0 | die "width must be greater than 0\n"; | |||||||||||||||||||||||||||||||||||||||||
| 2153 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2154 | |||||||||||||||||||||||||||||||||||||||||||
| 2155 | 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
| |||||||||||||||||||||||||||||||||||||||||||
| 2156 | 0 | die "status must either be 'read' or 'unread'\n"; | |||||||||||||||||||||||||||||||||||||||||
| 2157 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2158 | |||||||||||||||||||||||||||||||||||||||||||
| 2159 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||
| 2160 | |||||||||||||||||||||||||||||||||||||||||||
| 2161 | 0 | ▶ | unless (exists $VALID_SORTS{ $self->{ Sort } }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2162 | 0 | die sprintf | |||||||||||||||||||||||||||||||||||||||||
| 2163 | "--sort must be one of the following: %s\n", | ||||||||||||||||||||||||||||||||||||||||||
| 2164 | join(', ', sort keys %VALID_SORTS); | ||||||||||||||||||||||||||||||||||||||||||
| 2165 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2166 | |||||||||||||||||||||||||||||||||||||||||||
| 2167 | 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
| |||||||||||||||||||||||||||||||||||||||||||
| 2168 | 0 | die "Invalid argument to --limit-rate\n"; | |||||||||||||||||||||||||||||||||||||||||
| 2169 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2170 | |||||||||||||||||||||||||||||||||||||||||||
| 2171 | 0 | ▶ | unless ($DOESNT_NEED_FEED{ $self->{ Cmd } }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2172 | $self->{ DB } = WWW::Noss::DB->new( | ||||||||||||||||||||||||||||||||||||||||||
| 2173 | 0 | File::Spec->catfile($self->{ DataDir }, 'database.sqlite3') | |||||||||||||||||||||||||||||||||||||||||
| 2174 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 2175 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2176 | |||||||||||||||||||||||||||||||||||||||||||
| 2177 | 0 | ▶ | if (defined $self->{ TimeFmt }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2178 | 0 | _set_z_fmt($self->{ TimeFmt }); | |||||||||||||||||||||||||||||||||||||||||
| 2179 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2180 | |||||||||||||||||||||||||||||||||||||||||||
| 2181 | 0 | ▶ | if (not defined $self->{ UseColor }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2182 | 0 | ▶ | if (-t STDOUT) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2183 | 0 | $self->{ UseColor } = 1; | |||||||||||||||||||||||||||||||||||||||||
| 2184 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 2185 | 0 | $self->{ UseColor } = 0; | |||||||||||||||||||||||||||||||||||||||||
| 2186 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2187 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2188 | |||||||||||||||||||||||||||||||||||||||||||
| 2189 | # Windows terminals do not support ANSI color codes. | ||||||||||||||||||||||||||||||||||||||||||
| 2190 | 0 | ▶ | if ($^O eq 'MSWin32') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2191 | 0 | $self->{ UseColor } = 0; | |||||||||||||||||||||||||||||||||||||||||
| 2192 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2193 | |||||||||||||||||||||||||||||||||||||||||||
| 2194 | 0 | ▶ | if (not defined $self->{ Timeout }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2195 | 0 | $self->{ Timeout } = 45; | |||||||||||||||||||||||||||||||||||||||||
| 2196 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2197 | |||||||||||||||||||||||||||||||||||||||||||
| 2198 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 2199 | |||||||||||||||||||||||||||||||||||||||||||
| 2200 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2201 | |||||||||||||||||||||||||||||||||||||||||||
| 2202 | sub run { | ||||||||||||||||||||||||||||||||||||||||||
| 2203 | |||||||||||||||||||||||||||||||||||||||||||
| 2204 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 2205 | |||||||||||||||||||||||||||||||||||||||||||
| 2206 | 0 | $COMMANDS{ $self->{ Cmd } }->($self); | |||||||||||||||||||||||||||||||||||||||||
| 2207 | |||||||||||||||||||||||||||||||||||||||||||
| 2208 | 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"}}
| |||||||||||||||||||||||||||||||||||||||||||
| 2209 | 0 | $self->clean; | |||||||||||||||||||||||||||||||||||||||||
| 2210 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2211 | |||||||||||||||||||||||||||||||||||||||||||
| 2212 | # Delete outdated retry caches | ||||||||||||||||||||||||||||||||||||||||||
| 2213 | 0 | my $now = time; | |||||||||||||||||||||||||||||||||||||||||
| 2214 | 0 | for my $f (values %{ $self->{ Feeds } }) { | |||||||||||||||||||||||||||||||||||||||||
| 2215 | 0 | my $retry = $f->retry; | |||||||||||||||||||||||||||||||||||||||||
| 2216 | 0 | ▶ | next if not defined $retry; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2217 | 0 | ▶ | if ($now >= $retry) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2218 | 0 | ▶ | unlink $f->retry_cache | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2219 | or warn sprintf "Failed to unlink %s: %s\n", $f->retry_cache, $!; | ||||||||||||||||||||||||||||||||||||||||||
| 2220 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2221 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2222 | |||||||||||||||||||||||||||||||||||||||||||
| 2223 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 2224 | |||||||||||||||||||||||||||||||||||||||||||
| 2225 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2226 | |||||||||||||||||||||||||||||||||||||||||||
| 2227 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 2228 | |||||||||||||||||||||||||||||||||||||||||||
| 2229 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||
| 2230 | |||||||||||||||||||||||||||||||||||||||||||
| 2231 | WWW::Noss - RSS/Atom feed reader and aggregator | ||||||||||||||||||||||||||||||||||||||||||
| 2232 | |||||||||||||||||||||||||||||||||||||||||||
| 2233 | =head1 USAGE | ||||||||||||||||||||||||||||||||||||||||||
| 2234 | |||||||||||||||||||||||||||||||||||||||||||
| 2235 | use WWW::Noss; | ||||||||||||||||||||||||||||||||||||||||||
| 2236 | |||||||||||||||||||||||||||||||||||||||||||
| 2237 | my $noss = WWW::Noss->init(@ARGV); | ||||||||||||||||||||||||||||||||||||||||||
| 2238 | $noss->run; | ||||||||||||||||||||||||||||||||||||||||||
| 2239 | |||||||||||||||||||||||||||||||||||||||||||
| 2240 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||
| 2241 | |||||||||||||||||||||||||||||||||||||||||||
| 2242 | B<WWW::Noss> is the backend module providing L<noss>'s functionality. This is | ||||||||||||||||||||||||||||||||||||||||||
| 2243 | a private module, please consult the L<noss> manual for user documentation. | ||||||||||||||||||||||||||||||||||||||||||
| 2244 | |||||||||||||||||||||||||||||||||||||||||||
| 2245 | =head1 METHODS | ||||||||||||||||||||||||||||||||||||||||||
| 2246 | |||||||||||||||||||||||||||||||||||||||||||
| 2247 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||
| 2248 | |||||||||||||||||||||||||||||||||||||||||||
| 2249 | =item $noss = WWW::Noss->init(@argv) | ||||||||||||||||||||||||||||||||||||||||||
| 2250 | |||||||||||||||||||||||||||||||||||||||||||
| 2251 | Reads command-line arguments from C<@argv> and returns a blessed B<WWW::Noss> | ||||||||||||||||||||||||||||||||||||||||||
| 2252 | object. You would usually pass C<@ARGV> to it. | ||||||||||||||||||||||||||||||||||||||||||
| 2253 | |||||||||||||||||||||||||||||||||||||||||||
| 2254 | Consult the L<noss> manual for documentation on what options/arguments are | ||||||||||||||||||||||||||||||||||||||||||
| 2255 | available. | ||||||||||||||||||||||||||||||||||||||||||
| 2256 | |||||||||||||||||||||||||||||||||||||||||||
| 2257 | =item $noss->run() | ||||||||||||||||||||||||||||||||||||||||||
| 2258 | |||||||||||||||||||||||||||||||||||||||||||
| 2259 | Runs L<noss> based on the parameters processed during C<init()>. | ||||||||||||||||||||||||||||||||||||||||||
| 2260 | |||||||||||||||||||||||||||||||||||||||||||
| 2261 | =item $noss->update() | ||||||||||||||||||||||||||||||||||||||||||
| 2262 | |||||||||||||||||||||||||||||||||||||||||||
| 2263 | Method implementing the C<update> command. | ||||||||||||||||||||||||||||||||||||||||||
| 2264 | |||||||||||||||||||||||||||||||||||||||||||
| 2265 | =item $noss->reload() | ||||||||||||||||||||||||||||||||||||||||||
| 2266 | |||||||||||||||||||||||||||||||||||||||||||
| 2267 | Method implementing the C<reload> command. | ||||||||||||||||||||||||||||||||||||||||||
| 2268 | |||||||||||||||||||||||||||||||||||||||||||
| 2269 | =item $noss->read_post() | ||||||||||||||||||||||||||||||||||||||||||
| 2270 | |||||||||||||||||||||||||||||||||||||||||||
| 2271 | Method implementing the C<read> command. | ||||||||||||||||||||||||||||||||||||||||||
| 2272 | |||||||||||||||||||||||||||||||||||||||||||
| 2273 | =item $noss->open_post() | ||||||||||||||||||||||||||||||||||||||||||
| 2274 | |||||||||||||||||||||||||||||||||||||||||||
| 2275 | Method implementing the C<open> command. | ||||||||||||||||||||||||||||||||||||||||||
| 2276 | |||||||||||||||||||||||||||||||||||||||||||
| 2277 | =item $noss->cat() | ||||||||||||||||||||||||||||||||||||||||||
| 2278 | |||||||||||||||||||||||||||||||||||||||||||
| 2279 | Method implementing the C<cat> command. | ||||||||||||||||||||||||||||||||||||||||||
| 2280 | |||||||||||||||||||||||||||||||||||||||||||
| 2281 | =item $noss->look() | ||||||||||||||||||||||||||||||||||||||||||
| 2282 | |||||||||||||||||||||||||||||||||||||||||||
| 2283 | Method implementing the C<list> command. | ||||||||||||||||||||||||||||||||||||||||||
| 2284 | |||||||||||||||||||||||||||||||||||||||||||
| 2285 | =item $noss->unread() | ||||||||||||||||||||||||||||||||||||||||||
| 2286 | |||||||||||||||||||||||||||||||||||||||||||
| 2287 | Method implementing the C<unread> command. | ||||||||||||||||||||||||||||||||||||||||||
| 2288 | |||||||||||||||||||||||||||||||||||||||||||
| 2289 | =item $noss->mark() | ||||||||||||||||||||||||||||||||||||||||||
| 2290 | |||||||||||||||||||||||||||||||||||||||||||
| 2291 | Method implementing the C<mark> command. | ||||||||||||||||||||||||||||||||||||||||||
| 2292 | |||||||||||||||||||||||||||||||||||||||||||
| 2293 | =item $noss->post() | ||||||||||||||||||||||||||||||||||||||||||
| 2294 | |||||||||||||||||||||||||||||||||||||||||||
| 2295 | Method implementing the C<post> command. | ||||||||||||||||||||||||||||||||||||||||||
| 2296 | |||||||||||||||||||||||||||||||||||||||||||
| 2297 | =item $noss->feeds() | ||||||||||||||||||||||||||||||||||||||||||
| 2298 | |||||||||||||||||||||||||||||||||||||||||||
| 2299 | Method implementing the C<feeds> command. | ||||||||||||||||||||||||||||||||||||||||||
| 2300 | |||||||||||||||||||||||||||||||||||||||||||
| 2301 | =item $noss->groups() | ||||||||||||||||||||||||||||||||||||||||||
| 2302 | |||||||||||||||||||||||||||||||||||||||||||
| 2303 | Method implementing the C<groups> command. | ||||||||||||||||||||||||||||||||||||||||||
| 2304 | |||||||||||||||||||||||||||||||||||||||||||
| 2305 | =item $noss->clean() | ||||||||||||||||||||||||||||||||||||||||||
| 2306 | |||||||||||||||||||||||||||||||||||||||||||
| 2307 | Method implementing the C<clean> command. | ||||||||||||||||||||||||||||||||||||||||||
| 2308 | |||||||||||||||||||||||||||||||||||||||||||
| 2309 | =item $noss->discover() | ||||||||||||||||||||||||||||||||||||||||||
| 2310 | |||||||||||||||||||||||||||||||||||||||||||
| 2311 | Method implementing the C<discover> command. | ||||||||||||||||||||||||||||||||||||||||||
| 2312 | |||||||||||||||||||||||||||||||||||||||||||
| 2313 | =item $noss->export_opml() | ||||||||||||||||||||||||||||||||||||||||||
| 2314 | |||||||||||||||||||||||||||||||||||||||||||
| 2315 | Method implementing the C<export> command. | ||||||||||||||||||||||||||||||||||||||||||
| 2316 | |||||||||||||||||||||||||||||||||||||||||||
| 2317 | =item $noss->import_opml() | ||||||||||||||||||||||||||||||||||||||||||
| 2318 | |||||||||||||||||||||||||||||||||||||||||||
| 2319 | Method implementing the C<import> command. | ||||||||||||||||||||||||||||||||||||||||||
| 2320 | |||||||||||||||||||||||||||||||||||||||||||
| 2321 | =item $noss->help() | ||||||||||||||||||||||||||||||||||||||||||
| 2322 | |||||||||||||||||||||||||||||||||||||||||||
| 2323 | Method implementing the C<help> command. | ||||||||||||||||||||||||||||||||||||||||||
| 2324 | |||||||||||||||||||||||||||||||||||||||||||
| 2325 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 2326 | |||||||||||||||||||||||||||||||||||||||||||
| 2327 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||
| 2328 | |||||||||||||||||||||||||||||||||||||||||||
| 2329 | Written by Samuel Young, E<lt>samyoung12788@gmail.comE<gt>. | ||||||||||||||||||||||||||||||||||||||||||
| 2330 | |||||||||||||||||||||||||||||||||||||||||||
| 2331 | This project's source can be found on its | ||||||||||||||||||||||||||||||||||||||||||
| 2332 | L<Codeberg page|https://codeberg.org/1-1sam/noss.git>. Comments and pull | ||||||||||||||||||||||||||||||||||||||||||
| 2333 | requests are welcome! | ||||||||||||||||||||||||||||||||||||||||||
| 2334 | |||||||||||||||||||||||||||||||||||||||||||
| 2335 | =head1 COPYRIGHT | ||||||||||||||||||||||||||||||||||||||||||
| 2336 | |||||||||||||||||||||||||||||||||||||||||||
| 2337 | Copyright (C) 2025-2026 Samuel Young | ||||||||||||||||||||||||||||||||||||||||||
| 2338 | |||||||||||||||||||||||||||||||||||||||||||
| 2339 | This program is free software: you can redistribute it and/or modify | ||||||||||||||||||||||||||||||||||||||||||
| 2340 | it under the terms of the GNU General Public License as published by | ||||||||||||||||||||||||||||||||||||||||||
| 2341 | the Free Software Foundation, either version 3 of the License, or | ||||||||||||||||||||||||||||||||||||||||||
| 2342 | (at your option) any later version. | ||||||||||||||||||||||||||||||||||||||||||
| 2343 | |||||||||||||||||||||||||||||||||||||||||||
| 2344 | =head1 SEE ALSO | ||||||||||||||||||||||||||||||||||||||||||
| 2345 | |||||||||||||||||||||||||||||||||||||||||||
| 2346 | L<noss> | ||||||||||||||||||||||||||||||||||||||||||
| 2347 | |||||||||||||||||||||||||||||||||||||||||||
| 2348 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 2349 | |||||||||||||||||||||||||||||||||||||||||||
| 2350 | # vim: expandtab shiftwidth=4 | ||||||||||||||||||||||||||||||||||||||||||