mruby/mruby — pull request #470 by bovi (2012-09-13 13:59:20+00:00)
Title: Proposal and Proof Of Concept for a Library Manager (working title: mrbgems)

Hi,

I would like to put up an idea for discussion. Lately it seems that more and more add-ons to mruby are written. These libs (like the POSIX support) won't be merged into the core due to the reason that they are to platform dependant. Still I would like to see a way to integrate these kind of things easily into my project without going away from the mruby master. I would like to see a standardised way of including additional features like File System or Network support added as a library which is easy to integrate into my mruby binary and also easy to remove or update at a later time.

The current approach of integrating additions by patching them into the existing code and triggering them over include/mrbconf.h seems to be a little bit hacky.

So I would like to propose something which I call *mrbgems*. I just wrote very quick a small piece of demonstration code as a patch. PLEASE DON'T THINK ABOUT APPLYING THE PATCH NOW! I just want to provide some code for discussion. The current code adds a directory called *mrbgems* to the root path. Inside of this directory exists an initialisation file (*init_gems.c*) which bootstraps all gems. In the future I would imagine one directory per gem inside of *mrbgems*. At the moment I just added one directory named *md5* which contains the md5 binding from mattn.

This all compiles for now and gives the possibility to use the gem via the libmruby.a library:

````
boviAir:bovi daniel$ ./bin/mirb
mirb - Embeddable Interactive Ruby Shell

This is a very early version, please test and report errors.
Thanks :)

> MD5.md5_hex "test"
=> "d41d8cd98f00b204e9800998ecf8427e"
> ^D
````

The following things are TODOs from my perspective:
- compile a variable amount of gems (not only md5 as for now)
- automatically generate *init_gems.c* to include all bootstrap functions of all gems
- integrate dynamically all gems into the libmruby.a lib (not only md5 as for now)
- define a standard structure for a gem
- ??remove some functions from the core into a gem?? like Time ??

I would be happy for any feedback. Does anybody thinks this kind of feature (regardless of my current proof of concept code) is interesting? If yes, I'm more than happy to hear any suggestions, criticism, etc. to improve the current idea and create some code which could be integrated into mruby. If you don't think this kind of feature is necessary I'm also open for any information about how to integrate external libraries in an easy way with the current situation. Maybe I missed it :-)