From: Jesse van den Kieboom Date: 2004-09-16T02:22:10+09:00 Subject: Re: Truly modular Op wo 15-09-2004, om 18:19 schreef Robert Klemme: > "Jesse van den Kieboom" schrieb im Newsbeitrag > news:1095262552.10900.12.camel@ayla... > > Hi, > > > > As Ruby claims to be very modular I'd like to do the following (I tried > > some things but I think I'm going in the wrong directions). > > > > I have my main Ruby application. The applications need to be extendible. > > My idea is to write extra .rb files and put them in one directory. The > > main app should somehow load those files to extend functionality. on > > runtime the files can changes and the main app should be able to reload > > the extensions. Also new files can be added and these should be reloaded > > too. > > > > I don't know the right approach to this problem. The external .rb files > > somehow need to have access to parts of the main application and the > > main application obviously needs to call functions from the external > > files. > > > > Users can communicatie with the main app telling it there are new > > external files to be loaded, the name of the files and maybe function > > names to be called or whatever. The idea is that I don't want to restart > > the main application but do want to extend it on the flow. > > > > Somebody with some great ideas how to achieve this? > > Great? Dunno... As far as I can see here are two problems: > > i) file loading with respect to changes This is not the main issue though. If I have to I can manually tell the application to reload a certain file. Or use GnomeVFS for instance. > ii) communication between the code in the files and your app > I can suggest something for i) (see below) but for ii) I'd have to know > more about the nature of the app. My application gets data through a TCPSocket. All the data for example is prefixed by a certain command. I would like to have some sort of modular support for these commands which means that I can dynamically add a certain action for a new command. My guess was that this could best be done by loading external files, let the files register some command/actionfunction and have some sort of communication between the files code and the main app code. The communication is the problem. Jesse van den Kieboom