| 1 | # | ||
| 2 | # This file is part of App-Magpie | ||
| 3 | # | ||
| 4 | # This software is copyright (c) 2011 by Jerome Quelin. | ||
| 5 | # | ||
| 6 | # This is free software; you can redistribute it and/or modify it under | ||
| 7 | # the same terms as the Perl 5 programming language system itself. | ||
| 8 | # | ||
| 9 | 1 | ▶ | use 5.016; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 10 | 1 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 11 | 1 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 12 | |||
| 13 | package App::Magpie::Action::Recent; | ||
| 14 | # ABSTRACT: recent command implementation | ||
| 15 | $App::Magpie::Action::Recent::VERSION = '2.010'; | ||
| 16 | 1 | ▶ | use CPAN::Recent::Uploads; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 17 | 1 | ▶ | use List::AllUtils qw{ apply uniq }; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 18 | 1 | ▶ | use MetaCPAN::Client; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 19 | 1 | ▶ | use Moose; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 20 | |||
| 21 | 0 | ▶ | use App::Magpie::URPM; |
|
Subroutine
BEGIN: called CC=1 SCAR=2.6
| |||
| 22 | |||
| 23 | with 'App::Magpie::Role::Logging'; | ||
| 24 | |||
| 25 | |||
| 26 | |||
| 27 | sub run { | ||
| 28 | my ($self) = @_; | ||
| 29 | |||
| 30 | # get raw list of uploads | ||
| 31 | $self->log( "fetching list of recent uploads" ); | ||
| 32 | my $dayago = time() - ( 24 * 60 * 60 ); | ||
| 33 | my @uploads = uniq | ||
| 34 | apply { s{^.*/}{}; s{-[^-]*$}{}; s{-}{::}g; } | ||
| 35 | CPAN::Recent::Uploads->recent( $dayago ); | ||
| 36 | |||
| 37 | # check if available within mageia | ||
| 38 | $self->log( "filter out modules available in mageia" ); | ||
| 39 | my $urpm = App::Magpie::URPM->instance; | ||
| 40 | my @nomageia = | ||
| 41 | grep { scalar($urpm->packages_providing($_)) == 0 } | ||
| 42 | @uploads; | ||
| 43 | |||
| 44 | # raw list transformed distname such as: | ||
| 45 | # L/LI/LIOSHA/Geo-Openstreetmap-Parser-0.02.tar.gz | ||
| 46 | # to: | ||
| 47 | # Geo::Openstreetmap::Parser | ||
| 48 | # however, there may be some troubles due to weird numbering, or | ||
| 49 | # tarball /dist name not matching the module(s) inside the dist. so | ||
| 50 | # we need to check whether our wild transformation really points to | ||
| 51 | # an existing perl module on cpan. | ||
| 52 | $self->log( "validating modules" ); | ||
| 53 | my $mcpan = MetaCPAN::Client->new; | ||
| 54 | my $nbvalid; | ||
| 55 | foreach my $module ( sort @nomageia ) { | ||
| 56 | my $result; | ||
| 57 | eval { $result = $mcpan->module( $module ); }; | ||
| 58 | next if $@; | ||
| 59 | say $module; | ||
| 60 | $nbvalid++; | ||
| 61 | } | ||
| 62 | |||
| 63 | # $self->log( "uploads: " . scalar(@uploads) ); | ||
| 64 | # $self->log( "nomageia: " . scalar(@nomageia) ); | ||
| 65 | # $self->log( "valid: $nbvalid" ); | ||
| 66 | my $uploads = @uploads; | ||
| 67 | my $percent = 100 - int( $nbvalid * 100 / $uploads ); | ||
| 68 | $self->log( "new=$uploads, not in mageia=$nbvalid, mageia coverage=$percent%" ); | ||
| 69 | } | ||
| 70 | |||
| 71 | |||
| 72 | |||
| 73 | 1; | ||
| 74 | |||
| 75 | __END__ | ||