Skip Menu |
 

This queue is for tickets about the Module-Runtime CPAN distribution.

Report information
The Basics
Id: 77101
Status: open
Priority: 0/
Queue: Module-Runtime

People
Owner: Nobody in particular
Requestors: perl [...] toby.ink
Cc: ribasushi [...] leporine.io
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: (no value)



Subject: available_module(MODULENAME)
Download (untitled) / with headers
text/plain 559b
It would be handy to have a function that translates a module name to its notional filename, searches @INC for it, but does not then require it. Example use case... a module I'm working on needs: * Mouse and MouseX::Types; or * Moose and MooseX::Types. I don't want to require Mouse until I'm sure that MouseX::Types is available, and I don't want to require Moose until I'm sure that MooseX::Types is available. Maybe even accept a list available_modules(MODULE1, MODULE2, ...) and return true if and only if all the modules listed are available.
Subject: Re: [rt.cpan.org #77101] available_module(MODULENAME)
Date: Thu, 10 May 2012 10:00:12 +0100
To: Toby Inkster via RT <bug-Module-Runtime [...] rt.cpan.org>
From: Zefram <zefram [...] fysh.org>
Download (untitled) / with headers
text/plain 406b
Toby Inkster via RT wrote: Show quoted text
>It would be handy to have a function that translates a module name to its >notional filename, searches @INC for it, but does not then require it.
With the possibility for code refs in @INC, searching @INC for a module is not a straightforward task. I'm not sure that this can be correctly done outside the core. Still, it's a sane wish, I'll keep this ticket open. -zefram
Download (untitled) / with headers
text/plain 422b
Show quoted text
> With the possibility for code refs in @INC
Good point - I hadn't considered that. Still, I'd be happy with a tri- state: 1 = "module certainly exists; it's already been included, or we've found it on disk" 0 = "module certainly does not exist; it's not included, it's not on disk, and there are no coderefs in @INC" undef = "module might exist; it's not included, it's not on disk, but there are coderefs in @INC"
Download (untitled) / with headers
text/plain 685b
On Fri May 11 19:13:59 2012, TOBYINK wrote: Show quoted text
> > With the possibility for code refs in @INC
> > Good point - I hadn't considered that. Still, I'd be happy with a tri- > state: > > 1 = "module certainly exists; it's already been included, or we've found > it on disk" > > 0 = "module certainly does not exist; it's not included, it's not on > disk, and there are no coderefs in @INC" > > undef = "module might exist; it's not included, it's not on disk, but > there are coderefs in @INC"
Have you checked Class::Inspector->installed() ? It is pretty close to what you are after. However see the caveat in the bugtracker (i.e. coderefs in INC, which happens to be how PAR works)
Download (untitled) / with headers
text/plain 175b
I think find_module might be a better name than available_module. I am only chiming in because a function to do this came up in another discussion related to Module::Runtime.
Download (untitled) / with headers
text/plain 492b
On 2012-05-10 02:00:30, zefram@fysh.org wrote: Show quoted text
> Toby Inkster via RT wrote:
> >It would be handy to have a function that translates a module name to its > >notional filename, searches @INC for it, but does not then require it.
> > With the possibility for code refs in @INC, searching @INC for a module is > not a straightforward task. I'm not sure that this can be correctly done > outside the core. Still, it's a sane wish, I'll keep this ticket open.
Module::Path can do this, mostly.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.