Today I’ll share what I use for some of my DIY time-tracking when I do freelancing (sometimes I use other tools, depending on the customer).
Conventions I currently use:- one google calendar per customer (I name these “LoGeek CustomerName” to avoid conflicts with other calendars I would have shared with my customer – LoGeek is my company name)
- event title stores the project name
Code
require 'rufus/gcal'
customer = "LoGeek Acme Company"
Rufus::Google::Calendar.get_calendars( :account => user_name, :password => password)
calendar = get_calendars[customer]
# don't keep the default (low) :max_results or you'll probably miss events
events = calendar.events( "max_results" => 1000,
"start_min" => '2009-09-09T00:00:00',
"start_max" => '2009-11-25T11:00:00')
events.each do |e|
duration = (e.end_time - e.start_time)/3600.0
raise "corrupt event" if duration > 8
print e.title # project name
print " - "
print e.start_time.strftime(...)
print e.end_time.strftime(...)
print " - "
print duration
print " hours"
puts
total += duration
end
Once you have this data, you can either export it as CSV, or reinject it into Prawn or Documatic to create an invoice.
Resources
Known dependencies: Documentation:Thanks!
Thanks to John Mettraux for creating this useful libraries and many others!
To receive each article,
subscribe by RSS
or
by email.
The comments system is brand new - don't be afraid to comment!
All the posts are listed below and on the homepage.
- Monitoring File Changes and Getting Notified via Growl (February 14th, 2010)
- Using JRuby to prototype VST plugins (November 17th, 2009)
- Introducing Learnivore.com (September 15th, 2009)
- How to create small, unique tokens in Ruby (July 2nd, 2009)
- Detecting Which Ruby Interpreter is Running (JRuby, IronRuby) (March 4th, 2009)
- How to create an empty Rails Edge application (January 28th, 2009)
- How to Freeze Gems with Rails >= 2.1 (December 23rd, 2008)
- Thoughts on IronRuby and .Net Testing (December 1st, 2008)
- How to Retrieve Delicious Tags and Number of Bookmarks for a Given Url (November 30th, 2008)
- Fixing Symbol not found _rl_filename_completion_function (November 6th, 2008)
- How to Generate a Gradient for your CSS using RMagick (October 21st, 2008)
- Analyzing Your GMail History (September 18th, 2008)
- Data Visualization with Ruby and RMagick - Where Are Those Bikes ? (March 31st, 2008)
- All-Time Classics: a Selection of Recommended Books for Software Developers (February 23rd, 2008)

