Ruby Automation – Can Ruby Be Used to Automate Everything?

automationrubyscriptingtest-automation

I face various types of applications (web-based, GUI-based, command-line, etc.) on various platforms (Windows, Linux, etc.) to operate everyday. There is a great opportunity for me to automate tasks by scripting. But almost every type of application and platform has its native scripting language or tools (such as VBScript and PowerShell for Windows, Bash scripts for Linux, Selenium for web applications, and AutoIt for GUI applications, etc.). It kills me to learn and maintain so many scripting languages.

I have a feeling that Ruby can interoperate with various platforms easily, and it is very expressive. So my question is:

  1. It is possible to use Ruby to script everything?

  2. If it is, what are the main disadvantages compared to the native scripting language of each platform?

Best Answer

Ruby is a fine choice for a general purpose scripting language on Linux, OS X, etc. But I recently needed to write some scripts that would work on every version of Windows from 2000 through 7. VBScript didn't have the functionality I needed (talking to SOAP web services for example) and PowerShell isn't available for Windows 2000, so I looked outside the Microsoft toolkit and decided to give Ruby a shot (having used it on Linux in the past). I don't exactly regret the decision, but I do wonder if there might've been a better choice. My main complaints about Ruby on Windows were:

  • There's no 64-bit Ruby for Windows (as far as I know) which made trying to access virtualized areas of the system like c:\windows\system32 a drag. I ended up shelling out to VBScript for some of that stuff; maybe there's a better way I didn't figure out.
  • It's slow. I have a quad-core CPU and 6GB RAM and irb takes 2+ seconds to load.
  • While there are Windows-specific libraries for stuff like registry access and WMI, things definitely aren't always as easy as you think they might be and the relative lack of documentation does result in some trial and error.

Still, things basically work the way you'd expect and I like working with Ruby about a thousand times better than anything built into the OS, so at a minimum, I'd say you could do worse than Ruby for general purpose scripting on Windows.

Related Topic