Hobbies And Interests

How to Build Ruby Gems

Ruby is a programming language created by Japanese computer scientist Yukihiro Matsumoto. Ruby libraries are distributed using a centralized network and package format known as Gems. Each gem contains the code neccessary to add a specific feature to the Ruby language. You can create your own Ruby Gems for distributing your Ruby software using the NewGem tool available at the RubyForge Gem library. It is, conveniently enough, installed using the Gem library manager which comes with most versions of Ruby.

Instructions

    • 1

      Create the GemSpec file. The easiest way to do this is with the NewGem tool from the RubyForge Gem library. To enable it for use on your system, type the following from a command line, a text driven tool for controlling your computer:

      gem install newgem

      If you are using a Linux of Mac OS X system, you may need to preface this with the "sudo" command, which forces the command to run with full administrative privileges, allowing it to modify the system directories.

    • 2

      Navigate to the directory that contains the Ruby source files that you would like to include in the Gem. For example, if the source files are in C:\myrubycode, type the following:

      cd C:\myrubycode

    • 3

      Type the following to create the gemspec file that describes the traits of the gem:

      newgem gemName

      Replace "gemName" with the name that you want your gem to have.

    • 4

      Open a text editor, such as Windows Notepad, and open the gemspec file generated. Fill in any missing details, such as your own name, copyright and Gem description.


https://www.htfbw.com © Hobbies And Interests