Closed atoomic closed 4 years ago
I'm open to adjust it to any other syntax but I wonder what it would looks like
so far we could use $mcpan->download_url( 'Moose' );
to get the download url from the last available version
What I suggest here is to use an optional argument for the version
$mc->download_url( 'Moose', $version);
to get the version and use ===
by default
I can see adding later an additional third argument for the compare operator which could default to ===
$mc->download_url( 'Moose', $version, $method);
I'm not sure where this could be useful, but IMO this is a future improvement if needed
e9035e05e2b7ec2574d777087f36ecbf26e3f29f now provides support for range and the additional 'dev' argument. I think this is complete :-)
my $download_url = $mcpan->download_url($distro, [$version_or_range, $dev]);
# request the last available version
my $download_url = $mcpan->download_url('Moose');
# request an older version
my $download_url = $mcpan->download_url('Moose', '1.01');
# using a range
my $download_url = $mcpan->download_url('Moose', '<=1.01');
my $download_url = $mcpan->download_url('Moose', '>1.01,<=2.00');
# requesting dev release
my $download_url = $mcpan->download_url('Moose', '>1.01', 1);
It seems like it would be better to accept a hash or a hashref of parameters for these new options rather than positional.
->download_url('Moose', undef, 1)
is not particularly obvious.
I'm not sure if it's a good idea for the version to default to ==. This doesn't match the download_url endpoint's behavior, which is modeled on CPAN::Meta::Spec. If we wanted an easy way to request a specific version, it might make more sense to borrow cpanm's syntax and accept Moose@2.2011
and Moose~>=2.2011
forms.
I'm not sure if it's a good idea for the version to default to ==. This doesn't match the download_url endpoint's behavior, which is modeled on CPAN::Meta::Spec.
This is the current behaviour of MetaCPAN::Client
, though, so we should keep that in mind.
Thanks for @oalders help for finding the api end point
notes from our discussion: https://github.com/metacpan/metacpan-api/blob/master/lib/MetaCPAN/Document/File/Set.pm#L217 https://github.com/metacpan/metacpan-api/blob/master/t/server/controller/download_url.t#L16-L66