basecamp2redmine_undo.rb

Undo import of Basecamp XML backup file into Redmine - Ted Behling, 2010-08-23 22:00

Download (630 Bytes)

 
1
#!/usr/bin/env ruby
2

    
3
# This Ruby script will delete all the projects created by basecamp2redmine.rb, based on a Basecamp "backup" XML file.
4
# See license file and legal note in basecamp2redmine.rb
5

    
6
require 'rubygems'
7
require 'nokogiri'
8

    
9
filename = ARGV[0] or raise ArgumentError, "Must have filename specified on command line"
10

    
11
x = Nokogiri::XML(File.read filename)
12
project_ids = x.xpath('//project').map{|p| (p % 'id').content}
13

    
14
puts "# Paste the following Ruby code into script/console, or run through script/runner:"
15
project_ids.each do |project_id|
16
  puts %{Project.find_by_identifier("basecamp-p-#{project_id}").destroy}
17
end