Skip to main content

Ruby gem explained

 


What is a Ruby Gem?

Gems are open source libraries just like jar packages in java or modules in Go, the gem contains contain Ruby code. This helps in modularization of the code. A gem can be used by a developer in their own program, without writing that piece of code.

You can check the different gems at https://rubygems.org/. Below are some of the popular gems:

Bundler — Provides a consistent environment for Ruby projects by tracking and installing the exact gems and versions that are needed.

RSpec — A testing framework that supports BDD for Ruby.

Devise — Devise works with authentication. Website that needs to user log-in’s, Devise handles sign in, sign up, reset password, etc.

JSON — Provides an API for parsing JSON from text.

Nokogiri — Provides HTML, XML, SAX, and Reader parsers with XPath and CSS selector support.

Rails — Rails is a fullstack web application development framework.

Install Gems

To Install gems locally you can run the command:

gem install [gem_name]

The gem install command fetches the code, downloads it to your computer, and installs the gem and any necessary dependencies and builds documentation for the installed gems.

To see all gems installed locally run the command

gem list

Thank you folks.

Most viewed

Understanding ASCII / Unicode character encoding format

Computer stores everything in binary format. The process of converting a value into binary is called Encoding and the the process of converting value from binary is called Decoding. value --> binary  ::     Encoding  binary --> value   ::    Decoding for example: A number 12 is stored in its binary format as below.               12 ---> 00001100 but how are the characters are stored? If we want to store a character 'a' what formatting should be used ? It easiest way is to map the characters to number and store the binary format of that number. So, the character 'a' is represented as number 97 is stored as 1100001.  ASCII: In ASCII encoding format, 128 unique characters are identified and mapped with numbers (mostly English). One byte is used to represent all the characters. It uses 7 bits to represent numeric value 0 to 127 (total 128 characters).  The most significant bit is a...