[ANN] MagicLoader 0.10.0: painless code dependency management

T

Tony Arcieri

[Note: parts of this message were removed to make it a legal post.]

Think Bundler for your require statements:

Github: http://github.com/tarcieri/magicloader
Gemcutter: http://rubygems.org/gems/magicloader

MagicLoader uses a special algorithm to calculate the order in which various
files in your project must be required in order for your project to load
successfully. If you've been manually maintaining a dependencies list,
MagicLoader provides for your code the same automation that Bundler provides
for your gem dependencies.

You can let MagicLoader loose on a big directory of code and it will figure
out the require statement ordering and automatically write it out to a file
of your choosing. Once it's worked its magic, MagicLoader writes the
dependency list out to the given file in the form of a list of meticulously
ordered require statements. You can even use MagicLoader once then never use
it again, because the output is little different from what you might've
thrown together manually.

MagicLoader represents the evolution of the require_all gem (
http://github.com/jarmo/require_all), except rather than calculating the
dependency order at load time, MagicLoader lets you calculate it ahead of
time in a sandboxed, thread-free environment, then write it out to a given
file ensuring that your dependencies are precalculated and not subject to
environmental challenges like threads or previously defined constants.

TODO
----

MagicLoader presently doesn't load your code under pristine conditions. It
runs as a Rake task and thus brings with it everything which is already
loaded in your Rake environment. You may very well be pulling in the
MagicLoad target in your Rake environment ahead of time, which can break all
sorts of things.

To really be effective, MagicLoader needs a completely clean environment.
The easiest way to implement this is to have a separate "magicload" script
distributed with the gem that spawns a new, fresh Ruby interpreter and loads
all your code there.

In order for this to work effectively, MagicLoader needs some way of knowing
all of the gem dependencies that need to get loaded before it attempts to
load the given set of code. This requires at least one of two things (or
preferably, support for both):

- A way to specify a list of gem dependencies to be loaded when
MagicLoader::Task.new is invoked.
- An interface to Bundler to pull in your project's bundled Gem dependencies
which you can pass to MagicLoader::Task.new.

This remains the one unsolved problem preventing a MagicLoader 1.0.0
release. Pull requests for this sort of functionality are welcomed!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,981
Messages
2,570,187
Members
46,731
Latest member
MarcyGipso

Latest Threads

Top