lita-slack-standup 0.1.1 → 0.2.0

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: 372b83c82f687449d7f5fd37fb3def9854f62c58
4
- data.tar.gz: dafa991a290ec6cecf33845d996aae15bf9f596d
3
+ metadata.gz: 88e73917d16c70d9f71ad82a693d952710200309
4
+ data.tar.gz: 593553562ef488af54ccedcbc829535c9edb0f1d
5
5
  SHA512:
6
- metadata.gz: 92c6ea2b8b66cc07d86245e4fc6e74caba356e851011864b462db5e28898fe0879e174709a68a232ad27ef8f51135e1ce8c41e8800cbd92eb5be5f7a383d7e75
7
- data.tar.gz: 476920eb200651d8e6f3b42628a800ed2d25c481aed1542e97f47f858ce914fcce59a8562806bf73bd96c2f569f051a05011e891bbf08e5926c0d2790db6d652
6
+ metadata.gz: 2df34d19c44e6fa3b9005c8954e71454f5818dceedcc335b065353bc9e20e109a620ecc326cb343e33364e381fa152247d196f7c890f92bbb91ee5f8f3ae84ca
7
+ data.tar.gz: 1426c5fd4cb1302d7ec8d7491ca0e1698bc9b329da552fe1e985d061a65106726c24120fe1795b34c96b98d1aaf6811aa610c7d44a3508420f658520c0556c36
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # lita-lack-tandup
2
2
 
