From: Erik Veenstra Date: 2004-08-24T05:50:42+09:00 Subject: Re: Embedded Ruby and stdin On Mon, 23 Aug 2004 06:52:59 +0900, Lennon Day-Reynolds wrote: > I'm working on a simple wrapper which embeds the Ruby runtime > and a script file into a single binary. The idea is to have > something much like Exerb, but platform-independent (i.e., > works anywhere Ruby does). Do you know about RubyScript2Exe [1]? There's a (not yet released) Linux version as well, both i386 and PPC. Most of it must work (at least in theory) with MacOS. > It reads the size and offset of an included script from the > last few bytes of the program binary,... So do I, kind of. > ... closes stdin and reopens it as a handle to argv[0], and > seeks to the script offset before initializing Ruby. That's interesting. Does your program replace the Ruby executable, or does it include the Ruby executable? I've chosen the latter option, but that's not an option if you want to do this kind of tricks. > I know that I could just copy out the script data to another > file, or eval it as a string, but there are potential > problems with that: specifically, the fact that I'm trying to > distribute binary files along with my Ruby program, which > will be added to the __END__ section of the Ruby script > before it is appended to the wrapper binary. Tar2RubyScript [2] works with "binary" data at the end of the script as well, but it does read the input script into memory (multiple times). > Since these files will be quite large (50-150MB), I want to > avoid copying them to another file, or loading them fully > into RAM, if at all possible. Well, uh, that's big... > Any ideas would be greatly appreciated. I can post code > snippets first thing tomorrow morning once I'm back at work; > I just wanted to see if anyone had any quick suggestions > before that. Just have a look at the 2 projects mentioned. They are pretty mature. You might learn from them... And I may learn from you... Good luck! gegroet, Erik V. [1] http://www.erikveen.dds.nl/rubyscript2exe/index.html [2] http://www.erikveen.dds.nl/tar2rubyscript/index.html