trackinator 0.0.10 → 0.0.11
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/trackinator/google.rb +3 -1
- data/lib/trackinator/importer.rb +7 -2
- data/lib/trackinator/version.rb +1 -1
- data/lib/trackinator/you_track.rb +29 -12
- metadata +1 -1
data/lib/trackinator/google.rb
CHANGED
@@ -14,6 +14,8 @@ module Trackinator
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def get_tickets file_name
|
17
|
+
puts "reading document..."
|
18
|
+
|
17
19
|
spreadsheet_feed = @client.get("http://spreadsheets.google.com/feeds/worksheets/#{get_spreadsheet_key(file_name)}/private/full").to_xml
|
18
20
|
spreadsheet_list_data = @client.get(spreadsheet_feed.elements[1, 'entry'].elements[1, 'content'].attributes['src']).to_xml
|
19
21
|
|
@@ -42,7 +44,7 @@ module Trackinator
|
|
42
44
|
data = {}
|
43
45
|
|
44
46
|
REXML::XPath.match(entry, 'gsx:*').each do |col|
|
45
|
-
data[col.name] =
|
47
|
+
data[col.name] = col.text unless col.text.nil?
|
46
48
|
end
|
47
49
|
|
48
50
|
data
|
data/lib/trackinator/importer.rb
CHANGED
@@ -19,31 +19,36 @@ module Trackinator
|
|
19
19
|
issues = validate_tickets(ticket_data)
|
20
20
|
|
21
21
|
if issues.length == 0
|
22
|
+
puts "importing..."
|
23
|
+
|
22
24
|
ticket_data.each do |entry|
|
23
25
|
issue_id = @you_track.is_issue_exists? entry
|
24
26
|
false unless !issue_id.nil? ? @you_track.update_ticket(issue_id, entry) : @you_track.create_ticket(entry)
|
25
27
|
end
|
26
28
|
end
|
27
29
|
|
30
|
+
puts "done..."
|
31
|
+
|
28
32
|
issues
|
29
33
|
end
|
30
34
|
|
31
35
|
private
|
32
36
|
|
33
37
|
def validate_tickets tickets
|
38
|
+
puts "validating..."
|
34
39
|
issues = []
|
35
40
|
|
36
41
|
project = tickets[0]['project']
|
37
42
|
|
38
43
|
issues.concat(@you_track.project_exists?(project))
|
39
|
-
issues.concat(@you_track.you_track_fields_defined?(project, tickets[0].keys))
|
40
44
|
|
41
45
|
tickets.each do |ticket|
|
46
|
+
issues.concat(@you_track.you_track_fields_defined?(project, ticket.keys.collect! { |key| key.downcase }))
|
42
47
|
issues.concat(validate_fields(ticket))
|
43
48
|
issues.concat(validate_formats(ticket))
|
44
49
|
end
|
45
50
|
|
46
|
-
issues
|
51
|
+
issues.uniq
|
47
52
|
end
|
48
53
|
|
49
54
|
def validate_fields ticket
|
data/lib/trackinator/version.rb
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
require 'erb'
|
2
|
+
include ERB::Util
|
3
|
+
|
1
4
|
module Trackinator
|
2
5
|
class YouTrack
|
3
6
|
def initialize opts
|
@@ -32,10 +35,10 @@ module Trackinator
|
|
32
35
|
|
33
36
|
def update_ticket issue_id, data
|
34
37
|
success = set_platform(issue_id, data['platform'])
|
35
|
-
success ? (success = set_summary_and_description(issue_id, data['summary'], data['description'])) : (return success)
|
38
|
+
success ? (success = set_summary_and_description(issue_id, data['summary'], data['description'], data['outcome'])) : (return success)
|
36
39
|
success ? (success = set_type(issue_id, data['type'])) : (return success)
|
37
40
|
success ? (success = set_import_identifier(issue_id, "#{data['project']}-#{data['id']}")) : (return success)
|
38
|
-
success ? (success = set_design_reference(issue_id, "#{data['
|
41
|
+
success ? (success = set_design_reference(issue_id, "#{data['designreference']}")) : (return success) unless data['designreference'].nil?
|
39
42
|
|
40
43
|
success
|
41
44
|
end
|
@@ -57,11 +60,15 @@ module Trackinator
|
|
57
60
|
response = @connection.get("#{@path_prefix}rest/admin/project/#{project}/customfield", { 'Cookie' => @cookie, 'Content-Type' => 'text/plain; charset=utf-8' })
|
58
61
|
response_xml = REXML::Document.new(response.body)
|
59
62
|
|
60
|
-
you_track_fields =
|
63
|
+
you_track_fields = %w{ notes }
|
64
|
+
|
65
|
+
response_xml.elements.each('projectCustomFieldRefs/projectCustomField') do |element|
|
66
|
+
you_track_fields << element.attributes["name"].sub(' ', '').downcase
|
67
|
+
end
|
61
68
|
|
62
|
-
|
69
|
+
required_fields = fields - REQUIRED
|
63
70
|
|
64
|
-
|
71
|
+
required_fields.each do |document_field|
|
65
72
|
unless you_track_fields.include?(document_field)
|
66
73
|
issues << "Validation Error: Custom field '#{document_field}' not found in YouTrack"
|
67
74
|
end
|
@@ -101,7 +108,7 @@ module Trackinator
|
|
101
108
|
end
|
102
109
|
|
103
110
|
def create_youtrack_ticket data
|
104
|
-
response = @connection.put("#{@path_prefix}rest/issue?project=#{data['project']}&summary=#{data['summary']}&description=#{data['description']}&priority=#{data['priority']}", nil, { 'Cookie' => @cookie, 'Content-Type' => 'text/plain; charset=utf-8' })
|
111
|
+
response = @connection.put("#{@path_prefix}rest/issue?project=#{data['project']}&summary=#{url_encode(data['summary'])}&description=#{url_encode(construct_description(data['description'], data['outcome']))}&priority=#{data['priority']}", nil, { 'Cookie' => @cookie, 'Content-Type' => 'text/plain; charset=utf-8' })
|
105
112
|
return response.header["Location"].split("/").last, response.header.msg
|
106
113
|
end
|
107
114
|
|
@@ -110,40 +117,50 @@ module Trackinator
|
|
110
117
|
response.header.msg.eql? "OK"
|
111
118
|
end
|
112
119
|
|
113
|
-
def set_summary_and_description issue_id, summary, description
|
120
|
+
def set_summary_and_description issue_id, summary, description, outcome
|
114
121
|
return true if summary.nil? || description.nil?
|
115
122
|
|
116
|
-
response = @connection.post("#{@path_prefix}rest/issue/#{issue_id}/?summary=#{summary}&description=#{description}&disableNotifications=true", nil, { 'Cookie' => @cookie })
|
123
|
+
response = @connection.post("#{@path_prefix}rest/issue/#{issue_id}/?summary=#{url_encode(summary)}&description=#{url_encode(construct_description(description, outcome))}&disableNotifications=true", nil, { 'Cookie' => @cookie })
|
117
124
|
response.header.msg.eql? "OK"
|
118
125
|
end
|
119
126
|
|
120
127
|
def set_platform issue_id, platform
|
121
128
|
return true if platform.nil?
|
122
129
|
|
123
|
-
response = @connection.post("#{@path_prefix}rest/issue/#{issue_id}/execute?command=Platform+#{platform}&disableNotifications=true", nil, { 'Cookie' => @cookie })
|
130
|
+
response = @connection.post("#{@path_prefix}rest/issue/#{issue_id}/execute?command=Platform+#{URI.escape(platform)}&disableNotifications=true", nil, { 'Cookie' => @cookie })
|
124
131
|
response.header.msg.eql? "OK"
|
125
132
|
end
|
126
133
|
|
127
134
|
def set_type issue_id, type
|
128
135
|
return true if type.nil?
|
129
136
|
|
130
|
-
response = @connection.post("#{@path_prefix}rest/issue/#{issue_id}/execute?command=Type+#{type}&disableNotifications=true", nil, { 'Cookie' => @cookie })
|
137
|
+
response = @connection.post("#{@path_prefix}rest/issue/#{issue_id}/execute?command=Type+#{URI.escape(type)}&disableNotifications=true", nil, { 'Cookie' => @cookie })
|
131
138
|
response.header.msg.eql? "OK"
|
132
139
|
end
|
133
140
|
|
134
141
|
def set_import_identifier issue_id, import_id
|
135
142
|
return true if import_id.nil?
|
136
143
|
|
137
|
-
response = @connection.post("#{@path_prefix}rest/issue/#{issue_id}/execute?command=Import+Identifier+#{import_id}&disableNotifications=true", nil, { 'Cookie' => @cookie })
|
144
|
+
response = @connection.post("#{@path_prefix}rest/issue/#{issue_id}/execute?command=Import+Identifier+#{URI.escape(import_id)}&disableNotifications=true", nil, { 'Cookie' => @cookie })
|
138
145
|
response.header.msg.eql? "OK"
|
139
146
|
end
|
140
147
|
|
141
148
|
def set_design_reference issue_id, reference
|
142
149
|
return true if reference.nil?
|
143
150
|
|
144
|
-
response = @connection.post("#{@path_prefix}rest/issue/#{issue_id}/execute?command=Design+Reference+#{reference}&disableNotifications=true", nil, { 'Cookie' => @cookie })
|
151
|
+
response = @connection.post("#{@path_prefix}rest/issue/#{issue_id}/execute?command=Design+Reference+#{URI.escape(reference)}&disableNotifications=true", nil, { 'Cookie' => @cookie })
|
145
152
|
response.header.msg.eql? "OK"
|
146
153
|
end
|
147
154
|
|
155
|
+
def construct_description description, outcome
|
156
|
+
template = ERB.new <<-EOF
|
157
|
+
<% unless outcome.nil? %>'''Steps'''<% end %>
|
158
|
+
<%= description %>
|
159
|
+
<% unless outcome.nil? %>'''Outcome'''<% end %>
|
160
|
+
<%= outcome %>
|
161
|
+
EOF
|
162
|
+
|
163
|
+
template.result(binding)
|
164
|
+
end
|
148
165
|
end
|
149
166
|
end
|