Lines Matching +full:sub +full:- +full:module
22 sub new {
35 ua => $params{ua} || HTTP::Tiny->new(
45 sub _build_extra_params {
52 my $ua = $self->{ua};
57 $extra{$key} = $ua->_uri_escape($extra{$key});
68 sub source {
86 $url = $self->{base_url} . "/$url";
88 my $result = $self->{ua}->get($url);
89 $result->{'success'}
90 or croak "Failed to fetch '$url': " . $result->{'reason'};
92 return $result->{'content'};
98 sub release {
126 return $self->fetch( $url, %extra_opts );
130 # /pod/{module}
132 sub pod {
136 my $error = "Either provide 'module' or 'author and 'release' and 'path'";
140 if ( defined ( my $module = $opts{'module'} ) ) {
141 $url = "pod/$module";
152 # check content-type
154 if ( defined ( my $type = $opts{'content-type'} ) ) {
155 $type =~ m{^ text/ (?: html|plain|x-pod|x-markdown ) $}x
156 or croak 'Incorrect content-type provided';
158 $extra{headers}{'content-type'} = $type;
161 $url = $self->{base_url}. "/$url";
163 my $result = $self->{ua}->get( $url, \%extra );
164 $result->{'success'}
165 or croak "Failed to fetch '$url': " . $result->{'reason'};
167 return $result->{'content'};
171 # /module/{module}
172 sub module {
176 $name or croak 'Please provide a module name';
178 return $self->fetch("module/$name");
182 # file() is a synonym of module
183 sub file { goto &module }
187 sub author {
213 return $self->fetch( $url, %extra_opts );
218 sub fetch {
221 my $extra = $self->_build_extra_params(@_);
222 my $base = $self->{base_url};
225 my $result = $self->{ua}->get($req_url);
226 return $self->_decode_result( $result, $req_url );
230 sub post {
234 my $base = $self->{base_url};
243 my $result = $self->{ua}->request(
247 headers => { 'Content-Type' => 'application/json' },
252 return $self->_decode_result( $result, $url, $query_json );
255 sub _decode_result {
266 if ( defined ( my $success = $result->{'success'} ) ) {
267 my $reason = $result->{'reason'} || '';
275 defined ( my $content = $result->{'content'} )
292 MetaCPAN::API::Tiny - A Tiny API client for MetaCPAN
326 new is the constructor for MetaCPAN::API::Tiny. In the non-tiny version of this
327 module, this is provided via Any::Moose built from the attributes defined. In
335 my $source = $mcpan->source(
337 release => 'Moose-2.0201',
341 Searches MetaCPAN for a module or a specific release and returns the plain source.
345 my $result = $mcpan->release( distribution => 'Moose' );
348 my $result = $mcpan->release( author => 'DOY', release => 'Moose-2.0001' );
355 my $result = $mcpan->release(
366 my $result = $mcpan->pod( module => 'Moose' );
369 my $result = $mcpan->pod(
371 release => 'Moose-2.0201',
375 Searches MetaCPAN for a module or a specific release and returns the POD.
377 =head2 module
379 my $result = $mcpan->module('MetaCPAN::API');
381 Searches MetaCPAN and returns a module's ".pm" file.
385 A synonym of L</module>
389 my $result1 = $mcpan->author('XSAWYERX');
390 my $result2 = $mcpan->author( pauseid => 'XSAWYERX' );
397 my $result = $mcpan->author(
406 my $result = $mcpan->fetch('/release/distribution/Moose');
409 my $more = $mcpan->fetch(
422 … # /release&content={"query":{"match_all":{}},"filter":{"prefix":{"archive":"Cache-Cache-1.06"}}}
423 my $result = $mcpan->post(
427 filter => { prefix => { archive => 'Cache-Cache-1.06' } },
436 tiny-fied. A big thanks to Sawyer X for writing the original module.
454 unshift @INC, sub {
457 return sub {
483 use Module::CoreList;
501 perlbrew install perl-5.32.0
514 ) or pod2usage(-exitval => 1);
515 pod2usage(-exitval => 0) if $help;
516 pod2usage(-exitval => 0, -verbose => 2) if $man;
517 pod2usage(-exitval => 1) if scalar @ARGV == 0;
519 my %dist; # name -> metacpan data
520 my %need_target; # name -> 1 if target package is needed
521 my %need_host; # name -> 1 if host package is needed
522 my %need_dlopen; # name -> 1 if requires dynamic library
523 my %is_xs; # name -> 1 if XS module
524 my %deps_build; # name -> list of host dependencies
525 my %deps_runtime; # name -> list of target dependencies
526 my %license_files; # name -> hash of license files
527 my %checksum; # author -> list of checksum
529 my $mcpan = MetaCPAN::API::Tiny->new(base_url => 'http://fastapi.metacpan.org/v1');
530 my $ua = HTTP::Tiny->new();
534 'ExtUtils-Config' => 1,
535 'ExtUtils-InstallPaths' => 1,
536 'ExtUtils-Helpers' => 1,
537 'File-ShareDir-Install' => 1,
538 'Module-Build' => 1,
539 'Module-Build-Tiny' => 1,
543 sub get_checksum {
549 my $response = $ua->get($url);
550 $checksum{$dirname} = $response->{content};
552 my $chksum = Safe->new->reval($checksum{$dirname});
553 return $chksum->{$basename}, $basename;
556 sub is_xs {
558 # This heuristic determines if a module is a native extension, by searching
564 sub find_license_files {
584 sub want_test {
589 sub get_dependencies {
600 sub get_indirect_dependencies {
610 sub fetch {
616 my $result = $mcpan->release( distribution => $name );
617 my $main_module = $result->{main_module};
618 push @info, qq{[$name] $main_module is a core module}
619 if $top && Module::CoreList::is_core( $main_module, undef, $] );
623 my $author = $result->{author};
624 my $release = $name . q{-} . $result->{version};
625 … my $manifest = $mcpan->source( author => $author, release => $release, path => 'MANIFEST' );
628 … my $license = $mcpan->source( author => $author, release => $release, path => $fname );
629 $license_files{$name}->{$fname} = sha256_hex( $license );
638 foreach my $dep (@{$result->{dependency}}) {
639 my $modname = ${$dep}{module};
644 next if Module::CoreList::is_core( $modname, undef, $] );
645 # we could use the host Module::CoreList data, because host perl and
650 my $distname = $mcpan->module( $modname )->{distribution};
682 # Command-line's distributions
688 sub fsname {
690 $name =~ s|_|-|g;
691 return q{perl-} . lc $name;
695 sub brname {
697 $name =~ s|-|_|g;
702 sub brlicense {
704 $license =~ s|apache_1_1|Apache-1.1|;
705 $license =~ s|apache_2_0|Apache-2.0|;
706 $license =~ s|artistic_2|Artistic-2.0|;
707 $license =~ s|artistic|Artistic-1.0|;
708 $license =~ s|lgpl_2_1|LGPL-2.1|;
709 $license =~ s|lgpl_3_0|LGPL-3.0|;
710 $license =~ s|gpl_2|GPL-2.0|;
711 $license =~ s|gpl_3|GPL-3.0|;
713 $license =~ s|mozilla_1_1|Mozilla-1.1|;
715 $license =~ s|perl_5|Artistic or GPL-1.0+|;
728 unless (-d $dirname) {
732 if ($need_target{$distname} && ($force || !-f $cfgname)) {
733 $dist->{abstract} =~ s|\s+$||;
734 $dist->{abstract} .= q{.} unless $dist->{abstract} =~ m|\.$|;
735 my $abstract = wrap( q{}, qq{\t }, $dist->{abstract} );
736 … my $homepage = $dist->{resources}->{homepage} || qq{https://metacpan.org/release/${distname}};
755 if ($force || !-f $mkname) {
756 my $version = $dist->{version};
757 my ($path) = $dist->{download_url} =~ m|^[^:/?#]+://[^/?#]*([^?#]*)|;
763 my @dependencies = map( { q{host-} . fsname( $_ ); } sort @{$deps_build{$distname}} );
766 my @host_dependencies = map { q{host-} . fsname( $_ ); } sort( @{$deps_build{$distname}},
770 my $license = brlicense( ref $dist->{license} eq 'ARRAY'
771 ? join q{ or }, @{$dist->{license}}
772 : $dist->{license} );
787 say {$fh} qq{${brname}_SOURCE = ${distname}-\$(${brname}_VERSION).${suffix}};
795 say {$fh} qq{\$(eval \$(perl-package))} if $need_target{$distname};
796 say {$fh} qq{\$(eval \$(host-perl-package))} if $need_host{$distname};
799 if ($force || !-f $hashname) {
800 my ($checksum, $filename) = get_checksum($dist->{download_url});
801 my $md5 = $checksum->{md5};
802 my $sha256 = $checksum->{sha256};
819 if (want_test( $distname ) && ($force || !-f $testname)) {
821 $classname =~ s|-||g;
823 $modname =~ s|-|::|g;
827 make_path $testdir unless -d $testdir;
859 $dep =~ s|-|::|g;
863 $dep =~ s|-|::|g;
874 if (-f $cfgname) {
878 $pkg{$_} = 1 if m|package/perl-|;
898 utils/scancpan Try-Tiny Moo
905 -help
906 -man
907 -quiet
908 -force
909 -target/-notarget
910 -host/-nohost
911 -recommend
912 -test
918 =item B<-help>
922 =item B<-man>
926 =item B<-quiet>
930 =item B<-force>
934 =item B<-target/-notarget>
936 Switches package generation for the target variant (the default is C<-target>).
938 =item B<-host/-nohost>
940 Switches package generation for the host variant (the default is C<-nohost>).
942 =item B<-recommend>
946 =item B<-test>
970 Copyright (C) 2013-2020 by Francois Perrad <francois.perrad@gadz.org>
984 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
988 This script requires the module C<MetaCPAN::API::Tiny> (version 1.131730)
991 See L<https://metacpan.org/release/NPEREZ/MetaCPAN-API-Tiny-1.131730>.
993 See L<https://metacpan.org/release/App-FatPacker>.