A couple of years ago, when I needed email notification on a svn repository,
I wrote a C# program that will alert me on changes and provide information on
what was checked in, by whom, and the check in comment, etc. In order to gather
this information, I had to obviously call svnlook with different arguments. So, I
wrote
public static string ExecSvnlook(string arguments)
{
using(Process
theProcess = new Process())
{
theProcess.StartInfo = new ProcessStartInfo(svnlook,
arguments);
theProcess.StartInfo.RedirectStandardOutput = true;
theProcess.StartInfo.RedirectStandardInput = true;
theProcess.StartInfo.RedirectStandardOutput = true;
theProcess.StartInfo.UseShellExecute = false;
if (theProcess.Start())
{
StreamReader stdOut = theProcess.StandardOutput;
string response = stdOut.ReadToEnd();
return response;
}
else
{
return "error";
}
}
}
I had found .NET to be very productive and I still find it productive in a number
of areas.
However, when I had to provide notification for another repository, I did it a bit
differently
this time. I could have reused the C# code I wrote. Instead, I decided to write it
this time
using Ruby (Programmers will secretively admit that rewrite is more fun than reuse
:)).
The result, above method turned into:
def
exec_svnlook
`svnlook #{arguments}`.chomp
end
In fact I didn't need this method. I was able to directly use the call where I needed
it with a
couple of lines more to check for error.
When all was said and done (for what I wanted this notification to be), with good
indentation
and spacing, .NET code was about 140 lines plus a configuration file. Ruby was a total
of 50
lines with no configuration file.
More and more of my administrative scripts are turning up in Ruby. I've written code
to update
database, send out automatic email notifications, doing back up and copying of files
across
machines, ...
I had quite a few aha moments on the Rails project that I worked on earlier this year.
The real strength of Rail comes from Ruby. If you're still testing the Ruby waters,
you may want
to take a look at Bruce Tate's "From
Java to Ruby."
I had the pleasure of reading the above book and Stu and Justin's "Rails
for Java Programmers."
I learned a great deal from their discussions and arguments.
As Stu and Justin put it, ?Rails is the gateway drug, Ruby is the addiction.?
I will next share how my .NET code has changed due to Ruby influence.