zensana 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/lib/zensana/commands/project.rb +25 -19
- data/lib/zensana/models/zendesk/user.rb +4 -3
- data/lib/zensana/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b18b7ff525379225c8f69bce1b3ea35a6e0d792b
|
4
|
+
data.tar.gz: 4a4230204921505fcd69183c7d1d1e61e2edcdd9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 01a350826753a4d61e3ac7fe73089540d2745b7c114707e5dafecb383616e95e3aa3cd34b40379977473268c690a2756f6c60d635dafe309f0392a263f62377c
|
7
|
+
data.tar.gz: a575ccec62f200adf69cf5a84086d518c4348c9f3368ff28b418c2c480f28af80214bcc59218c08380dde36d9bc41e21be4c360a1919594c0e27da78604f17a1
|
data/README.md
CHANGED
@@ -4,6 +4,8 @@ This gem provides access to the Asana API and ZenDesk Ticket Import API
|
|
4
4
|
for the purpose of importing tasks from Asana Projects into ZenDesk
|
5
5
|
tickets.
|
6
6
|
|
7
|
+
[](http://badge.fury.io/rb/zensana)
|
8
|
+
|
7
9
|
## Installation
|
8
10
|
|
9
11
|
Add this line to your application's Gemfile:
|
@@ -27,12 +27,12 @@ module Zensana
|
|
27
27
|
end
|
28
28
|
|
29
29
|
desc 'convert PROJECT', 'Convert PROJECT tasks to ZenDesk tickets (exact ID or NAME required)'
|
30
|
-
option :attachments, type: 'boolean', aliases: '-a', default: true,
|
31
|
-
option :completed, type: 'boolean', aliases: '-c', default: false,
|
32
|
-
option :
|
33
|
-
|
34
|
-
option :
|
35
|
-
option :verified, type: 'boolean', aliases: '-v', default: true,
|
30
|
+
option :attachments, type: 'boolean', aliases: '-a', default: true, desc: 'download and upload any attachments'
|
31
|
+
option :completed, type: 'boolean', aliases: '-c', default: false, desc: 'include tasks that are completed'
|
32
|
+
option :global_tags, type: 'array', aliases: '-t', default: ['zensana'], desc: 'array of tag(s) to be applied to every ticket imported'
|
33
|
+
option :stories, type: 'boolean', aliases: '-s', default: true, desc: 'import stories as comments'
|
34
|
+
option :default_user, type: 'string', aliases: '-u', default: nil, desc: 'set a default user to assign to tickets'
|
35
|
+
option :verified, type: 'boolean', aliases: '-v', default: true, desc: '`false` will send email to zendesk users created'
|
36
36
|
def convert(project)
|
37
37
|
@asana_project = Zensana::Asana::Project.new(project)
|
38
38
|
say <<-BANNER
|
@@ -60,7 +60,11 @@ using options #{options}
|
|
60
60
|
# `section_tag_list` holds the tags for the last
|
61
61
|
# section task which are also added to tickets
|
62
62
|
#
|
63
|
-
tags = [ '
|
63
|
+
tags = [ 'imported' ]
|
64
|
+
options[:global_tags].each do |t|
|
65
|
+
tags << normalize(t)
|
66
|
+
end
|
67
|
+
puts tags
|
64
68
|
project_tags = [] << tags
|
65
69
|
section_tags = []
|
66
70
|
|
@@ -114,10 +118,10 @@ using options #{options}
|
|
114
118
|
if task.is_section?
|
115
119
|
say "\nProcessing section: #{task.section_name} "
|
116
120
|
section_tags.pop
|
117
|
-
section_tags.push task.tags <<
|
121
|
+
section_tags.push task.tags << normalize(task.section_name)
|
118
122
|
else
|
119
123
|
say "\nProcessing task: #{task.name} "
|
120
|
-
project_tags.push
|
124
|
+
project_tags.push normalize(task.tags)
|
121
125
|
|
122
126
|
if Zensana::Zendesk::Ticket.external_id_exists?(task.id)
|
123
127
|
say "\n >>> skip ticket creation, task already imported ", :yellow
|
@@ -156,9 +160,10 @@ using options #{options}
|
|
156
160
|
|
157
161
|
# if assignee is not an agent then leave unassigned
|
158
162
|
if (assignee_key = options[:default_user] || task.attributes['assignee'])
|
159
|
-
|
160
|
-
|
161
|
-
|
163
|
+
if (assignee = asana_to_zendesk_user(assignee_key, false))
|
164
|
+
unless assignee.attributes && assignee.attributes['role'] != 'end-user'
|
165
|
+
assignee = nil
|
166
|
+
end
|
162
167
|
end
|
163
168
|
end
|
164
169
|
|
@@ -176,12 +181,13 @@ using options #{options}
|
|
176
181
|
|
177
182
|
Task attributes: #{task.attributes}
|
178
183
|
EOF
|
179
|
-
:assignee_id => assignee ? assignee.id :
|
184
|
+
:assignee_id => assignee ? assignee.id : nil,
|
180
185
|
:created_at => task.created_at,
|
181
186
|
:tags => flatten_tags(project_tags, section_tags),
|
182
187
|
:comments => comments
|
183
188
|
)
|
184
189
|
ticket.import
|
190
|
+
say "\n >>> ticket imported "
|
185
191
|
end
|
186
192
|
|
187
193
|
# rinse and repeat for subtasks and their subtasks and ...
|
@@ -275,19 +281,19 @@ using options #{options}
|
|
275
281
|
tags.flatten.uniq
|
276
282
|
end
|
277
283
|
|
278
|
-
def
|
284
|
+
def normalize(thing)
|
279
285
|
case
|
280
286
|
when thing.is_a?(String)
|
281
|
-
|
287
|
+
normalize_it thing
|
282
288
|
when thing.is_a?(Array)
|
283
|
-
thing.map { |a|
|
289
|
+
thing.map { |a| normalize a }
|
284
290
|
else
|
285
|
-
raise ArgumentError, "I don't know how to
|
291
|
+
raise ArgumentError, "I don't know how to normalize instances of #{thing.class}"
|
286
292
|
end
|
287
293
|
end
|
288
294
|
|
289
|
-
def
|
290
|
-
thing.gsub(/(
|
295
|
+
def normalize_it(thing)
|
296
|
+
thing.gsub(/(\/| |-)+/,'_').downcase
|
291
297
|
end
|
292
298
|
end
|
293
299
|
end
|
@@ -53,8 +53,9 @@ module Zensana
|
|
53
53
|
|
54
54
|
def lookup_by_email(email)
|
55
55
|
unless (user = read_cache(email))
|
56
|
-
user = search("email:#{email}")
|
57
|
-
|
56
|
+
if (user = search("email:#{email}"))
|
57
|
+
update_cache user
|
58
|
+
end
|
58
59
|
end
|
59
60
|
user
|
60
61
|
end
|
@@ -78,7 +79,7 @@ module Zensana
|
|
78
79
|
end
|
79
80
|
|
80
81
|
def update_cache(user)
|
81
|
-
[
|
82
|
+
[ 'id', 'email' ].each do |attr|
|
82
83
|
key = user[attr].to_s
|
83
84
|
cache[key] = user
|
84
85
|
end
|
data/lib/zensana/version.rb
CHANGED