CPAN-Info-FromURL

 view release on metacpan or  search on metacpan

META.json  view on Meta::CPAN

{
   "abstract" : "Extract/guess information from a URL",
   "author" : [
      "perlancar <perlancar@cpan.org>"
   ],
   "dynamic_config" : 0,
   "generated_by" : "Dist::Zilla version 6.012, CPAN::Meta::Converter version 2.150010",
   "license" : [
      "perl_5"
   ],
   "meta-spec" : {
      "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",

META.yml  view on Meta::CPAN

---
abstract: 'Extract/guess information from a URL'
author:
  - 'perlancar <perlancar@cpan.org>'
build_requires:
  File::Spec: '0'
  IO::Handle: '0'
  IPC::Open3: '0'
  Test::More: '0'
configure_requires:
  ExtUtils::MakeMaker: '0'
dynamic_config: 0

Makefile.PL  view on Meta::CPAN

# This file was automatically generated by Dist::Zilla::Plugin::MakeMaker v6.012.
use strict;
use warnings;

use 5.010001;

use ExtUtils::MakeMaker;

my %WriteMakefileArgs = (
  "ABSTRACT" => "Extract/guess information from a URL",
  "AUTHOR" => "perlancar <perlancar\@cpan.org>",
  "CONFIGURE_REQUIRES" => {
    "ExtUtils::MakeMaker" => 0
  },
  "DISTNAME" => "CPAN-Info-FromURL",
  "LICENSE" => "perl",
  "MIN_PERL_VERSION" => "5.010001",
  "NAME" => "CPAN::Info::FromURL",
  "PREREQ_PM" => {
    "CPAN::Dist::FromRepoName" => 0,

README  view on Meta::CPAN

NAME
    CPAN::Info::FromURL - Extract/guess information from a URL

VERSION
    This document describes version 0.092 of CPAN::Info::FromURL (from Perl
    distribution CPAN-Info-FromURL), released on 2020-10-02.

FUNCTIONS
  extract_cpan_info_from_url
    Usage:

     extract_cpan_info_from_url($url) -> hash

    Extract/guess information from a URL.

    Examples:

    *   Example #1 (mcpan/pod/MOD):

         extract_cpan_info_from_url("https://metacpan.org/pod/Foo::Bar"); # -> { module => "Foo::Bar", site => "mcpan" }

    *   Example #2 (mcpan/module/MOD):

         extract_cpan_info_from_url("metacpan.org/module/Foo?"); # -> { module => "Foo", site => "mcpan" }

lib/CPAN/Info/FromURL.pm  view on Meta::CPAN

our $re_end_or_q = qr/(?:[?&#]|\z)/;

sub _normalize_mod {
    my $mod = shift;
    $mod =~ s/'/::/g;
    $mod;
}

$SPEC{extract_cpan_info_from_url} = {
    v => 1.1,
    summary => 'Extract/guess information from a URL',
    description => <<'_',

Return a hash of information from a CPAN-related URL. Possible keys include:
`site` (site nickname, include: `mcpan` [metacpan.org, api.metacpan.org,
fastapi.metacpan.org], `sco` [search.cpan.org], `cpanratings`
[cpanratings.perl.org], `rt` ([rt.cpan.org]), `cpan` [any normal CPAN mirror]),
`author` (CPAN author ID), `module` (module name), `dist` (distribution name),
`version` (distribution version). Some keys might not exist, depending on what
information the URL provides. Return undef if URL is not detected to be of some
CPAN-related URL.

lib/CPAN/Info/FromURL.pm  view on Meta::CPAN

        if (defined $4) {
            $res->{release} = $4;
            $res->{dist} = $5;
            $res->{version} = $6;
        }
    }
    $res;
}

1;
# ABSTRACT: Extract/guess information from a URL

__END__

=pod

=encoding UTF-8

=head1 NAME

CPAN::Info::FromURL - Extract/guess information from a URL

=head1 VERSION

This document describes version 0.092 of CPAN::Info::FromURL (from Perl distribution CPAN-Info-FromURL), released on 2020-10-02.

=head1 FUNCTIONS


=head2 extract_cpan_info_from_url

Usage:

 extract_cpan_info_from_url($url) -> hash

ExtractE<sol>guess information from a URL.

Examples:

=over

=item * Example #1 (mcpanE<sol>podE<sol>MOD):

 extract_cpan_info_from_url("https://metacpan.org/pod/Foo::Bar"); # -> { module => "Foo::Bar", site => "mcpan" }

=item * Example #2 (mcpanE<sol>moduleE<sol>MOD):

lib/CPAN/Module/FromURL.pm  view on Meta::CPAN


use CPAN::Info::FromURL qw(extract_cpan_info_from_url);

use Exporter qw(import);
our @EXPORT_OK = qw(extract_cpan_module_from_url);

our %SPEC;

$SPEC{extract_cpan_module_from_url} = {
    v => 1.1,
    summary => 'Extract/guess CPAN module from a URL',
    args => {
        url => {
            schema => 'str*',
            req => 1,
            pos => 0,
        },
    },
    args_as => 'array',
    result => {
        schema => 'str',

lib/CPAN/Module/FromURL.pm  view on Meta::CPAN

    return undef unless $ecires;
    return $ecires->{module} if defined $ecires->{module};
    if (defined(my $mod = $ecires->{dist})) {
        $mod =~ s/-/::/g;
        return $mod;
    }
    undef;
}

1;
# ABSTRACT: Extract/guess CPAN module from a URL

__END__

=pod

=encoding UTF-8

=head1 NAME

CPAN::Module::FromURL - Extract/guess CPAN module from a URL

=head1 VERSION

This document describes version 0.092 of CPAN::Module::FromURL (from Perl distribution CPAN-Info-FromURL), released on 2020-10-02.

=head1 FUNCTIONS


=head2 extract_cpan_module_from_url

Usage:

 extract_cpan_module_from_url($url) -> str

ExtractE<sol>guess CPAN module from a URL.

Examples:

=over

=item * Example #1 (mcpanE<sol>podE<sol>MOD):

 extract_cpan_module_from_url("https://metacpan.org/pod/Foo::Bar"); # -> "Foo::Bar"

=item * Example #2 (mcpanE<sol>releaseE<sol>DIST):



( run in 1.070 second using v1.01-cache-2.11-cpan-748bfb374f4 )