Runnin' this site ain't free, help us out! Donate.
Programming With Ruby Episode 11, Ruby Projects
Covered In This Episode:
- Finding projects (GitHub, RubyForge)
- Using Rubygems
- Using the code
Hello Everybody and welcome to Programming With Ruby Episode 11, Ruby
Projects. I’m Tyler, and this video is brought to you by
Despite what the name may imply, this episode is not about making
projects in ruby, but finding and using projects other people have
made. I will be showing you rubyforge.org and github.com, both places
have many different and useful projects hosted.
I will also be showing you how to use rubygems, arguably the easiest
and most popular way of installing, managing, and keeping up to date
various ruby libraries, tools, etc. which rubygems calls gems.
And finally you will learn how to use the code you find!
Lets get started!
Finding Projects – Rubyforge
Rubyforge is one of the most popular hosting sites for ruby
projects. (It is also where most gems are hosted)
Just navigate over to http://rubyforge.org to get started
If you want to find a project, you have a few options. First is the
search box located at the top right of the website.
Second is the project tree where you can find projects by the category
they are in.
Third is the most popular projects on the homepage, which can be
helpful from time to time.
If you find a project that you like, you can download it, or install
it as a gem if it is available. Both of which will be covered a little
later in this tutorial.
Finding Projects – GitHub
Github is another project hosting site, that easily lets developers
collaborate using the version control system, git. Github has been
gaining a lot of popularity with Ruby programmers lately and you can
find many Ruby projects here.
GitHub is located at http://github.com
GitHub has search functionality, and most popular like Rubyforge, but
it is a little more comprehensive.
GitHub also offers nice graphs and many download options depending on
To start using rubygems, first you have to install it. If you
installed via a one-click installer you probably already have it. To
check if you have it installed, open your command prompt and enter
“gem”. If nothing comes up, it is not installed.
If you are on Debian or a variant of it (such as Ubuntu) this command
will get you rubygems: sudo apt-get install rubygems
Otherwise go to http://rubygems.org/ and download rubygems from there.
After you’ve installed, run the command:
to make sure the installation succeed. If not you may have to add
rubygems to your PATH, a quick Google search will tell you how.
For this example I you will install the gem hpricot, which parses HTML.
simply use the command:
gem install hpricot
sudo gem install hpricot
It should install successfully, and now you can start using it in your code!
But before we do that, I would like to show you a few more features or rubygems.
“gem list” lists all the gems you have installed
“gem uninstall gem” uninstalls the specified gem
“gem update” updates all your gems
“gem help commands” shows all commands that rubygems has, so you can
explore on your own!
Using the code
Now that you have installed a gem, or downloaded a projects source
code, you can use it in your own programs.
To obtain access to an installed gem, or the source file add the
following line to the top of your program:
require 'rubygems' require 'name' # Name can be a gem or a source file
if you are just using a source file, you don’t need to require rubygems
require 'rubygems' require 'hpricot'
If you are loading a file that can change, use load:
load ‘name’ # Name can be a gem or a source file
Note that I said source file. This means that you can separate your
own code into different files and load them in using the load or
Now we have reached that sad sad time, when the episode starts ending.
If you have any question, comments, or suggestions leave a comment on
this page, or send me an email at email@example.com
Please do not forget to donate, a small $5 or $10 donation will help
more than you realize!
Thanks for watching, Goodbye.Programming With Ruby Episode 10, Objects and ModulesProgramming With Ruby Episode 12, Documentation