rjbs and I have been working on something that involves referring to things on
CPAN, both real files and abtract things (modules, dists without versions,
etc.).  Here's what we have working so far:

URI::cpan (isa URI::_generic) reblesses into several packages based on its
'authority'.

cpan://package/ -> URI::cpan::package

  cpan://package/Foo::Bar
  cpan://package/Foo::Bar/1.23

cpan://dist/ -> URI::cpan::dist

  cpan://dist/Foo-Bar
  cpan://dist/Foo-Bar/1.23

both package and dist urls have accessor/mutators for 'name' and 'version':

  my $url = URI->new('cpan://package/Foo::Bar');
  print $url->name;      # Foo::Bar
  print $url->version;   # undef
  $url->version("1.23"); # this works
  print $url;            # cpan://package/Foo::Bar/1.23

cpan://^[A-Z]+$/ -> URI::cpan::author

  cpan://HDP/Foo-Bar-1.23.tar.gz
  cpan://HDP/some/subdir/random/file.txt

It's up to an application to convert between them, since that would probably
require access to 02packages.  Some author urls *could* be automatically
converted to dist urls using CPAN::DistnameInfo, but that isn't included.

author urls can be easily used to download things:

  my $cpan_url = URI->new("cpan://HDP/Foo-Bar-1.23.tar.gz");
  my $http_url = URI->new_abs(
    $cpan_url->full_path_url,
    "http://www.cpan.org";, # or your favorite mirror
  );

Is there anything else that should be included?

hdp.

Reply via email to