NAME
wad - rolls all your libraries in a big wad, ghetto style
After rubygems and bundler, let us take you full circle and go back to a lib directory that contains all your libraries. Except now, it’s per project.
SYNOPSIS
$ wad roll # installs all your libs into 'vendor/lib', by default.
DESCRIPTION
Since we’re all following very strict standards with regards to how our gems are constructed, we might as well pack all those gems back into a directory and use that directory in our load path.
Once you do that, you’ll discover that loading from all these paths and doing dependency resolution cost on every ruby invocation. On our machines, using wad saves us >500ms every time, on every call.
Wad helps you with getting there: It vendors your Gemfile below ‘vendor/bundle`, then copies relevant source code to `vendor/lib`. All in one simple call.
After that, the standard code for augmenting the load path in your binaries becomes:
require 'pathname'
root = Pathname.new(__FILE__).dirname.join('..').
%w(vendor/lib lib).each { |p| $:.unshift(root.join(p)) }
require 'mylib' # And it's simple requires from then on.
It might be useful to extend your (bash) .profile with something like this:
function be() {
if [[ -d vendor/lib ]]; then
RUBYOPT="-I vendor/lib" command $*
else
if [[ -a Gemfile ]]; then
bundle exec $*
else
command $*
fi
fi
}
alias ruby="be ruby"
alias rake="be rake"
alias rspec="be rspec"
alias irb="be irb"
This way, you don’t notice wad. Except that it boots real quick.
INSTALL
$ gem install wad
BUGS
This is new and will get you into all sorts of trouble, unless you know what you’re doing. But if you don’t, you’re in trouble anyway. In short: if any milk gets spilt, don’t expect us to lick it.
COPYRIGHT
MIT. See LICENSE file.
AUTHORS
Resident Astronauts: Kaspar Schiess (Technology Astronauts dot ch) & Florian Hanke (Technology Astronauts dot ch)