3
- lita-slack-standup is a gem for Lita (https://www.lita.io/), a chat bot written in ruby.
3
+ lita-slack-standup is a gem for Lita (https://www.lita.io/), a chat bot written in ruby.
4
4
  It handles standup meetings on slack (the sentences are in french for now).
5
5
 
6
6
  ## Installation
@@ -16,7 +16,6 @@ gem "lita-standup"
16
16
  In your lita configuration file (lita_config.rb), add the lines :
17
17
  ``` ruby
18
18
  Lita.congifure do |config|
19
- ## standup
20
19
  config.handlers.slack_standup.channel = ENV['STANDUP_CHANNEL']
21
20
  end
22
21
  ```
@@ -25,16 +24,16 @@ And set the environment variable STANDUP_CHANNEL, with the name of the channel w
25
24
 
26
25
  ## Test
27
26
 
28
- We used VCR generated by real standups on slack.
29
- We had to delete them for privacy reasons.
27
+ We used VCR generated by real standups on slack. We had to delete them for privacy reasons.
28
+ To rerun the tests and recreate some VCR, you need to bundle the gem into a lita bot.
30
29
 
31
30
  ## Usage
32
31
 
33
- - !start standup : launches the standup, prints the standups already filled and asks for someone else to report
34
- - !next standup : skips the current user and asks the next user to do his standup report
35
- - !standup <some standup report> : saves your standup. If you do it before the start of the standup, you won't be asked to report. The bot will displays your standup in your stead
36
- - !ignore <some user> : ignores an user for the standups
37
- - !unignore <some user> : unignores an user
38
- - !list ignore : list all ignored users
39
-
32
+ - !standup start : launches the standup, prints the standups already filled and asks for someone else to report
33
+ - !standup next : skips the current user and asks the next user to do his standup report
34
+ - !standup report <some standup report> : saves your standup. If you do it before the start of the standup, you won't be asked to report. The bot will displays your standup in your stead
35
+ - !standup ignore <some user> : ignores an user for the standups
36
+ - !standup unignore <some user> : unignores an user
37
+ - !standup list : list all ignored users
38
+
40
39
  The standup stops when everyone has done his report or has been skipped.
@@ -5,82 +5,96 @@ module Lita
5
5
 
6
6
  config :channel
7
7
 
8
- route(/^start\s*standup?/, :start_standup, command: true, help: {"start standup" => "Lance le standup." })
8
+ route(/^standup\s*start?/, :standup_start, command: true, help: {"standup start" => "Lance le standup." })
9
9
 
10
- def start_standup(message=nil)
10
+ def standup_start(message=nil)
11
11
  in_standup.value = 'true'
12
12
  setup_redis_objects
13
13
  send_message(config.channel, 'Hello <!channel> ! Le standup va commencer : )')
14
14
  prewritten_standups_summary
15
- next_standup
15
+ standup_next
16
16
  end
17
17
 
18
- route(/^standup\s*(.*)$/, :standup, command: true, help: {"standup texte" => "Permet d'écrire son standup à l'avance ou pendant le tour d'un autre."})
18
+ route(/^standup\s*report\s*(.*)$/, :standup_report, command: true, help: {"standup report TEXT" => "Permet d'écrire son standup à l'avance ou pendant le tour d'un autre."})
19
19
 
20
- def standup(message)
20
+ def standup_report(message)
21
21
  setup_redis_objects
22
22
  save_standup message
23
23
  message.reply("Ton standup est enregistré. Merci :)")
24
24
  end
25
25
 
26
- route(/^next\s*standup?/, :next_standup, command: true, help: {"next standup" => "Passe à l'utilisateur suivant et considère le standup précédent comme fait."})
26
+ route(/^standup\s*next?/, :standup_next, command: true, help: {"standup next" => "Passe à l'utilisateur suivant et considère le standup précédent comme fait."})
27
27
 
28
- def next_standup(message=nil)
29
- if in_standup.value == 'true'
30
- if standup_members.none? { |user, standup| standup.empty? }
31
- end_standup
32
- else
33
- next_attendee = select_next_standup
34
- send_message(config.channel,"Bonjour <@#{next_attendee}> ! C'est à ton tour de parler.")
35
- fill_standup(next_attendee)
36
- end
28
+ def standup_next(message=nil)
29
+ setup_redis_objects
30
+ return unless standup_check?
31
+
32
+ if standup_members.none? { |user, standup| standup.empty? }
33
+ standup_end
37
34
  else
38
- send_message(config.channel,"La commande n'est pas disponible en dehors d'un standup.")
35
+ next_attendee = select_next_standup
36
+ send_message(config.channel,"Bonjour <@#{next_attendee}> ! C'est à ton tour de parler.")
37
+ fill_standup(next_attendee)
39
38
  end
40
39
  end
41
40
 
42
41
  def reminder
42
+ setup_redis_objects
43
43
  standup_members.each do |user, standup|
44
44
  send_message("@#{user}","Bonsoir <@#{user}> ! Tu peux donner ton standup pour demain. !standup 3615mavie") if standup.empty?
45
45
  end
46
46
  end
47
47
 
48
- route(/^ignore\s*(.*)$/, :ignore, command: true, help: {"ignore nom" => "Retire un utilisateur de la liste des personnes ayant à faire le standup"})
48
+ route(/^standup*\signore\s*(.*)$/, :standup_ignore, command: true, help: {"standup ignore USER" => "Retire un utilisateur de la liste des personnes ayant à faire le standup"})
49
49
 
50
- def ignore(message)
50
+ def standup_ignore(message)
51
+ setup_redis_objects
51
52
  user = message.matches[0][0].gsub('@','')
53
+
52
54
  unless ignored_members.include? user
53
55
  ignored_members << user
54
56
  standup_members.delete(user)
55
57
  end
58
+
56
59
  message.reply("<@#{user}> est désormais ignoré jusqu'à nouvel ordre.")
57
60
  end
58
61
 
59
- route(/^unignore\s*(.*)$/, :unignore, command: true, help: {"unignore nom" => "Remet l'utilisateur dans la liste des personnes participant aux standups."})
62
+ route(/^standup*\sunignore\s*(.*)$/, :standup_unignore, command: true, help: {"standup unignore USER" => "Remet l'utilisateur dans la liste des personnes participant aux standups."})
60
63
 
61
- def unignore(message)
64
+ def standup_unignore(message)
65
+ setup_redis_objects
62
66
  user = message.matches[0][0].gsub('@','')
67
+
63
68
  if ignored_members.include? user
64
69
  ignored_members.delete(user)
65
70
  standup_members[user] = ''
66
71
  end
72
+
67
73
  message.reply("<@#{user}> est à nouveau inclus dans les standups.")
68
74
  end
69
75
 
70
- route(/^list\s*ignore?/, :list_ignore, command: true, help: {"list ignore" => "Liste les utilisateurs ignorés."})
76
+ route(/^standup\s*list?/, :standup_list, command: true, help: {"standup list" => "Liste les utilisateurs ignorés."})
71
77
 
72
- def list_ignore(message)
73
- reply = "Utilisateurs ignorés : "
74
- ignored_members.each do |user|
75
- reply += "#{user} "
76
- end
77
- message.reply(reply)
78
+ def standup_list(message)
79
+ setup_redis_objects
80
+ message.reply(
81
+ ignored_members.inject("Utilisateurs ignorés : ") do |reply, user|
82
+ reply += "#{user} "
83
+ end
84
+ )
78
85
  end
79
86
 
80
87
  private
81
88
 
89
+ def standup_check?
90
+ if in_standup.value != 'true'
91
+ send_message(config.channel,"La commande n'est pas disponible en dehors d'un standup.")
92
+ end
93
+ in_standup.value == 'true'
94
+ end
95
+
82
96
  def in_standup
83
- @in_standup ||= Redis::Value.new('in_standup', redis, marshal: true)
97
+ @in_standup ||= Redis::Value.new('in_standup', redis)
84
98
  end
85
99
 
86
100
  def ignored_members
@@ -88,8 +102,8 @@ module Lita
88
102
  end
89
103
 
90
104
  def setup_redis_objects
91
- update_ids_to_members if ids_to_members.empty?
92
- update_standup_members if standup_members.empty?
105
+ update_ids_to_members if ids_to_members.empty?
106
+ update_standup_members if standup_members.empty?
93
107
  end
94
108
 
95
109
  def standup_members
@@ -97,10 +111,9 @@ module Lita
97
111
  end
98
112
 
99
113
  def retrieve_channel
100
- slack_client.channels_list['channels'].
101
- find do |channel|
102
- "##{ channel['name'] }" == config.channel
103
- end
114
+ slack_client.channels_list['channels'].find do |channel|
115
+ "##{ channel['name'] }" == config.channel
116
+ end
104
117
  end
105
118
 
106
119
  def fill_standup_members(members_list)
@@ -129,7 +142,7 @@ module Lita
129
142
 
130
143
  def prewritten_standups_summary
131
144
  standup_members.each do |user, standup|
132
- display_standup(user, standup) unless standup.empty?
145
+ display_standup(user, standup) unless standup.empty?
133
146
  end
134
147
  end
135
148
 
@@ -151,14 +164,14 @@ module Lita
151
164
  standup_members.select{ |key,value| value.empty? }.first.first
152
165
  end
153
166
 
154
- def end_standup
167
+ def standup_end
155
168
  in_standup.value = 'false'
156
169
 
157
170
  send_message(config.channel, "Et voilà ! C'est bon pour aujourd'hui. Merci tout le monde :parrot:")
171
+
158
172
  update_standup_members
159
173
  update_ids_to_members
160
174
  end
161
-
162
175
  end
163
176
  Lita.register_handler(SlackStandup)
164
177
  end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "lita-slack-standup"
3
- spec.version = "0.1.1"
3
+ spec.version = "0.2.0"
4
4
  spec.authors = ["Sybil Deboin"]
5
5
  spec.email = ["sybil.deboin@gmail.com"]
6
6
  spec.description = "Standup feature for slack"
data/locales/en.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  en:
2
2
  lita:
3
3
  handlers:
4
- standup:
4
+ slack_standup:
@@ -40,12 +40,11 @@ describe Lita::Handlers::SlackStandup, lita_handler: true do
40
40
  end
41
41
 
42
42
  describe "when standup starts" do
43
-
44
43
  subject do
45
- send_message("!start standup", as: sybil, from: channel)
44
+ send_message("!standup start", as: sybil, from: channel)
46
45
  end
47
46
 
48
- it "starts standup", vcr: {cassette_name: 'start_standup'} do
47
+ it "starts standup", vcr: {cassette_name: 'standup_start'} do
49
48
  [ "Hello <!channel> ! Le standup va commencer : )",
50
49
  "Bonjour <@zaratan> ! C'est à ton tour de parler."
51
50
  ].each do |text|
@@ -55,28 +54,28 @@ describe Lita::Handlers::SlackStandup, lita_handler: true do
55
54
  subject
56
55
  end
57
56
 
58
- it "annoys people only on working days" do
59
- #standup test that it's called on weekday
60
- end
61
-
62
- context "with pre-filled reports" do
63
- it "displays known reports", vcr: {cassette_name: 'standup_prefilled'} do
64
- send_message("!standup My standup report for testing purposes", as: sybil, from: channel)
57
+ context "with pre-filled report" do
58
+ before do
59
+ send_message("!standup report My standup report for testing purposes", as: sybil, from: channel)
60
+ end
65
61
 
62
+ it "displays known reports", vcr: {cassette_name: 'standup_one_report_prefilled'} do
66
63
  [ "Hello <!channel> ! Le standup va commencer : )",
67
64
  "sybil a déjà renseigné son standup : \n My standup report for testing purposes",
68
65
  "Bonjour <@zaratan> ! C'est à ton tour de parler."
69
66
  ].each do |text|
70
67
  expect_any_instance_of(Slack::Web::Client).to receive(:chat_postMessage).with({:channel=>channel, :text=>text, :as_user=>true})
71
68
  end
72
-
73
69
  subject
74
70
  end
75
- context "with all reports pre-filled", vcr: {cassette_name: 'standups_all_prefilled'} do
76
- it "displays the standups and ends the meeting" do
77
- send_message("!standup My standup report for testing purposes", as: sybil, from: channel)
78
- send_message("!standup My standup report for testing purposes", as: zaratan, from: channel)
71
+
72
+ context "with all reports pre-filled", vcr: {cassette_name: 'standup_all_reports_prefilled'} do
73
+ before do
74
+ send_message("!standup report My standup report for testing purposes", as: sybil, from: channel)
75
+ send_message("!standup report My standup report for testing purposes", as: zaratan, from: channel)
76
+ end
79
77
 
78
+ it "displays the standups and ends the meeting" do
80
79
  [ "Hello <!channel> ! Le standup va commencer : )",
81
80
  "zaratan a déjà renseigné son standup : \n My standup report for testing purposes",
82
81
  "sybil a déjà renseigné son standup : \n My standup report for testing purposes",
@@ -84,85 +83,81 @@ describe Lita::Handlers::SlackStandup, lita_handler: true do
84
83
  ].each do |text|
85
84
  expect_any_instance_of(Slack::Web::Client).to receive(:chat_postMessage).with({:channel=>channel, :text=>text, :as_user=>true})
86
85
  end
87
-
88
86
  subject
89
87
  end
90
88
  end
91
89
  end
92
90
  end
93
91
 
94
- describe "!standup command", vcr: {cassette_name: 'standup'} do
92
+ describe "!standup report command", vcr: {cassette_name: 'standup_report'} do
95
93
  subject do
96
- send_message("!standup My standup report for testing purposes", as: sybil, from: channel)
94
+ send_message("!standup report My standup report for testing purposes", as: sybil, from: channel)
97
95
  end
98
96
 
99
- context "when the user reports" do
100
- it "saves the report" do
101
- subject
102
- expect(replies.last).to eq("Ton standup est enregistré. Merci :)")
103
- end
97
+ it "saves the report" do
98
+ subject
99
+ expect(replies.last).to eq("Ton standup est enregistré. Merci :)")
104
100
  end
105
101
  end
106
102
 
107
- describe "!next standup command" do
103
+ describe "!standup mext command" do
108
104
  subject do
109
- send_message("!next standup", as: sybil, from: channel)
105
+ send_message("!standup next", as: sybil, from: channel)
110
106
  end
111
107
 
112
- context "when its called oustide of standups", vcr: {cassette_name: 'next_standup_refused'} do
108
+ context "when its called oustide of standups", vcr: {cassette_name: 'standup_next_refused'} do
113
109
  it "is not available" do
114
110
  expect_any_instance_of(Slack::Web::Client).to receive(:chat_postMessage).with({:channel=>channel, :text=>"La commande n'est pas disponible en dehors d'un standup.", :as_user=>true})
115
-
116
111
  subject
117
112
  end
118
113
  end
119
114
 
120
- context "when it's called during standup", vcr: {cassette_name: 'next_standup'} do
115
+ context "when it's called during standup", vcr: {cassette_name: 'standup_next'} do
116
+ before do
117
+ send_message("!standup start", as: sybil, from: channel)
118
+ end
119
+
121
120
  it "asks the next user to report" do
122
- send_message("!start standup", as: sybil, from: channel)
123
-
124
121
  expect_any_instance_of(Slack::Web::Client).to receive(:chat_postMessage).with({:channel=>channel, :text=>"Bonjour <@sybil> ! C'est à ton tour de parler.", :as_user=>true})
125
-
126
122
  subject
127
123
  end
128
124
  end
129
125
  end
130
126
 
131
- describe "!ignore user command", vcr: {cassette_name: 'ignore_user'} do
127
+ describe "!standup ignore user command", vcr: {cassette_name: 'standup_ignore'} do
128
+
129
+ before do
130
+ send_message("!standup start", as: sybil, from: channel)
131
+ end
132
132
 
133
133
  subject do
134
- send_message("!ignore sybil", as: sybil, from: channel)
135
- send_message("!next standup", as: sybil, from: channel)
134
+ send_message("!standup ignore sybil", as: sybil, from: channel)
135
+ send_message("!standup next standup", as: sybil, from: channel)
136
136
  end
137
137
 
138
138
  it "ignores an user" do
139
- send_message("!start standup", as: sybil, from: channel)
140
-
141
139
  expect_any_instance_of(Slack::Web::Client).to receive(:chat_postMessage).with({:channel=>channel, :text=>"Et voilà ! C'est bon pour aujourd'hui. Merci tout le monde :parrot:", :as_user=>true})
142
-
143
140
  subject
144
141
  expect(replies.last).to eq("<@sybil> est désormais ignoré jusqu'à nouvel ordre.")
145
-
146
142
  end
147
143
  end
148
144
 
149
- describe "!unignore user command", vcr: {cassette_name: 'unignore_user'} do
145
+ describe "!standup unignore user command", vcr: {cassette_name: 'standup_unignore'} do
146
+
147
+ before do
148
+ send_message("!standup start", as: sybil, from: channel)
149
+ send_message("!standup ignore sybil", as: sybil, from: channel)
150
+ end
150
151
 
151
152
  subject do
152
- send_message("!unignore sybil", as: sybil, from: channel)
153
- send_message("!next standup", as: sybil, from: channel)
153
+ send_message("!standup unignore sybil", as: sybil, from: channel)
154
+ send_message("!standup next", as: sybil, from: channel)
154
155
  end
155
156
 
156
157
  it "unignores an user" do
157
- send_message("!start standup", as: sybil, from: channel)
158
- send_message("!ignore sybil", as: sybil, from: channel)
159
-
160
158
  expect_any_instance_of(Slack::Web::Client).to receive(:chat_postMessage).with({:channel=>channel, :text=>"Bonjour <@sybil> ! C'est à ton tour de parler.", :as_user=>true})
161
-
162
159
  subject
163
160
  expect(replies.last).to eq("<@sybil> est à nouveau inclus dans les standups.")
164
-
165
161
  end
166
162
  end
167
-
168
163
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lita-slack-standup
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sybil Deboin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-26 00:00:00.000000000 Z
11
+ date: 2016-02-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lita