bender-bot 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/lib/bender/bot.rb +56 -22
  4. data/lib/bender/metadata.rb +15 -13
  5. metadata +30 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7c561e6f44af4f398b20ae38a1c8b506a3318a4b
4
- data.tar.gz: 736e2de7ab537a0d070b9d65fc06f3a1831c1bc6
3
+ metadata.gz: 6194220e4bd4031c46110f96d78da9826c16cf93
4
+ data.tar.gz: 90d5e15752537eec532c8e16831b522d6cf11b49
5
5
  SHA512:
6
- metadata.gz: fc3a5c412677a9dbe0d3bdf61c7fecacff394636f7ecf9ca3c451964905c163ae2a7377a13a66215c8700dd4687a378c893c0b2e069826dc3d609c49c2dc9e96
7
- data.tar.gz: 13229d4431b57107fbf104d598ff36d645db1d96086e9e5f9930eafd48eb6361f27ed1e18d938775fa2668949631ee35c367e2c7e4aabd7c50bb5fec9f489bd6
6
+ metadata.gz: 1928c523bb4dc16565342b5ef31df04cd636db1c59b4732cf7f5d6b8d676e291600dbefe31fac0cb5172196301773c26600851f7233b4c033dfd059eab2ecb4e
7
+ data.tar.gz: 3b1ff85103c748808b1ef187628ba62dc719f0e20ebfb794ed263fcf9df3ad1be50990dccbea77df03abef3a60e9fb674d1623a25d0d07ab70efd18de4376025
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.2
1
+ 0.0.3
@@ -1,4 +1,6 @@
1
1
  require 'thread'
2
+ require 'date'
3
+ require 'time'
2
4
 
3
5
  require 'robut'
4
6
  require 'robut/storage/yaml_store'
@@ -26,14 +28,19 @@ class BenderBot
26
28
 
27
29
  JARO = FuzzyStringMatch::JaroWinkler.create :native
28
30
 
29
- SHOW_FIELDS = %w[
30
- summary
31
- description
32
- priority
33
- status
34
- created
35
- updated
36
- ]
31
+ SHOW_FIELDS = {
32
+ 'summary' => 'Summary',
33
+ 'description' => 'Description',
34
+ 'customfield_11250' => 'Severity',
35
+ 'customfield_11251' => 'Impact Started',
36
+ 'customfield_11252' => 'Impact Ended',
37
+ 'customfield_11253' => 'Reported By',
38
+ 'customfield_11254' => 'Services Affected',
39
+ 'customfield_11255' => 'Cause',
40
+ 'status' => 'Status',
41
+ 'created' => 'Created',
42
+ 'updated' => 'Updated'
43
+ }
37
44
 
38
45
 
39
46
  def handle time, sender, message
@@ -51,16 +58,17 @@ class BenderBot
51
58
  u = user_where(name: $1) || user_where(nick: $1)
52
59
  reply '%s: %s (%s)' % [ u[:nick], u[:name], u[:email] ]
53
60
 
54
- when /^\s*\?incident\s*$/
61
+ when /^\s*\?inc\s*$/
55
62
  reply [
56
- '?icident - This help text',
57
- '?incidents - List open incidents',
58
- '?incident NUM - Show incident',
59
- '?incident NUM FIELD - Show incident field',
60
- '?incident SUMMARY - File a new incident'
63
+ '?inc - This help text',
64
+ '/inc - List open incidents',
65
+ '/inc NUM - Show incident details',
66
+ '/inc close NUM - Close an indident',
67
+ '/inc SEVERITY SUMMARY - File a new incident',
68
+ '/inc summary - Summarize recent indicents'
61
69
  ].join("\n")
62
70
 
63
- when /^\s*\?incidents\s*$/
71
+ when /^\s*\/inc\s*$/
64
72
  refresh_incidents
65
73
 
66
74
  is = store['incidents'].map do |i|
@@ -69,17 +77,22 @@ class BenderBot
69
77
 
70
78
  reply is
71
79
 
72
- when /^\s*\?incident\s+(\d+)\s*$/
80
+ when /^\s*\/inc\s+summary\s*$/
81
+ # TODO
82
+ reply "Sorry, I haven't been programmed for that yet!"
83
+
84
+ when /^\s*\/inc\s+(\d+)\s*$/
73
85
  refresh_incidents
74
86
  incident = store['incidents'].select { |i| i['num'] == $1 }.first
75
87
 
76
- fields = SHOW_FIELDS - %w[ summary ]
88
+ fields = SHOW_FIELDS.keys - %w[ summary ]
77
89
 
78
90
  i = fields.map do |f|
79
91
  val = incident['fields'][f]
80
92
  if val
81
- val = val.is_a?(Hash) ? val['name'] : val
82
- '%s: %s' % [ f, val ]
93
+ key = SHOW_FIELDS[f]
94
+ val = normalize_value val
95
+ '%s: %s' % [ key, val ]
83
96
  end
84
97
  end.compact
85
98
 
@@ -89,14 +102,18 @@ class BenderBot
89
102
  i.join("\n")
90
103
  ]
91
104
 
92
- when /^\s*\?incident\s+(\d+)\s+(.*?)\s*$/
105
+ when /^\s*\/inc\s+close\s+(\d+)\s*$/
106
+ # TODO
107
+ reply "Sorry, I haven't been programmed for that yet!"
108
+
109
+ when /^\s*\/inc\s+(\d+)\s+(.*?)\s*$/
93
110
  refresh_incidents
