Ruby is a Tool, How have you used it?

Sometimes I feel like I forget the utility of the Ruby language. Part of the reason is how I use it so much via Rails. Ruby is a almost perfect scripting language, once you should reach for when performing everyday programming tasks.

There are many, many articles on this subject, and we’ve had a few more recently on SitePoint. My question today is: How have you used Ruby as a tool?

I’d love to build a thread of quick-hitting, useful Ruby examples so we never forget how utilitarian Ruby can be.

I use it for loads of stuff unrelated to Rails.
For example I wrote a small script to recurse through a directory tree, open text files (based on the extension) and perform a find and replace on the contents. This proves useful when I have to change something globally on one of the static websites I look after (i.e. one which wasn’t built using a CMS).
I also wrote a static website generator in Ruby, as well as a GUI editor to allow our secretary to update an events plan on our webpage.

Nice @Pullo…have you considered releasing this stuff to the community?

I never really thought about it to be honest. I’ve nothing against doing so, but it’d probably take some time to get it in a state that other people might find useful.

Thinking about it, I also wrote a GUI password generator which will generate you a secure password on demand.

This people can read about: (although it appears that something hideous has happened to the code formatting).

Edit: I fixed the code highlighting and stuck the code on GitHub.

I find Ruby to be my “Go To” [scripting] language when I need to accomplish a task that:

  • requires manipulating lots of textual data
  • is repetitive and mundane to perform with an editor (although as I grow my VIM skills there are some AMAZING things that can be done
  • may need to be performed again, later, on another set of data

If this is likely to be a “one-of” task I will trudge through it with sed, awk and/or vi. But Ruby is often just plain fun to use. And it provides the additiona benefit that - among my colleagues - I am percieved as a sort of “wizard” for using the hip-new-tools from the Open Source world (we are a very stoic [e.g. US Government] organization).

Yeah, Ruby is my first option when building simple cli utilities like parallel git pull, calendar events or hours duration summing. When I have time I try to rewrite those tools in Rust to gain super-speed. :smile:

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.