Posterous theme by Cory Watilo

Filed under: ruby

Ruby script to increment a build number

This is used to increment a build number in a tracking file for use in a build / CI script:

#!/usr/bin/ruby

def increment(filename)
    # Read it
    file_str = ''
    if File.exists?(filename)
        file_str = File.open(filename, 'r') {|file| file.read }
    end

    old_version = file_str.to_i
    new_version = old_version+1

    # Write
    File.open(filename, 'w') {|file| file.write(new_version) }

    puts "Incrementing version number in #{filename} to #{new_version}" 
end

if ARGV.length < 1
    puts 'Usage: VersionIncrement '
else
    increment(ARGV.first)
end

Simple Comet demo for Ruby on Rails

Here's the script from a talk I gave yesterday at Ruby on Rails Oceania Sydney. Hi all, I'm Chris Hulbert. During the day i work as a C# programmer, but don't hold that against me. I'm new here so be nice. I'm here to talk about Comet. Comet is a handy technique for allowing the server to notify the client about any event. Yes, welcome to windows 311 programming again, we're talking event driven programming, but for websites.

Read the rest of this post »