Loading ruby source from a zip archive? -


i have mod_rails server disk space, oddly enough, @ premium. there way me compress application's source, python's zipimport?

there obvious disadvantages this, should break down , spend nickel on disk space, figured it'd worth shot.

oh, neat. check out rubyzip gem:

rubyzip features zip/ziprequire.rb module (source) allows ruby load ruby modules zip archives.

(update: ziprequire.rb no longer present in rubyzip gem, source link appears contain old content nonetheless.)

like so. modified example:

require 'rubygems' require 'zip/zipfilesystem' require 'zip/ziprequire'  zip::zipfile.open("/tmp/mylib.zip", true) |zip|   zip.file.open('mylib/somefile.rb', 'w') |file|     file.puts "def foo"     file.puts "  puts 'foo here'"     file.puts "end"   end end  $:.unshift '/tmp/mylib.zip' require 'mylib/somefile'  foo    # => foo here 

you don't have use rubyzip library create zipped library, of course. can use cli zip that.


Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -