| 1 | package Build::PPK::Deptool::CPAN; | ||
| 2 | |||
| 3 | # Copyright (c) 2018, cPanel, L.L.C. | ||
| 4 | # All rights reserved. | ||
| 5 | # http://cpanel.net/ | ||
| 6 | # | ||
| 7 | # This is free software; you can redistribute it and/or modify it under the same | ||
| 8 | # terms as Perl itself. See the LICENSE file for further details. | ||
| 9 | |||
| 10 | use strict; | ||
| 11 | use warnings; | ||
| 12 | |||
| 13 | use Build::PPK::Deptool::HTTP; | ||
| 14 | |||
| 15 | use Carp ('confess'); | ||
| 16 | |||
| 17 | sub fetch_dist { | ||
| 18 | my ( $class, %args ) = @_; | ||
| 19 | |||
| 20 | confess('Unknown URL format') unless $args{'url'} =~ /^cpan:\/\/([a-z0-9_\-]+)\/([^\/]+)$/i; | ||
| 21 | |||
| 22 | my ( $author, $cpan_dist ) = ( $1, $2 ); | ||
| 23 | |||
| 24 | my $cpan_url = 'http://search.cpan.org/CPAN/authors/id/' | ||
| 25 | . join( | ||
| 26 | '/', | ||
| 27 | substr( $author, 0, 1 ), | ||
| 28 | substr( $author, 0, 2 ), | ||
| 29 | $author, | ||
| 30 | $cpan_dist | ||
| 31 | ); | ||
| 32 | |||
| 33 | return Build::PPK::Deptool::HTTP->fetch_dist( | ||
| 34 | 'url' => $cpan_url, | ||
| 35 | 'dist' => $args{'dist'}, | ||
| 36 | 'path' => $args{'path'} | ||
| 37 | ); | ||
| 38 | } | ||
| 39 | |||
| 40 | 1; |