94
111
  incident = store['incidents'].select { |i| i['num'] == $1 }.first
95
112
  val = incident['fields'][$2]
96
113
  val = val.is_a?(Hash) ? val['name'] : val
97
114
  reply val
98
115
 
99
- when /^\s*\?incident\s+(.*?)\s*$/
116
+ when /^\s*\/inc\s+(.*?)\s*$/
100
117
  user = user_where name: sender
101
118
  data = {
102
119
  fields: {
@@ -144,7 +161,7 @@ private
144
161
  req_path = '/rest/api/2/search'
145
162
  req_params = QueryParams.encode \
146
163
  jql: "project = #{options.jira_project} AND resolution = Unresolved ORDER BY created ASC, priority DESC",
147
- fields: SHOW_FIELDS.join(','),
164
+ fields: SHOW_FIELDS.keys.join(','),
148
165
  startAt: 0,
149
166
  maxResults: 1_000_000
150
167
 
@@ -183,4 +200,21 @@ private
183
200
  end
184
201
 
185
202
 
203
+ def normalize_value val
204
+ case val
205
+ when Hash
206
+ val['name'] || val['value'] || val
207
+ when Array
208
+ val.map { |v| v['value'] }.join(', ')
209
+ when /^\d{4}\-\d{2}\-\d{2}/
210
+ '%s (%s)' % [ val, normalize_date(val) ]
211
+ else
212
+ val
213
+ end
214
+ end
215
+
216
+ def normalize_date val
217
+ Time.parse(val).utc.iso8601(3).sub(/Z$/, 'UTC')
218
+ end
219
+
186
220
  end
@@ -6,34 +6,36 @@ module Bender
6
6
  VERSION = File.read(File.join(ROOT, 'VERSION')).strip
7
7
 
8
8
  # We don't really do all that much, be humble
9
- SUMMARY = 'Yet another HipChat bot'
9
+ SUMMARY = 'Yet another HipChat bot'
10
10
 
11
11
  # Your benevolent dictator for life
12
- AUTHOR = 'Sean Clemmer'
12
+ AUTHOR = 'Sean Clemmer'
13
13
 
14
14
  # Turn here to strangle your dictator
15
- EMAIL = 'sclemmer@bluejeans.com'
15
+ EMAIL = 'sclemmer@bluejeans.com'
16
16
 
17
17
  # Like the MIT license, but even simpler
18
- LICENSE = 'ISC'
18
+ LICENSE = 'ISC'
19
19
 
20
20
  # If you really just can't get enough
21
21
  HOMEPAGE = 'https://github.com/sczizzo/bender'
22
22
 
23
23
  # Bundled extensions
24
- TRAVELING_RUBY_VERSION = '20150210-2.2.0'
24
+ TRAVELING_RUBY_VERSION = '20150517-2.2.2'
25
+ JSON_VERSION = '1.8.2'
25
26
  THIN_VERSION = '1.6.3'
27
+ FFI_VERSION = '1.9.6'
26
28
  EM_VERSION = '1.0.4'
27
29
 
28
30
  # Every project deserves its own ASCII art
29
- ART = <<-'EOART' % VERSION
30
- ,, ,,
31
- *MM `7MM
32
- MM MM
33
- MM,dMMb. .gP"Ya `7MMpMMMb. ,M""bMM .gP"Ya `7Mb,od8
34
- MM `Mb ,M' Yb MM MM ,AP MM ,M' Yb MM' "'
35
- MM M8 8M"""""" MM MM 8MI MM 8M"""""" MM
36
- MM. ,M9 YM. , MM MM `Mb MM YM. , MM
31
+ ART = <<-'EOART' % VERSION
32
+ ,, ,,
33
+ *MM `7MM
34
+ MM MM
35
+ MM,dMMb. .gP"Ya `7MMpMMMb. ,M""bMM .gP"Ya `7Mb,od8
36
+ MM `Mb ,M' Yb MM MM ,AP MM ,M' Yb MM' "'
37
+ MM M8 8M"""""" MM MM 8MI MM 8M"""""" MM
38
+ MM. ,M9 YM. , MM MM `Mb MM YM. , MM
37
39
  P^YbmdP' `Mbmmd'.JMML JMML.`Wbmd"MML.`Mbmmd'.JMML. v%s
38
40
  EOART
39
41
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bender-bot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean Clemmer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-24 00:00:00.000000000 Z
11
+ date: 2015-08-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -136,6 +136,34 @@ dependencies:
136
136
  - - '='
137
137
  - !ruby/object:Gem::Version
138
138
  version: 1.6.3
139
+ - !ruby/object:Gem::Dependency
140
+ name: json
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - '='
144
+ - !ruby/object:Gem::Version
145
+ version: 1.8.2
146
+ type: :runtime
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - '='
151
+ - !ruby/object:Gem::Version
152
+ version: 1.8.2
153
+ - !ruby/object:Gem::Dependency
154
+ name: ffi
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - '='
158
+ - !ruby/object:Gem::Version
159
+ version: 1.9.6
160
+ type: :runtime
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - '='
165
+ - !ruby/object:Gem::Version
166
+ version: 1.9.6
139
167
  description: Yet another HipChat bot.
140
168
  email: sclemmer@bluejeans.com
141
169
  executables: