I wrote a short ruby script to generate various screenshots, and event though I am not completely new to ruby I rarely use it.
Full script (41 LOC): https://gist.github.com/1229115
The string substitutions irritate me. They don't look quite right - much too ugly for a beautiful and concise language like ruby. Am I overdoing it? What alternatives are there?
Here is the lines I am concerned about (for context, please take a look at the gist):
# assemble file name
fname = "#{directory}/#{prefix}-#{timestamp}-#{commit}-#{size[:width]}x#{size[:height]}.png"
# create command line stuff
call = "#{macruby_exe} #{snapper} \
--width #{size[:width]} --height #{size[:height]} #{url} #{fname}"
# now call it
system call
# just to show the progress (and the file sizes)
puts "#{fname} (#{File.size?(fname) / 1024}kB)"
Just to illustrate the script, the output usually looks like:
screenies/screenshot-1316535022-0b5c7967887481deb17bcd9039cd3fe0ac4540d4-640x960.png (95kB)
screenies/screenshot-1316535022-0b5c7967887481deb17bcd9039cd3fe0ac4540d4-800x480.png (62kB)
screenies/screenshot-1316535022-0b5c7967887481deb17bcd9039cd3fe0ac4540d4-800x600.png (78kB)
^ ^ ^ ^ ^
| | | | ________|______
| | | | | |
directory prefix timestamp commit size[:width] x size[:height]