Alex Rivera | Logout

What is the modern way to structure a ruby gem?

Asked 2010-07-22T08:56:16.113
42

Has much changed with the release of Bundler? Is there a template that can be used as a base? What are the best practices?

Edit
Report

1 Answer

5

When writing fat (binary) gems the structure is usually this:

lib/1.8/binary.so

lib/1.9/binary.so

lib/my_gem.rb (this file simply chooses which binary.so to load depending on ruby version)

And for native extensions:

lib/ext/my_gem/my_sources.*

lib/my_gem.rb

I also usually put a version.rb file here:

lib/my_gem/version.rb

and it simply contains something like:

module MyGem
    VERSION = "0.1.0"
end

Also, IMO, don't put any .rb files except the file you want people to use to load the gem, in the lib/ directory. Instead put all auxiliary files in lib/my_gem/

answered 2010-07-22T11:08:46.310

Your Answer