Skip to content

low-rb/lowload

Repository files navigation

Gem version GitHub repo Codeberg repo

LowLoad

LowLoad is really dumb; like a bull in a china shop, smashing through fragile dependencies to autoload your code without manual load/require/require_relative calls.

  1. First LowLoad goes through all your files and notes their constant definitions and file paths
  2. Then it goes through the same files again and creates autoloads for each file's dependencies
  3. Then it goes through every file again and loads it into Ruby

Features:

  • Use any namespace structure you want (namespaces are not inferred from folder structure)
  • Mix in manual requires in autoloaded files
  • Supports RBX files

File Support

LowLoad supports normal Ruby (.rb) files as well as a few other embedded formats.

RBX

LowLoad supports loading RBX files (.rbx). RBX files are Ruby files containing unescaped HTML markup:

class MyClass
  def render
    <p>Hello</p>
  end
end

ℹ️ For more information see LowNode.

Antlers [UNRELEASED]

Antlers syntax such as <{ ChildNode }> can be embedded inside the render method of your RBX file.

Philosophy

  • Folders are often organised by the kind of file it is, a bunch of views for example. But namespaces should be organised by your domain — different to your file structure
  • You should be able to mix autoloading with manual require calls for stuff like gems, and require_relative when you need files outside the autoloaded directory

Caveats

Like other autoloading libraries, LowLoad doesn't support circular dependencies on class load (runtime is fine).

❌ Please don't do:

class A
  include B
end

class B
  include A
end

✅ Instead do:

class A
  include C
end

class B
  include C
end

class C
  # Code that both A and B share.
end

Installation

Add gem 'lowload' to your Gemfile then:

bundle install

About

An autoloader that is dumb but lets you do you

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors