lita-rally 0.4.0 → 0.5.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 +19 -0
- data/lib/lita/handlers/rally.rb +91 -0
- 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: ff72b0fbfa6e11ab442f696236e705c0429846e7
|
4
|
+
data.tar.gz: 363ebeef8d49d31c883ede14bae87e97e1061672
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0a56efa23c18ce9a1a850b6ab52ecd00858b1933dc47486cd8423be250690b7aed1d2c0a65a77cd1ee95176292f31e17ab2cbd7cd8162e483d5c1ffe878d073d
|
7
|
+
data.tar.gz: a984803b293ed835caa19e1f6126bdff29bd5b755207a4accac6abc81d480d8689d54debed9bfd6224d893d3f2fd2f6ebdb1069f0c6ec5d9682da3de6d906e86
|
data/README.md
CHANGED
@@ -24,6 +24,7 @@ gem "lita-rally"
|
|
24
24
|
**Optional:**
|
25
25
|
|
26
26
|
```config.handlers.rally.api_version``` - API version, default 'v2.0'
|
27
|
+
```config.handlers.rally.read_only``` - disable commands that modifies objects
|
27
28
|
|
28
29
|
|
29
30
|
## Usage
|
@@ -49,6 +50,24 @@ term>" in <name|description>
|
|
49
50
|
```
|
50
51
|
Find object with terms
|
51
52
|
|
53
|
+
```
|
54
|
+
lita rally find defects <created|closed> between <date1> and <date2>
|
55
|
+
```
|
56
|
+
|
57
|
+
Find rally defects created/closed in certain date range
|
58
|
+
|
59
|
+
```
|
60
|
+
lita rally find defects <created|closed> in last <number> days
|
61
|
+
```
|
62
|
+
|
63
|
+
Find rally defects created/closed in last few days
|
64
|
+
|
65
|
+
```
|
66
|
+
lita rally query <type> <query_string>
|
67
|
+
```
|
68
|
+
|
69
|
+
Execute raw Rally API query with <type> and <query_string>
|
70
|
+
|
52
71
|
```
|
53
72
|
lita rally <start|pause|finish|accept|backlog> <FormattedID>
|
54
73
|
```
|
data/lib/lita/handlers/rally.rb
CHANGED
@@ -78,6 +78,7 @@ module Lita
|
|
78
78
|
config :username, type: String, required: true
|
79
79
|
config :password, type: String, required: true
|
80
80
|
config :api_version, type: String, default: 'v2.0'
|
81
|
+
config :read_only, type: Object, default: false
|
81
82
|
|
82
83
|
route(/^rally me ([[:alpha:]]+)(\d+)/, :rally_show, command: true, help: {
|
83
84
|
'rally me <identifier>' => 'Show me that rally object'
|
@@ -105,7 +106,70 @@ module Lita
|
|
105
106
|
'mark issue in-progress'
|
106
107
|
})
|
107
108
|
|
109
|
+
route(/^rally query (\w+)\s+(.*)$/,
|
110
|
+
:rally_query_raw, command: true, help: { 'rally query <type> <query>' =>
|
111
|
+
'execute raw query on rally on type of object'
|
112
|
+
})
|
113
|
+
|
114
|
+
route(/^rally find defect[s]{0,1} (created|closed) between (.+) and (.+)/,
|
115
|
+
:rally_find_defect_range, command: true, help: {
|
116
|
+
'rally find defect <created|closed> between <date> and <date>' =>
|
117
|
+
'Find defect objects in date range'
|
118
|
+
})
|
119
|
+
|
120
|
+
route(
|
121
|
+
/^rally find defect[s]{0,1} (created|closed) in last (\d+) day[s]{0,1}/,
|
122
|
+
:rally_find_defect_back, command: true, help: {
|
123
|
+
'rally find defect <created|closed> in last <number> days' =>
|
124
|
+
'Find defect objects in date range'
|
125
|
+
})
|
126
|
+
|
127
|
+
def rally_find_defect_back(response)
|
128
|
+
field =
|
129
|
+
response.matches[0][0] == 'created' ? 'CreationDate' : 'ClosedDate'
|
130
|
+
dt1 = (Time.now.to_date - response.matches[0][1].to_i).to_datetime
|
131
|
+
dt2 = Time.now.to_datetime.to_s
|
132
|
+
|
133
|
+
response.reply(rally_find_defect_by_date(field, dt1, dt2))
|
134
|
+
end
|
135
|
+
|
136
|
+
def rally_find_defect_range(response)
|
137
|
+
field =
|
138
|
+
response.matches[0][0] == 'created' ? 'CreationDate' : 'ClosedDate'
|
139
|
+
dt1 = Time.parse(response.matches[0][1]).to_datetime.to_s
|
140
|
+
dt2 = Time.parse(response.matches[0][2]).to_datetime.to_s
|
141
|
+
|
142
|
+
response.reply(rally_find_defect_by_date(field, dt1, dt2))
|
143
|
+
end
|
144
|
+
|
145
|
+
def rally_query_raw(response)
|
146
|
+
rally = get_rally_api
|
147
|
+
|
148
|
+
query = RallyAPI::RallyQuery.new()
|
149
|
+
query.type = response.matches[0][0]
|
150
|
+
query.query_string = response.matches[0][1]
|
151
|
+
|
152
|
+
result = rally.find(query)
|
153
|
+
|
154
|
+
if result.count < 1
|
155
|
+
response.reply("No object found")
|
156
|
+
else
|
157
|
+
response.reply(result.inject("") do |c,r|
|
158
|
+
r.read
|
159
|
+
"#{c}#{r['FormattedID']} - #{r['Name']}\n"
|
160
|
+
end)
|
161
|
+
end
|
162
|
+
rescue Exception => e
|
163
|
+
response.reply("Error executing query: #{e}")
|
164
|
+
end
|
165
|
+
|
108
166
|
def rally_mark(response)
|
167
|
+
if config.read_only
|
168
|
+
response.reply('Rally plugin is operating in Read-Only mode, ' \
|
169
|
+
'ask your chat-ops admin to disable it.')
|
170
|
+
return
|
171
|
+
end
|
172
|
+
|
109
173
|
action = response.matches[0][0]
|
110
174
|
type = response.matches[0][1].downcase
|
111
175
|
id = response.matches[0][2]
|
@@ -237,6 +301,33 @@ module Lita
|
|
237
301
|
end
|
238
302
|
end
|
239
303
|
|
304
|
+
def rally_find_defect_by_date(field, dt1, dt2)
|
305
|
+
rally = get_rally_api
|
306
|
+
|
307
|
+
query = RallyAPI::RallyQuery.new()
|
308
|
+
query.type = 'defect'
|
309
|
+
query.query_string =
|
310
|
+
"((#{field} >= \"#{dt1}\") AND "\
|
311
|
+
"(#{field} <= \"#{dt2}\"))"
|
312
|
+
|
313
|
+
result = rally.find(query)
|
314
|
+
|
315
|
+
if result.count < 1
|
316
|
+
return "No defect found"
|
317
|
+
else
|
318
|
+
m_result =
|
319
|
+
result.map do |r|
|
320
|
+
r.read
|
321
|
+
[r['Project'].name,r['FormattedID'], r['Name']]
|
322
|
+
end
|
323
|
+
m_result.sort_by {|r| r[0]}.inject("") do |c,r|
|
324
|
+
"#{c}[#{r[0]}] #{r[1]} - #{r[2]}\n"
|
325
|
+
end
|
326
|
+
end
|
327
|
+
rescue Exception => e
|
328
|
+
"Error executing query: #{e}"
|
329
|
+
end
|
330
|
+
|
240
331
|
def update_object(type, id, attribute, value, options = {})
|
241
332
|
rally = get_rally_api
|
242
333
|
return 'Object not found' unless obj = get_by_formatted_id(type, id)
|
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.5.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-09-
|
11
|
+
date: 2015-09-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lita
|