Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set a %?RESOURCES key during development?

Tags:

module

raku

In a module I'm developing, there will be a file config provided in the resources directory, and so it can be accessed as %?RESOURCES<config> within the code I am developing.

Whilst writing and testing the code, I need to set %?RESOURCES. How can this be done?

At the start of the module, in the development stage, I have use lib 'lib'.

I haven't zef-installed the Module yet, so %?RESOURCES is Nil.

The META6.json file contains "resources": [ "config" ] .

like image 926
Richard Hainsworth Avatar asked Jan 13 '21 11:01

Richard Hainsworth


Video Answer


1 Answers

In principle, I don't think it's possible to set any variable with the twigil ?. Unlike those with the * twigil, they're not dynamic variables, but simply a reflection of some core data structure. In the case of %?RESOURCES, the documentation says:

The %?RESOURCES variable is not implemented as a plain Hash, but as an instance of the Distribution::Resources type, so do not expect to see all available resource files in a distribution by printing or by using other ways to inspect its value. Instead, use the API described above to access particular files

As you see in the documentation for Distribution::Resource, which cough could be improved by a lot, there's no interface for even setting the values.

If what you're looking for is to install a resource during runtime, it's probably not advisable to do so. But TIMTOWDI, and the previous class might give you some hints on how to do it.

like image 52
jjmerelo Avatar answered Sep 25 '22 04:09

jjmerelo