Currently you can pass rakudo a Distribution object to be installed that pipes all of its content from some (possibly remote, encoded, etc) source, but %?RESOURCES returns an IO::Path. This means you have to save the content of anything in %?RESOURCES to disk.
Instead %?RESOURCES{$key}
could mimick Distribution.content("resources/$key")
, returning an IO::Handle-like object. The "path" can then be accessed as %?RESOURCES{$key}.path
, or the content itself as %?RESOURCES{$key}.open.slurp
.
This requires some change in mindset usage wise, because although .open.slurp
should always work (access to the resource's bytes) .path
might be a url, nil, etc instead of a file path. In other words: this allows something like zef to be loaded without writing to disk (which just uses %?RESOURCES
to access config data - it doesn't care about location) but something like Inline::Perl5 that needs to pass an actual path string would need to cope... some naive solutions:
-
Authors using
%RESOURCES
should add logic to complain if the CUR loading it doesn't give a IO::Path for%?RESOURCES.path
. Something like requiringDistribution::Locally
somewhere, or adding it conditionally like/withDistribution::Builder
? -
Do it like auto-precompile where the content gets turned into an actual path somewhere if .path is ever called (by saving the content to a temporary file). example