What exact steps in the # core are required in Ruby?

The ruby ​​specification does not document specific steps, exactly what algorithm is used to search and then execute files in MRI Ruby 1.9.3?

I'm basically looking for: http://docs.python.org/reference/simple_stmts.html#import for Ruby

+4
source share
2 answers

From a technical point of view, you do not need a file, you need a function.

If you submit the full path to the required call (e.g. require '/home/users/kerrick/my_lib/utils' ), it will load the file /home/users/kerrick/my_lib/utils.rb (either .so or .dll or .bundle ).

If you do not specify the full path, Ruby will look in your boot path in the order specified by ruby -e 'puts $:' on UNIX command line.

Also, keep in mind that if you need to do something more than once, it will download only once.

+3
source

It may help, not sure if this is what you are looking for.

https://github.com/rubinius/rubinius/blob/master/kernel/common/codeloader.rb#L198

0
source

Source: https://habr.com/ru/post/1414436/


All Articles