Skip to content
rifraf edited this page Sep 14, 2010 · 2 revisions

Adding additional files to the cache

  • Vendorize.add(filename) will add any named file (that must be on the $LOAD_PATH) into the cache. It does not have to be executable code.
  • Vendorize.add_requirable(filename) will perform the same caching that would occur for require, but does not actually load the file. Note that because the file doesn’t get loaded, files that it requires internally won’t get cached.
  • Vendorize.add(dirname) will add any named directory (that must be on the $LOAD_PATH) into the cache. All the files in the directory, and all of its subdirectories will be cached. They do not have to be executable code.

Vendorize.add(dirname) can be useful to force all files in a GEM install to get cached. Typically a call such as require 'test/unit' will result in most, but not all of the files getting loaded (because not all paths through the code are executed at first load). Rather than trying to force the code to execute every route, you can do this:

require 'test/unit'
Vendorize.add_dir('test/unit') if defined?(Vendorize)
Clone this wiki locally