Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/adamluzsi/loader.rb
Ruby require loader gem with caller tricks
https://github.com/adamluzsi/loader.rb
Last synced: 13 days ago
JSON representation
Ruby require loader gem with caller tricks
- Host: GitHub
- URL: https://github.com/adamluzsi/loader.rb
- Owner: adamluzsi
- License: mit
- Created: 2014-02-02T22:23:09.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2016-02-27T16:36:21.000Z (over 8 years ago)
- Last Synced: 2024-10-19T16:48:25.941Z (24 days ago)
- Language: Ruby
- Size: 59.6 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
loader
======Ruby module for automatic file require based on convention :)
### Introduction
Okey, before you even think about use this gem,
let's say this gem only for lazy ones...the basic idea is to have an easy to use relative require system and a namespace based Constant loading logic
The fun part is , that this stuffs can be used in gems (modules),
because it do not depend on the Dir.pwd or any kind of absolute path or
the File expand_path tricks that based on the application position.The end goal is to make an easy ruby file loader for apps and gems.
### Examples
load relative directory (not based on Dir.pwd but the caller files position)
if you pass multiple string as argument it will be joined by file separator that the OS use#### Manual loading folders
```ruby
require 'loader'
# load all ruby file that was not loaded already
# from that relative folder
require_relative_directory "folder_name"# for recursive use try the following
require_relative_directory_r "folder_name/path/etc"```
#### Autoload folders
```ruby
require 'loader'
Loader.autoload```
optionally you can tell the project root folder if you work with in a gem.
```rubyrequire 'loader'
Loader.autoload(File.dirname(__FILE__))```
If you like the basic idea that the app should not do any kind of Eager Load and become slow,
you can use the constant based autoload function##### [Sketch about how it works](https://github.com/adamluzsi/loader.rb/blob/master/doc/sketch.md)