About ruby/ext/my_extension/lib function

What is the right structure for a Ruby extension? I mean, not a RubyGem,
a Ruby extension like that openssl one that comes with Ruby source.

I’ve asked in the IRC channel and all that the people said was: “just
put it under ruby/ext”. But some extensions (openssl, for example) have
a structure like that:

ruby/ext/openssl/ lots of C files
ruby/ext/openssl/lib/openssl.rb
ruby/ext/openssl/lib/openssl/ some Ruby files

My question is: what are these Ruby files for?

I want to know because I want to compile Rubygame (a RubyGem) like if it
was a common Ruby extension in order to link it statically with an
embedded application and run it on my handheld. And on rubygame source
exists a lib dir with files that are needed by the rubygame.

Thank you for the help

Ravish Inverse wrote:

What is the right structure for a Ruby extension? I mean, not a RubyGem,
a Ruby extension like that openssl one that comes with Ruby source.

I’ve asked in the IRC channel and all that the people said was: “just
put it under ruby/ext”. But some extensions (openssl, for example) have
a structure like that:

ruby/ext/openssl/ lots of C files
ruby/ext/openssl/lib/openssl.rb
ruby/ext/openssl/lib/openssl/ some Ruby files

My question is: what are these Ruby files for?

I want to know because I want to compile Rubygame (a RubyGem) like if it
was a common Ruby extension in order to link it statically with an
embedded application and run it on my handheld. And on rubygame source
exists a lib dir with files that are needed by the rubygame.

Thank you for the help

Those ruby files (the ones under the lib directory) are just like the
class / module definitions in any other gem; in this case, some of them
happen to be written in ruby (by convention these are put inside the lib
directory) and some in C (by convention, native extensions go in an ext
directory). When a gem gets installed and the native code compiled, the
end user treats them in the same way, regardless of what language
they’ve been written in.

If your native extension is heinously complicated you might want to
organise the files into sub folders in ext, and tweak your extconf.rb.