About ruby/ext/my_extension/lib function.

R

Ravish Inverse

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
 
C

Chris Mowforth

Ravish said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,962
Messages
2,570,134
Members
46,692
Latest member
JenniferTi

Latest Threads

Top