How to name a gem which is a Ruby wrapper for an existing C library?

dubek's Avatar


08 Aug, 2011 07:44 PM

I want to write a Ruby wrapper for an existing C library. Existing examples are the gems bcrypt-ruby which gives Ruby interface for the bcrypt C library (password hashing), and yajl-ruby which gives Ruby interface for the YAJL C libary (JSON parser).

These two examples "break" the gem naming convention suggested in the Rubygems guides:

  1. The gem name contains dash instead of underscore
  2. The gem name doesn't match the require line (that is, in order to use the library you need to require "yajl" or require "bcrypt".

I don't have anything against those two gems, but I want to know what would be the best way to name another gem with a similar purpose (Ruby wrapper for an existing C library).

Note that naming the gem yajl (for example) might create a problem because there is already a github project called yajl (it's the C library code). Maybe the github repository name can be yajl-ruby but the name in the gemspec can be yajl. Is that cool?

Maybe keep the -ruby suffix even if it breaks the naming convention? (maybe update the naming convention?)

Thanks a lot for your help,

  1. 1 Posted by Luis Lavena on 08 Aug, 2011 07:58 PM

    Luis Lavena's Avatar


    Naming the gem, while not following recommended RubyGems practices, are not related to what the gem does.

    For example, Psych is a gem that wraps libyaml library for YAML emitter.

    Rugged is the wrapper around libgit2.

    And there are other examples.

    One simple example, sqlite3-ruby, it was known as SQLite3/Ruby bindings, which recently got renamed to simple "sqlite3"

    MySQL/Ruby library which is distributed as "mysql" gem.

    You're free to name the gem as you like, as long is not inflammatory or disrespectful of other members or libraries in the community like "railssucks" or things like that.

    The guides do not cover it in too much detail:

    But Eric Hodel, one of the maintainers of RubyGems outlined his preferences about the conventions:

    Hope that helps.

  2. 2 Posted by dubek on 09 Aug, 2011 06:24 AM

    dubek's Avatar

    Thanks. I think in my case it would be better to name the gem simply after the name of the C library, like mysql or sqlite3. Clearly gems are for Ruby, so it doesn't make a lot of sense to add -ruby or _ruby to the gem name...

    The only thing I don't like is having a github project named after the original library name, because it can be mistaken for as the official repository for the C library (consider the yajl repository which has the C library code). I think I'll follow your move with sqlite3: the github repository name will have the -ruby suffix, but the gem name (in gemspec) will be simply the library name.

    Makes sense?

  3. 3 Posted by Luis Lavena on 09 Aug, 2011 01:18 PM

    Luis Lavena's Avatar

    Makes totally sense.

    Glad this helped you. Closing out.

    Feel free to reopen if you have further questions.

  4. Luis Lavena closed this discussion on 09 Aug, 2011 01:18 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac