Hello,
Let me give you some background, We have embedded devices such as FOX
VHDL (http://www.acmesystems.it/?id=120). It runs fully functional linux
kernel on which we have the ruby interpretor and a bunch of ruby
scripts. All is well except for we are running out of storage, we only
get 8MB.
Now we need to front our growing number of ruby scripts with a web
interface, most likely _why’s Camping framework or some custom CGI.
So due to space limitations I thought the best thing to do would be
compress the ruby files and decompress them at runtime. Performance
should be ok since the number of simultaneous users is throttled anyway.
I had two thoughts;
-
Build decompression in to the interpreter, I have looked through the
source (1.8.4)and it looks like I might be able to hook in to load_file,
and do something like decompress the file and pass the decompressed
contents to load_stdin (is this how code sent using -e is processed?). -
Override require in the Kernel. I’m taking a bit of guess here
because I cant actually find require.rb, but I’m guessing the file being
required is simply eval’d so I could decompress the file and eval it in
place mimicking the behavior of the normal require.
It would also be of more value if I used a different extension for
compressed ruby, maybe .crb, that way I can look for the compressed ruby
file first and if it does not exist look for a plain ruby file.
Does this seem reasonable? Any short comings?
Many thanks, Simon.