ruboty-redmine 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0b2671e9a1d54aeafe5c9df8e88156e3716918a8
4
- data.tar.gz: e1e43e99bcd7a837f29e2fc7f0deac7617516478
3
+ metadata.gz: 759100cbf0b5752c77f02070110eaf87240727f0
4
+ data.tar.gz: e486952501594a90cc2336d14ec24b5985c73c02
5
5
  SHA512:
6
- metadata.gz: 29137977f505ef31759525dc1bf4da1b29a87cbc9a947b6093198c5817cf4b66f4fc2c6f528920cc6630f24bd2b90a295d71fe21fabbe7f0a5369e280464a444
7
- data.tar.gz: 35d4e78d2ce5543feff16449ef6882af876ca79b7f1859be347f4d2d3793eeb6efddb233465d4b2d10e7c63e848f3966f51f41af630202b8c4fa0b0f2c903b16
6
+ metadata.gz: d0782d74534eb79f1b85031ae08c9dce588564bb50673784d45028c2137dd612b6cd71a8fdf9d7c254b74d0d7de50e37a475941c7d0897fbac251eb2bc43171a
7
+ data.tar.gz: 096427b5f830ba198df16fddb8d63ee90c5a4a8cd3be207be6d3a9247fe9d926e63bd22ba0797fd3a27cacab70d5d23fcde4ecd615d72fe86e32c50550ea90be
@@ -40,13 +40,13 @@ module Ruboty
40
40
  )
41
41
 
42
42
  on(
43
- /redmine stop assigning to (?<redmine_id>\d+)/,
43
+ /redmine stop assigning to (?<user>.+)/,
44
44
  name: 'stop_assigning',
45
45
  description: 'Stop assigning issues to the user',
46
46
  )
47
47
 
48
48
  on(
49
- /redmine start assigning to (?<redmine_id>\d+)/,
49
+ /redmine start assigning to (?<user>.+)/,
50
50
  name: 'start_assigning',
51
51
  description: 'Start assigning issues to the user',
52
52
  )
@@ -157,13 +157,23 @@ module Ruboty
157
157
  end
158
158
 
159
159
  def stop_assigning(message)
160
- u = message[:redmine_id]
160
+ u = username_to_redmine_id(message[:user])
161
+ unless u
162
+ message.reply("#{message[:user]} is not found")
163
+ return
164
+ end
165
+
161
166
  absent_users << u.to_i
162
167
  message.reply("Stop assigning issues to #{u}")
163
168
  end
164
169
 
165
170
  def start_assigning(message)
166
- u = message[:redmine_id]
171
+ u = username_to_redmine_id(message[:user])
172
+ unless u
173
+ message.reply("#{message[:user]} is not found")
174
+ return
175
+ end
176
+
167
177
  absent_users.delete(u.to_i)
168
178
  message.reply("Start assigning issues to #{u}")
169
179
  end
@@ -174,6 +184,19 @@ module Ruboty
174
184
 
175
185
  private
176
186
 
187
+ def username_to_redmine_id(username)
188
+ case username
189
+ when /\A\d+\z/
190
+ username.to_i # redmine_id
191
+ else
192
+ u = users.find do |u|
193
+ u['chat_name'] == username
194
+ end
195
+
196
+ u && u['redmine_id']
197
+ end
198
+ end
199
+
177
200
  def redmine
178
201
  @redmine ||= Ruboty::Redmine::Client.new(
179
202
  ENV['REDMINE_URL'],
@@ -1,5 +1,5 @@
1
1
  module Ruboty
2
2
  module Redmine
3
- VERSION = "0.1.3"
3
+ VERSION = "0.1.4"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruboty-redmine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryota Arai