My developer toolchain for Ruby
I recently learned Ruby and I thought I’d lay out the different tools I use when programming Ruby just for self documentation purposes. Most weight is put on the IDE and the TDD tools that I use.
IDE is a big deal for many people and I have tried two, Eclipse and Emacs. Since I normally only program Ruby on Linux, these are my two alternatives. In Eclipse I’ve tried the ruby plugin from Aptana and the standard one in the “Programming languages” section of the eclipse update manager. and I can’t say I prefer one over the other. Since Ruby is a dynamic language you won’t get the benefit of refactoring and completion like you would in Java, and this has lead me to ditch Eclipse for Ruby in favor of Emacs. What I miss in Emacs is integrated docs and integrated test runner. It’s possible in emacs as well but takes some hacking. We’ll see if I get around to that. I’ve been using Emacs for 12 years or so, and the first tool you pick always stick. This is my current ruby setup for Emacs:
(autoload 'yaml-mode "yaml-mode" "" t) (autoload 'ruby-mode "ruby-mode" "" t) (autoload 'rhtml-mode "rhtml-mode" "" t) (require 'flymake-ruby) (add-hook 'ruby-mode-hook 'flymake-ruby-load) (add-hook 'ruby-mode-hook (lambda() (add-hook 'local-write-file-hooks '(lambda() (save-excursion (untabify (point-min) (point-max)) (delete-trailing-whitespace) ))) (set (make-local-variable 'indent-tabs-mode) 'nil) (set (make-local-variable 'tab-width) 2) ;;(imenu-add-to-menubar "IMENU") (local-unset-ket "TAB") ;;(define-key ruby-mode-map "TAB" 'yas/expand) (define-key ruby-mode-map "\C-m" 'newline-and-indent) (require 'ruby-electric) (ruby-electric-mode t) )) ;(add-hook 'ruby-mode-hook ; '(lambda () ; (make-variable-buffer-local 'yas/trigger-key) ; (setq yas/trigger-key [tab]))) (provide 'ruby)
I use flymake to do interactive compile as I type but I suspect I’ll be turning this off when Ruby gets more into my fingers.
I want to get irb up and running from within Emacs but haven’t gotten that far yet. In addition to the ruby specific stuff I use ECB, auto-complete and yasnippet for extra support. In fact my complete emacs setup is available at the emacs github repository. I’m also thinking about getting some elisp together to be able to integrate the testrunner into a shell window in emacs. The shell part isn’t hard but it takes some configuring to get the window electric and behaving the way I want.
I develop in a TDD/BDD style and most of the tools are geared towards that. Here’s a list:
- The ruby metric_fu for all your analysis and metric needs. It wraps a lot of other rubygems that are handy. It covers code coverage with rcov, cyclomatic complexity with Saikuro, Flay for duplication detection, Flog for misc. pain points, reek for code smells and more. Nice graphs and all.
- Cucumber for BDD style outside-in testing. Does a great job both for web applications and non-web applications.
- Test::Unit for low-level unit test for driving out the details of classes.
- RSpec for the times when the Test::Unit assertions feels awkward.
- Github for storing everything. Git is the coolest version control system since, well, since ever.
Generally things move so damn fast in the ruby space and it’s hard to keep up when it’s not your main activity.
I haven’t tried Ruby-on-Rails yet and the next webapp idea I get, I’m seriously considering doing that. Yeah, I know. I’m slow.blog comments powered by Disqus