Path: lib/zip/ziprequire.rb
Last Update: Sun Aug 24 13:00:55 +0200 2008

With ziprequire you can load ruby modules from a zip file. This means ruby‘s module include path can include zip-files.

The following example creates a zip file with a single entry log/simplelog.rb that contains a single function simpleLog:

  require 'zip/zipfilesystem'"", true) {
    |zf|"log/simplelog.rb", "w") {
      f.puts "def simpleLog(v)"
      f.puts '  Kernel.puts "INFO: #{v}"'
      f.puts "end"

To use the ruby module stored in the zip archive simply require zip/ziprequire and include the zip file in the module search path. The following command shows one way to do this:

  ruby -rzip/ziprequire  -e " require 'log/simplelog'; simpleLog 'Hello world' "

Required files