-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathcsv2lighthouse.rb
48 lines (40 loc) · 1.1 KB
/
csv2lighthouse.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/env ruby
require 'rubygems'
require 'active_record'
require 'active_support'
require 'active_resource'
require 'lighthouse'
require 'csv'
# Configure Me... #####################################################
# Enter your Lighthouse account and token. The token must have both
# read & write access.
Lighthouse.account = 'ACCOUNT_NAME'
Lighthouse.token = 'TOKEN'
# Your Lighthouse Project ID
PROJECT_ID = 12345
def save_to_lighthouse(record)
t = Lighthouse::Ticket.new(:project_id => PROJECT_ID,
:title => record['title'],
:body => record['description'],
:state => record['state'],
:milestone_id => record['milestone'])
p record['title']
t.tags << taggify(record['tags'])
t.save
t
end
def taggify(s)
return "" if s.nil?
s.downcase.gsub(/[^a-z0-9\-_@\!' ]/,'').strip
end
def import(fname)
CSV.foreach(fname, :headers => :first_row) do |row|
save_to_lighthouse(row)
end
end
unless ARGV.length > 0
puts "No file specified."
Process.exit(1)
else
import(ARGV[0])
end