#!/usr/bin/env ruby # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # Program to generate a 'life graph' as seen at # http://dropbox.theadmin.org/media/life.png # # Code and examples at http://dropbox.theadmin.org/bin/life_graph/ # # Copyright (c) 2005 Eric Davis # Released under the MIT License # Details: http://dropbox.theadmin.org/bin/life_graph/LICENSE.txt # # Last Revision: [2005/12/07] # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # require 'rubygems' require 'gruff' require 'yaml' life_file = File.open( "life.yaml") date = Array.new business = Array.new energy = Array.new gtd = Array.new morale = Array.new sleep = Array.new work = Array.new hacking = Array.new yp = YAML::load_documents(life_file) { |item| date << item['date'] business << item['business'] energy << item['energy'] gtd << item['gtd'] morale << item['morale'] sleep << item['sleep'] work << item['work'] hacking << item['hacking'] } lg = Gruff::Line.new(800) lg.theme_37signals lg.title = "Eric's Life Graph" # lg.data("Business", business ) ### not enough colors. lg.data("Energy", energy ) lg.data("GTD", gtd ) lg.data("Morale", morale ) lg.data("Sleep", sleep ) lg.data("Work", work ) lg.data("Hacking", hacking ) total_days = date.length lg.labels = { 0 => total_days.to_s + ' days ago', total_days - 1 => 'Yesterday' } lg.write('life.png')