[MetaCPAN] GET-ing a module by name Case-Insensitively

SundaraRaman R sundaryourfriend at gmail.com
Sat Jun 20 14:58:09 GMT 2015


I looked into that, and found a Perlmonks thread from 2013 (I think)
where someone had written a script to find modules that differed only
by case, and found there were 44 such pairs back then (I'll post the
link to the thread when I manage to find it again). So, it appears
PAUSE does allow that.

But in this case, that is an edge case that I think is okay to ignore
- I'm hoping that whatever the solution is, it will also tell us when
there is more than one match, so that in those ambiguous cases we can
avoid showing the user anything.

-
Sundar


On Sat, Jun 20, 2015 at 8:21 PM, Ævar Arnfjörð Bjarmason
<avarab at gmail.com> wrote:
> Are CPAN modules themselves case-insensitive? I wonder if PAUSE allows
> foo::bar and FOO::BAR.
>
> I doubt that such conflicting modules exists though, but it's worthwhile to
> consider what this proposed metacpan API should do in the event of a
> collision.
>
> On 20 Jun 2015 4:47 pm, "SundaraRaman R" <sundaryourfriend at gmail.com> wrote:
>>
>> Hi,
>>
>> I'd like to GET data on a module by its name, similar to what the
>> /module/Module::Name endpoint does, except I would like to be able to
>> specify the Module::Name as module::name or Module::name, etc. What
>> would the easiest way to do this be?
>>
>> The usecase is, I'm hacking on the MetaCPAN Instant Answer on DuckDuckGo
>> (eg: https://duckduckgo.com/?q=metacpan+LWP%3A%3AUserAgent), which
>> currently uses the /module/Module::Name form of API call internally.
>> This gives the user some information about the current version of the
>> module, as extracted from the API. It works if the user enters the
>> module's name in the exactly correct case, but even a single letter
>> being incorrect in case (eg: LWP::Useragent) leads to no result from the
>> API. I'd like to change this so that it works whatever case the user
>> enters the module name is in.
>>
>> I noticed that there is a module.name.lowercase field, and got as far as:
>>
>> $ curl http://api.metacpan.org/v0/module/ -d'
>> {
>> "filter": { "bool": { "must": [ { "term": { "module.name.lowercase":
>> "lwp::useragent" }}, {"match": {"status": "latest"}} ] } }
>> }'
>>
>> which seems to work, but I'm unsure on (a) whether there is a simpler
>> way of achieving this (b) whether the above would be sufficient to
>> replicate what the /module/ endpoint does i.e. reliably getting the
>> latest version of the module.
>>
>> An additional constraint (and further reason a simpler solution would be
>> appreciated) is that the Instant Answers (AFAICT) support making only
>> GET requests (without a BODY), no POSTs. So I believe the above would
>> have to become a big encoded "?source" abomination if this was indeed
>> the simplest way to achieve this. I'm hoping that this is not the case!
>>
>> Cheers,
>> Sundar
>>
>> _______________________________________________
>> MetaCPAN mailing list
>> MetaCPAN at lists.scsys.co.uk
>> http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/metacpan



-- 
! Knowing others is intelligence; knowing yourself is true wisdom.
Mastering others is strength; mastering yourself is true power.



More information about the MetaCPAN mailing list