Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the important Ruby commands? [closed]

Tags:

ruby

I'm not sure of all of them, but what are the commands to do things like update Ruby, download a new gem, or update an existing gem? What other important things are there?

Since it might matter, I'm running Windows.

like image 654
Thomas Owens Avatar asked Aug 30 '08 22:08

Thomas Owens


2 Answers

By Ruby commands you probably mean the command line programs for Ruby. These are also called Ruby Helper programs. Here are a few:

  • ruby - The interpreter itself. Run Ruby scripts or statements.

  • gem - Ruby Package Manager. Great for automatically downloading or updating small Ruby modules like XML libraries, web servers, or even whole Ruby programs.

  • irb - Interactive Ruby Prompt. This is an entire Ruby shell that will let you execute any Ruby code you want. You can load libraries, test code directly, anything you can do with Ruby you can do in this shell. Believe me, there is quite a lot that you can do with it to improve your Ruby development workflow [1].

  • ri - Quick shell access to Ruby documentation. You can find the RDoc information on nearly any Ruby Class or method. The same kind of documentation that you would find on the online ruby-docs.

  • erb - Evaluates embedded Ruby in Ruby Templated documents. Embedded Ruby is just like embedding php into a document, and this is an interpreter for that kind of document. This is really more for the rails crowd. An alternative would be haml.

  • rdoc - Generate the standard Ruby documentation for one of your Ruby classes. Its like Javadocs. It parses the Ruby source files and generates the standard documentation from special comments.

  • testrb and rake. I'm not familiar enough with these. I'd love it if someone could fill these in!

Hopefully this was what you were looking for!

like image 195
Joseph Pecoraro Avatar answered Sep 20 '22 13:09

Joseph Pecoraro


Useful command: Rake

In addition to the commands listed by Joseph Pecoraro, the 'rake' command is also pretty standard when working with Ruby. Rake makes it easy to automate (simple) tasks; like building a RubyGem or running your unit tests.

With rake, the only important command to remember is 'rake -T', which shows a list of rake tasks available in the current directory.

Updating a Ruby gem

To get back to your specific question:

To update a specific gem, you can do two things: simply update the gem:

gem update <gemname>

This will update the gem to the latest version.

Install a Ruby gem

If you want to update to a specific version, you must install it:

gem install <gemname> -v <gemversion>

You can leave out the -v options. Rubygems then installs the latest version.

How to help yourself

Two useful gem commands to remember are:

gem help

This shows how to get help with rubygems.

gem help commands

This shows all commands available to rubygems. From here you can get more specific help on a command by using gem help:

gem help update
like image 20
Wes Oldenbeuving Avatar answered Sep 18 '22 13:09

Wes Oldenbeuving