Skip to content

Instantly share code, notes, and snippets.

@yrgoldteeth
Created May 11, 2010 14:26
Show Gist options
  • Save yrgoldteeth/397369 to your computer and use it in GitHub Desktop.
Save yrgoldteeth/397369 to your computer and use it in GitHub Desktop.
Export workorders created from git commit messages from csv file. Takes optional number argument to go back n days.
require 'rubygems'
require 'active_support'
require 'excelsior'
class WorkorderList
attr_accessor :data_file, :data, :workorders
def initialize(day=Time.now)
@data_file = File.join('/home/ndfine/code/misc/work_order', "#{day.strftime('%Y_%m_%d')}_work_orders.csv")
@data = []
@workorders = {}
load_data
load_categories
load_workorders
end
def load_data
Excelsior::Reader.rows(File.open(@data_file, 'rb')) do |row|
@data << row
end
end
def load_categories
categories = []
@data.each {|d| categories << d[0]}
categories.uniq!
categories.each {|c| @workorders[c] = []}
end
def load_workorders
@data.each {|d| @workorders[d[0]] << d[1]}
end
def to_s
@workorders.each do |w|
puts w.first
w.last.each {|r| puts " #{r.capitalize}"}
puts ""
puts ""
end
end
end
if ARGV.first.present?
days_ago_int = ARGV.first.to_i
day = days_ago_int.days.ago
else
day = Time.now
end
WorkorderList.new(day).to_s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment