lita-rally 0.3.4 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -0
- data/lib/lita/handlers/rally.rb +85 -1
- data/lita-rally.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3cd89121e0d94dbb82717bdf87a5d73bc5e30383
|
4
|
+
data.tar.gz: f881f60bb78e08338e42f4f36cd95f7f17b2aa03
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cff30b41736dffc5f3b7a48c8aed21ae80607e914e2e0b0d9ec978bdd764245da589789a2fedde82e21b2823a02f182a0b03e1f7cc8e385c544e500a51cd4f31
|
7
|
+
data.tar.gz: bfd3972bd78c16100b87a52a7ed0474621e682664c428bb343ffaa31d40bba05de5a83c7df8b1dd96a1bb4647b2f800f4a88c7f79776835d647c3d0c6a3d7ac6
|
data/README.md
CHANGED
@@ -49,6 +49,13 @@ term>" in <name|description>
|
|
49
49
|
```
|
50
50
|
Find object with terms
|
51
51
|
|
52
|
+
```
|
53
|
+
lita rally <start|pause|finish|accept|backlog> <FormattedID>
|
54
|
+
```
|
55
|
+
|
56
|
+
Move object between schedule states: **start** -> **In-Progress**, **pause** ->
|
57
|
+
**Defined**, **finish** -> **Completed**, **backlog** -> **Backlog**.
|
58
|
+
|
52
59
|
## License
|
53
60
|
|
54
61
|
[MIT](http://opensource.org/licenses/MIT)
|
data/lib/lita/handlers/rally.rb
CHANGED
@@ -99,6 +99,52 @@ module Lita
|
|
99
99
|
'in <name|description>' => 'Find the story or defect'
|
100
100
|
})
|
101
101
|
|
102
|
+
route(/^rally (start|pause|finish|accept|backlog) ([[:alpha:]]+)(\d+)/,
|
103
|
+
:rally_mark, command: true, help: {
|
104
|
+
'rally <start|pause|finish|accept|backlog> <formattedID>' =>
|
105
|
+
'mark issue in-progress'
|
106
|
+
})
|
107
|
+
|
108
|
+
def rally_mark(response)
|
109
|
+
action = response.matches[0][0]
|
110
|
+
type = response.matches[0][1].downcase
|
111
|
+
id = response.matches[0][2]
|
112
|
+
|
113
|
+
schedule_state =
|
114
|
+
case action
|
115
|
+
when 'start'
|
116
|
+
'In-Progress'
|
117
|
+
when 'pause'
|
118
|
+
'Defined'
|
119
|
+
when 'finish'
|
120
|
+
'Completed'
|
121
|
+
when 'accept'
|
122
|
+
'Accepted'
|
123
|
+
when 'backlog'
|
124
|
+
'Backlog'
|
125
|
+
end
|
126
|
+
|
127
|
+
state =
|
128
|
+
case action
|
129
|
+
when 'start','pause','backlog'
|
130
|
+
'Open'
|
131
|
+
when 'finish'
|
132
|
+
'Fixed'
|
133
|
+
when 'accept'
|
134
|
+
'Closed'
|
135
|
+
end
|
136
|
+
|
137
|
+
response.reply(update_object(type, id, 'ScheduleState', schedule_state))
|
138
|
+
|
139
|
+
response.reply(update_object(type, id, 'State', state))
|
140
|
+
|
141
|
+
update_object(type, id, 'Notes',
|
142
|
+
"<br />Marked #{state} by #{response.user.name} on " \
|
143
|
+
"#{Time.now.strftime('%Y-%m-%dT%H:%M:%S%z')}",
|
144
|
+
append: true)
|
145
|
+
|
146
|
+
end
|
147
|
+
|
102
148
|
def rally_show(response)
|
103
149
|
type = response.matches[0][0].downcase
|
104
150
|
id = response.matches[0][1]
|
@@ -126,6 +172,8 @@ module Lita
|
|
126
172
|
private
|
127
173
|
|
128
174
|
def get_rally_api
|
175
|
+
@rally if instance_variable_defined?('@rally')
|
176
|
+
|
129
177
|
rally_api_config = {
|
130
178
|
base_url: 'https://rally1.rallydev.com/slm',
|
131
179
|
username: config.username,
|
@@ -133,7 +181,7 @@ module Lita
|
|
133
181
|
version: config.api_version
|
134
182
|
}
|
135
183
|
|
136
|
-
RallyAPI::RallyRestJson.new(rally_api_config)
|
184
|
+
@rally = RallyAPI::RallyRestJson.new(rally_api_config)
|
137
185
|
end
|
138
186
|
|
139
187
|
def validate_release(rally, release)
|
@@ -189,6 +237,42 @@ module Lita
|
|
189
237
|
end
|
190
238
|
end
|
191
239
|
|
240
|
+
def update_object(type, id, attribute, value, options = {})
|
241
|
+
rally = get_rally_api
|
242
|
+
return 'Object not found' unless obj = get_by_formatted_id(type, id)
|
243
|
+
|
244
|
+
if options[:append]
|
245
|
+
fields = {attribute => obj.read[attribute] + value}
|
246
|
+
else
|
247
|
+
fields = {attribute => value}
|
248
|
+
end
|
249
|
+
|
250
|
+
updated = rally.update(@@key_map[type][:name],
|
251
|
+
"FormattedID|#{type}#{id}",
|
252
|
+
fields)
|
253
|
+
"#{attribute} of #{type.upcase}#{id} has been updated to #{value}"
|
254
|
+
rescue Exception => e
|
255
|
+
"Exception during update: #{e}"
|
256
|
+
end
|
257
|
+
|
258
|
+
def get_by_formatted_id(type, id)
|
259
|
+
rally = get_rally_api
|
260
|
+
|
261
|
+
raise 'No such object' unless @@key_map[type]
|
262
|
+
|
263
|
+
query = RallyAPI::RallyQuery.new()
|
264
|
+
query.type = @@key_map[type][:name]
|
265
|
+
query.query_string = "(FormattedID = \"#{type}#{id}\")"
|
266
|
+
|
267
|
+
result = rally.find(query)
|
268
|
+
|
269
|
+
raise 'No such object' if result.count < 1
|
270
|
+
|
271
|
+
result[0]
|
272
|
+
rescue
|
273
|
+
nil
|
274
|
+
end
|
275
|
+
|
192
276
|
def get_rally_object(type, id)
|
193
277
|
rally = get_rally_api
|
194
278
|
|
data/lita-rally.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lita-rally
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard Li
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-09-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lita
|