%module OpenBabel
gives rise to a .cpp file with
#define SWIG_init Init_OpenBabel
#define SWIG_name "OpenBabel"
When you try 'require openbabel', it complains:
" undefined symbol: Init_openbabel"
The ruby convention would be: 'require openbabel', and then "OpenBabel::OBObject.new"
Use of %openbabel imports fine, but the resulting module name has the wrong case, "Openbabel::OBObject.new"
Still the case with current git master.
FWIW, you can run
swig -ruby -initname openbabel
to achieve what you want.Perhaps the default should be the module name lowercased instead of the module name as-is, but that needs input from someone who knows more about Ruby than I do.
Also, SWIG_init and SWIG_name aren't actually used in Ruby - it generates the name of the
Init_OpenBabel
function directly, rather than calling itSWIG_init
like some other languages do.This would be the change I think (untested):
Still seems to be the case with current git master.
https://github.com/rubocop/ruby-style-guide#snake-case-files adds evidence that what SWIG calls the "init name" ought to be lower case. According to that it perhaps ought to be
open_babel
here rather thanopenbabel
for%module OpenBabel
- SWIG does haveCamelCase
tosnake_case
conversion code so we could easily do that, and there's always-initname openbabel
if that's what you really want.I think this should just apply to the auto-generated default, and an explicit
-initname OpenBabel
should allow that people who really wantrequire 'OpenBabel'
to still have it.Currently there are some examples in the manual which violate this which we should update to use more conventional names too: