lib/zip/ziprequire.rb in rwdgutenberg-0.12 vs lib/zip/ziprequire.rb in rwdgutenberg-0.13

- old
+ new

@@ -1,8 +1,37 @@ -require 'zip/zip' +# 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 +# <code>log/simplelog.rb</code> that contains a single function +# <code>simpleLog</code>: +# +# require 'zip/zipfilesystem' +# +# Zip::ZipFile.open("my.zip", true) { +# |zf| +# zf.file.open("log/simplelog.rb", "w") { +# |f| +# 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 +# <code>zip/ziprequire</code> and include the <code>my.zip</code> zip +# file in the module search path. The following command shows one +# way to do this: +# +# ruby -rzip/ziprequire -Imy.zip -e " require 'log/simplelog'; simpleLog 'Hello world' " -class ZipList +#$: << 'data/rubycode.zip' << 'data/rubycode2.zip' + + +require 'lib/zip/zip' + +class ZipList #:nodoc:all def initialize(zipFileList) @zipFileList = zipFileList end def get_input_stream(entry, &aProc) @@ -21,10 +50,10 @@ " for '#{entry}'" end end -module Kernel +module Kernel #:nodoc:all alias :oldRequire :require def require(moduleName) zip_require(moduleName) || oldRequire(moduleName) end