Created
November 1, 2008 19:07
-
-
Save bricooke/21555 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'rubygems' | |
require File.join(File.dirname(__FILE__), 'basecamp') | |
require 'activesupport' | |
project_id = ARGV[0] | |
person_id = "2333575" | |
xml_data = File.open(ARGV[1]).read.gsub("@", "") | |
def parse_minutes(a_time) | |
(Time.parse(a_time) - Time.now.beginning_of_day).to_i / 60 | |
end | |
basecamp = Basecamp.new("makalumedia.projectpath.com", "MYUSERNAME", "MYPASSWORD") | |
tasks = [] | |
doc = REXML::Document.new xml_data | |
doc.elements.each("job/tasks/task") do |task| | |
basecamp.post_time_entry({ | |
:project_id => project_id, | |
:person_id => person_id, | |
:date => Date.parse(task.elements["date"].text, true).to_s(:db), | |
:hours => parse_minutes(task.elements["time"].text) / 60.0, | |
:description => task.elements["description"].text.gsub("%20", " ").gsub("%22", "\""), | |
:todo_item_id => nil | |
}) if parse_minutes(task.elements["time"].text) != 0 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment