https://github.com/gforge/torch-dir-loader
Loads a directory of files
https://github.com/gforge/torch-dir-loader
Last synced: over 1 year ago
JSON representation
Loads a directory of files
- Host: GitHub
- URL: https://github.com/gforge/torch-dir-loader
- Owner: gforge
- License: mit
- Created: 2017-01-30T10:28:39.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-01-31T13:07:13.000Z (over 9 years ago)
- Last Synced: 2025-02-03T13:15:30.087Z (over 1 year ago)
- Language: Lua
- Size: 8.79 KB
- Stars: 1
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# torch-dir-loader
Loads a directory of files. You use the function as:
```
local loader = requrie 'torch-dir-loader'
local loaded_files, docs, my_object = loader('src')
```
The `loaded_files` contains all the files that have loaded. The `docs` contains
docs if you're using the `argcheck.doc` system. The `my_object` will be an object
if you have an `init.lua` that returns an object.
## init.lua details
If there is an `init.lua` it will load that files collect any returning object and send it to the other files via the parameters.
In order to use the object returned from the `init.lua` use the following
in all other files, below is an example on how to extend a `torch.class`:
```
local params = {...}
local my_object = params[1]
my_object.additional_function = function()
end
```
## Load once
Each file that the loader remembers loaded files, thus each file is only loaded
once. This means that the second time that the loader is invoked on the same directory
it won't result in any returned data.
## The specs
See the specs folder for tests that use the `busted` package.