Panagiotis Atmatzidis

a digital diary

Creating a Ruby Workflow: Part 1

| Comments

Introduction

This tutorial is targeted towards ruby newbies who often find the ruby ecosystem frustrating, although the language per se is easy to learn 1.

Here you should be able to find all the information to get you a fully working ruby environment.

Feel free to leave a comment if you face some kind of problem that is already discussed here.

To avoid repeating information that is available elsewhere, I will link the projects to whom I’m referring too (e.g. rvm ).

Further help on ruby you can get via IRC, the ruby mailing list or the forums2.

GNU/Linux as a development platform

The GNU/Linux is an open source operating operating system consisting of the Linux kernel and GNU tools. GNU/Linux comes in many flavors called distributions. The most widely used GNU/Linux distribution is probably Ubuntu.

GNU/Linux is a mature, stable and widely used environment among developers. This system gives you access to an incredible variety of development toolchains out of the box and is the operating system of choice for running servers.

On the downside some non-development specific applications might not be as polished as their counterparts running on Microsoft Windows or Apple’s OSX.

If you have time, curiosity and will to learn, then do try to install Linux on your computer and give it a go! Becoming familiar with GNU/Linux will give lots of benefits and will help you get a better understanding of how operating systems work.

GNU/Linux is the most customizable operating system out there and can run on nearly any sort of hardware. Even computers considered very old can run successfully some Linux flavor! So if you feel that your hardware is becoming obsolete, give linux a try. Just choose a lightweight distribution for your own sake!

Mac OSX as a development platform

Apple’s operating system called MacOSX is probably the operating system of choice for rubyists. OSX is extremely well polished in my opinion.

OSX has the added plus that combines the best of both worlds, meaning that it’s at least as polished as Microsoft Windows if not more, when it comes to applications and desktop environment and it’s a UNIX-based platform beneath. You can launch the terminal and work on a fully fledged UNIX-based environment, similar to GNU/Linux.

The last version of MacOSX, as of this writing is called Yosemite and ships with ruby-2.0.0. My advise is to use the latest stable version if you’re starting with ruby today!

In order to prepare a MacOSX system for development the user needs to install additional software. First install xCode. Then you can choose one of these two solutions to manage open source software on your Macintosh:

  • MacPorts: A complete, full feautered flexible system to handle software installation, updates and management of dependencies. You can read more about MacPorts on their installation page.
  • HomeBrew: Similar solution to MacPorts. It’s easier to install and faster to deliver but lacks the flexibility of MacPorts.

You will need either of those two systems installed in order to proceed without issues. Ruby needs some extra software packages that you can install using any of the above mentioned solutions.

Most Mac users opt for HomeBrew but I use MacPorts. Both seem to be good.

Microsoft Windows as a development platform

Microsoft Windows is a tricky platform for any kind of software development other than Microsoft related technologies (e.g. Visual Basic, C#, etc.).

In the first revision of this guide, I won’t cover MS Windows installation because I don’t have a usable MS Windows installation anywhere near me.

That said, I’m not a Microsoft fan. I find MS Windows 8.x hideous, but that’s a personal opinion more than anything else. You can still develop on Windows.

NOTE: I will update this guide if the situation changes and I have access to licensed version of Microsoft Windows.

Installing ruby

Ruby has libraries called gems. A collection of these libraries can be found on the RubyGems website. Some of these libraries will add important, well tested, functionalities to your programs. Other libraries will have executable scro[ts that you will need to run. Hence, the operating system needs to know where they are and what to do with them at any time. These libraries change versions. Some change versions more often than others. As with every software development cycle, every new version has some additions. Sometimes though it has obsoletes some functions. So you have to keep an eye on the different versions of each library in order to avoid hassles.

Keeping up to speed with all these things is a huge pain. That’s why some very nice people developed a few solutions that are widely used in the ruby world.

Installing ruby with rvm

RVM stands for Ruby Version Manager. You can download and install RVM on any UNIX-like system. Follow the instructions on the front page.

RVM will help you install multiple ruby versions, and gemsets. So you can have for example a Ruby on Rails projects running on ruby-1.9.3 while developing a second projects using plain ruby-2.1.2. Each of these projects can run it’s own distinct library collections.

The documentation is good and the authors of the project are very helpful either through IRC or StackOverflow.

Installing ruby with rbenv

Another very popular tool similar to RVM is rbenv. It uses a structure similar to RVM although the nomeclature is a little bit different. The documentation is extensive and you should read the documentation at least once if you plan to go with rbenv.

Installing ruby vanilla

The vanilla way of installing ruby is to download the source code from Ruby’s official website and compile the code yourself.

Although this procedure is considerably easy for any UNIX-like system, should be avoided by users that are not intimately familiar with command line installations.

My 2 cents here is to go with the flow and install ruby using rbenv or rvm. Learning how to use any of these tools will help you considerably in your future as a ruby programmer.

Installing ruby using package managers

You could install ruby using the package manager of your distribution if you are on GNU/Linux or one using MacPorts or Homebrew if you’re on a Mac.

Unfortunately most linux distribution update ruby versions very late. So you will probably end up with some old ruby version.

NOTE: Package managers might install ruby at some point in order to add ruby support third party programs (e.g. VIM). Both rvm and rbenv will help you run your custom ruby version without interfering with the ruby version installed by your package manager.

Editors and IDEs

Editors

Choosing an editor is not a trivial task, it’s almost like wine: The true sweetness of wine is one flavor. A modern editor should support at least the following:

  • Syntax highlighting
  • Auto-completion
  • Code snippets
  • Code execution (on the fly, via shortcut)

The last feature will be extremely helpful as you make your first steps with ruby. If you want to just try some ruby code in your browser, without installing additional software, you can visit the TryRuby website and test your snippets!

Some good editors which support all of the above features and much more are:

NOTE: Vim and Emacs are most popular editors in the UNIX world for a variety of reasons. The learning curve is very steep and might be daunting for new programmers. If you think you have what it takes make your research and pick one of the two. I assure that your productivity will sky-rocket once you get the hand of it.

Whatever editor you choose, please stick with it at least for 6 months and try to learn how to automate your workflow using your editor!

IDEs

Integrated development environments (IDEs) are not extensively used in the ruby community but some developers like having everything tight up in one package. The most popular IDEs to develope ruby (or rails) applications are:

Epilogue

You’ve reached the end of the first part. Hopefully you’ve got an overview of the ruby ecosystem and a pretty good idea about the best way to deploy ruby in your system.

In the second part I will describe my personal which consists mainly of vim and the terminal multiplexer.


  1. Mind you, ruby is like guitar: It’s easy to learn but hard to master.

  2. The forums and the mailing are connected so you can one or the other.