Module luarocks.loader
Functions
add_context (name, version) | Process the dependencies of a package to determine its dependency chain for loading modules. |
call_other_loaders (module, name, version, module_name) | Request module to be loaded through other loaders, once the proper name of the module has been determined. |
luarocks_loader (module) | Package loader for LuaRocks support. |
pick_module (module) | Search for a module |
select_module (module, filter_module_name) | Search for a module in the rocks trees |
sort_versions (a, b) | Internal sorting function. |
which (module) | Return the pathname of the file that would be loaded for a module. |
Functions
- add_context (name, version)
-
Process the dependencies of a package to determine its dependency chain for loading modules.
Parameters
- name: string: The name of an installed rock.
- version: string: The version of the rock, in string format
- call_other_loaders (module, name, version, module_name)
-
Request module to be loaded through other loaders, once the proper name of the module has been determined. For example, in case the module "socket.core" has been requested to the LuaRocks loader and it determined based on context that the version 2.0.2 needs to be loaded and it is not the current version, the module requested for the other loaders will be "socket.core_2_0_2".
Parameters
- module: The module name requested by the user, such as "socket.core"
- name: The rock name, such as "luasocket"
- version: The rock version, such as "2.0.2-1"
- module_name: The actual module name, such as "socket.core" or "socket.core_2_0_2".
Return value:
table or (nil, string): The module table as returned by some other loader, or nil followed by an error message if no other loader managed to load the module. - luarocks_loader (module)
-
Package loader for LuaRocks support. A module is searched in installed rocks that match the current LuaRocks context. If module is not part of the context, or if a context has not yet been set, the module in the package with the highest version is used.
Parameters
- module: string: The module name, like in plain require().
Return value:
table: The module table (typically), like in plain require(). See require() in the Lua reference manual for details. - pick_module (module)
-
Search for a module
Parameters
- module: string: module name (eg. "socket.core")
Return value:
string, string, string: name of the rock containing the module (eg. "luasocket"), version of the rock (eg. "2.0.2-1"), name of the module (eg. "socket.core", or "socket.core_2_0_2" if file is stored versioned). - select_module (module, filter_module_name)
-
Search for a module in the rocks trees
Parameters
- module: string: module name (eg. "socket.core")
- filter_module_name: function(string, string, string, string, number): a function that takes the module name (eg "socket.core"), the rock name (eg "luasocket"), the version (eg "2.0.2-1"), the path of the rocks tree (eg "/usr/local"), and the numeric index of the matching entry, so the filter function can know if the matching module was the first entry or not.
Return value:
string, string, string: name of the rock containing the module (eg. "luasocket"), version of the rock (eg. "2.0.2-1"), name of the module (eg. "socket.core", or "socket.core_2_0_2" if file is stored versioned). - sort_versions (a, b)
-
Internal sorting function.
Parameters
- a: table: A provider table.
- b: table: Another provider table.
Return value:
boolean: True if the version of a is greater than that of b. - which (module)
-
Return the pathname of the file that would be loaded for a module.
Parameters
- module: string: module name (eg. "socket.core")
Return value:
string, string, string: name of the rock containing the module (eg. "luasocket"), version of the rock (eg. "2.0.2-1"), filename of the module (eg. "/usr/local/lib/lua/5.1/socket/core.so")