Application interface with LuaRocks. Load this module to LuaRocks-enable an application: this overrides the require() function, making it able to load modules installed as rocks.
|require (module, constraints)||Function that overloads require(), adding LuaRocks support.|
|set_context (name, version)||Specify the root of LuaRocks' dependency chain.|
- require (module, constraints)
Function that overloads require(), adding LuaRocks support. This function wraps around Lua's standard require() call, allowing it to find modules installed by LuaRocks. 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. If a module is not available in any installed rock, plain require() is called, using the original package.path and package.cpath lookup locations. Additionally, version constraints for the matching rock may be given as a second parameter. If version constraints could not be fulfilled, this equates to the rock not being available: as such, plain require() with the default paths is called as a fallback.
- module: string: The module name, like in plain require().
- constraints: string: A comma-separated list of version constraints.
Return value:table: The module table (typically), like in plain require(). See require() in the Lua reference manual for details.
- set_context (name, version)
Specify the root of LuaRocks' dependency chain. In the presence of multiple versions of packages, it is necessary to, at some point, indicate which dependency chain we're following. set_context does this by allowing one to pick a package to be the root of this dependency chain. Once a dependency chain is picked it's easy to know which modules to load ("I want to use *this* version of A, which requires *that* version of B, which requires etc etc etc").
- name: string: The package name of an installed rock.
- version: string or nil: Optionally, a version number When a version is not given, it picks the highest version installed.