Uptake/Command/list.pm untested

filter: Statementstmt 0.0% 0 / 49 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 10 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 65 CC 3 SCAR 15.0
CC
3
Cov
0%
execute
12.0
opt_spec
2.0
BEGIN
2.0
CRAP 4.5
1 # ABSTRACT: List kernels on kernel.ubuntu.com/~kernel-ppa/mainline/.
2 package Uptake::Command::list;
3 use Uptake -command;
4  
5 use autodie;
6 use strict;
7 use warnings;
8 use feature qw(say);
9  
10 use Carp;
11 use List::Util qw(none);
12 use Mojo::UserAgent;
13  
14 my $exclude = [
15 'Parent Directory',
16 'daily',
17 'testing',
18 'fixes',
19 'next',
20 'nightly',
21 'queue',
22 'review'];
23 my $ua = Mojo::UserAgent->new;
24 my $url = 'http://kernel.ubuntu.com/~kernel-ppa/mainline/';
25  
26 sub execute {
27 my ($self, $opt, $args) = @_;
28  
29 my $regex = delete $opt->{regex};
30  
31 if (my $no = delete $opt->{no}) {
32 push @$exclude, $_ for @$no;
33 }
34  
35 my @versions;
36 $ua->get(
37 $url => {DNT => 1})->res->dom('tr > td > a')->each(sub {
38 push @versions, $_->text;
39 });
40  
41 @versions =
42 map { s/\///r }
43 grep {
44 my $val = $_;
45 none { $val =~ /$_/ } @$exclude } @versions;
46  
47 @versions = grep { /$regex/ } @versions if $regex;
48  
49 say for @versions;
50 }
51  
52 sub opt_spec {
53 return (
54 [ 'no=s@', 'exclude the specified word.' ],
55 [ 'regex=s', 'kernel name will match the regex.' ],
56 );
57 }
58  
59 1;