A Beginners Tutorial to the Gems Package

Posted by kumarjit in Internet Trends, Software, The Internet

1 Star2 Stars (No Ratings Yet)

A Beginners Tutorial to the Gems Package

Rails is an application developed in the Ruby language which helps in development of Rails application. Rails is designed to make assumptions about what developers need to get started, so that web application development becomes much easier. Using Rails, developing web applications becomes much easier, at the same time; the coding process becomes less extensive and much more simple. Rails is basically functions according to an ‘opinionated’ logic, wherein the logic decides on the ‘best’ way to perform the work, and encourages the user to follow that path. The ‘Rails path’ will probably lead to the best productivity.

A Beginners Tutorial to the Gems Package

RubyGems

Rubygems is a Ruby software library manager. A Ruby code packaged in this manner is called a gem. For example, when you find the required Ruby software for any particular project, you can download, install and manage the software using gems. The first RubyGems project was created by Ryan Leavengood in 2001. The initial focus of RubyGems was on simplifying the process of installing, removing, updating and managing Ruby libraries. An innovative twist was added by the new developers when they provided the system with the ability to manage several versions of the same library easily. Using RubyGems, it is possible to provide very powerful control over which version of the library is to be used by the code.

Gems Tutorial

Installation

First of all, you need to download the current version of RubyGems. To install the software, you need to type in

ruby setup.rb all

Gem Command

In RubyGems, the gem command is the command which is used to interact with the RubyGems package system. To test it out, type in:

Gem list

It shows a single package-source installed.

Installing gem packages

The next step is to begin installing the required gem packages in the machine. Once again, as is required in case of installation, you need to be the root in order to install any gem packages or modify them. However, any user can query the system to find out which packages have been installed in the system. RubyForge is one of the most popular resources from where Ruby open-house software can be downloaded. Ruby on Rails is a popular RubyForge project which uses the RubyGem package. The following command can be used to install the Rails gem:

Gem install rails –include-dependencies

A Beginners Tutorial to the Gems Package

RMagick, a Ruby interface used for ImageMagick, can be installed using the command

Gem install rmagick

As this gem includes a non Ruby code, it compiles the C code as a part of the installation process. In case the compile tool is not installed beforehand, the installation fails.

Other uses of gem command line

Other features which are offered can be accessed by the following commands

Gem update

Updates all the current versions of gems to their latest versions

Gem cleanup

Removes old versions of gems which are installed

Gem uninstall

Removes a particular gem from the repository

The command

Gem server

Automatically launches a Ruby based server on port 8808. Adding the –p option to the code will allow the server to be launched on a different port. This makes it relatively simpler for your web server to view the documentation on all the gems that are installed on your machine to learn their API. In case the rdoc is already installed on the system, gem will automatically generate the rdoc for every gem installed.

Using libraries for Ruby scripts

In order to use the Ruby libraries while executing the Ruby scripts, the require  mechanism can be used in the following manner:

Require ‘rubygems’

This will automatically load the RubyGems code and allow the script to use the latest version of the Gem installed in the machine.

Make the most of Web 2.0 by hosting Ruby on Rails application only on Bounceweb!

Be Sociable, Share!

Leave a Reply

You must be logged in to post a comment.