Created
February 5, 2011 19:35
-
-
Save codatory/812709 to your computer and use it in GitHub Desktop.
Pivotal Tracker Importer for Redmine
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
begin | |
require 'ruport' | |
rescue LoadError => err | |
warn "Couldn't load ruport gem: #{err}" | |
end | |
namespace :import do | |
desc 'Import tickets from CSV File' | |
task :csv => :environment do | |
csv_file = Table(Rails.root.join('db', 'seeds', 'import.csv'), :records => true) | |
csv_file.rename_columns({ | |
'Story' => 'subject', | |
'Story Type' => 'story_type', | |
'Current State' => 'state', | |
'Description' => 'description', | |
'Estimate' => 'estimate' | |
}) | |
csv_file.each do |row| | |
issue = Issue.new | |
story = row.to_hash | |
issue.project_id = 1 | |
case story['story_type'] | |
when 'chore' | |
issue.tracker_id = 4 | |
when 'bug' | |
issue.tracker_id = 1 | |
when 'feature' | |
issue.tracker_id = 2 | |
else | |
issue.tracker_id = nil | |
end | |
issue.subject = story['subject'] | |
issue.description = story['description'] | |
issue.story_points = story['estimate'] | |
issue.author = User.first | |
case story['state'] | |
when 'unscheduled' | |
issue.status_id = 7 | |
when 'unstarted' | |
issue.status_id = 1 | |
when 'started' | |
issue.status_id = 2 | |
when 'finished' | |
issue.done_ratio = 100 | |
issue.status_id = 3 | |
when 'accepted' | |
issue.status_id = 5 | |
else | |
issue.status_id = 8 | |
end | |
if issue.save | |
print '.' | |
else | |
print "! #{story.id} - #{issue.errors.first} !" | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How does this work? I would like to use this, but am fairly new to ruby... Hence, I don't get the 'gist' of this.... :-D
Quick explanation please? Thanks.