lita-debug-queue 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: eaf323f4fe47b1aeb6cc87e98a4dc1cfd64a22a3
4
+ data.tar.gz: ebed6e0928f033f06802ee945d664cedeabeb63e
5
+ SHA512:
6
+ metadata.gz: 3411f4a18feb9f082080bc3f7a87e59bdb8bec8a271309be6bcc09283864b0bbff001669b9c143a71a0bcc1284972a105b8eddc0e71e3b0bc613cf11995b07c4
7
+ data.tar.gz: 5f96eef0287d91c3933e32128ad499c267559bd445499cc2e33feae7ca02129dc0f58edce6acb9702bc0fcca543523db5cd1cab313b33d43a372f18db8aee539
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015, Brit Butler
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,22 @@
1
+ # lita-debug-queue
2
+
3
+ Queue tracking of users who need debugging help with per-channel management.
4
+
5
+ ## Installation
6
+
7
+ Add lita-debug-queue to your Lita instance's Gemfile:
8
+
9
+ ``` ruby
10
+ gem "lita-debug-queue"
11
+ ```
12
+
13
+ ## Configuration
14
+
15
+ lita-debug-queue expects two things to be present for correct operation:
16
+
17
+ 1. An `:instructors` authorization group containing admin users.
18
+ 2. A `classrooms` config option containing a Hash that maps instructor mention names to classroom channels.
19
+
20
+ ## Usage
21
+
22
+ **TODO**
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
@@ -0,0 +1,12 @@
1
+ require "lita"
2
+
3
+ Lita.load_locales Dir[File.expand_path(
4
+ File.join("..", "..", "locales", "*.yml"), __FILE__
5
+ )]
6
+
7
+ require "lita/handlers/debug_queue"
8
+
9
+ Lita::Handlers::DebugQueue.template_root File.expand_path(
10
+ File.join("..", "..", "templates"),
11
+ __FILE__
12
+ )
@@ -0,0 +1,85 @@
1
+ module Lita
2
+ module Handlers
3
+ class DebugQueue < Handler
4
+ config :classrooms # A mapping from instructor names to classroom channels.
5
+
6
+ route(/^debug me$/, :add, command: true, help: { })
7
+ route(/^debug nvm$/, :cancel, command: true, help: { })
8
+ route(/^debug queue$/, :show, command: true, help: { })
9
+ route(/^debug count$/, :count, command: true, help: { })
10
+ route(/^debug next$/, :next, command: true, restrict_to: [:instructors],
11
+ help: { })
12
+ route(/^debug drop\s+(.+)$/, :drop, command: true, restrict_to: [:instructors],
13
+ help: { })
14
+ route(/^debug clear$/, :clear, command: true, restrict_to: [:instructors],
15
+ help: { })
16
+
17
+ def add(response)
18
+ return unless check_room!(response)
19
+ student = response.user.mention_name
20
+ if room_queue.include?(student)
21
+ response.reply("#{student}: Easy there killer. You're already on the list.")
22
+ else
23
+ redis.set(@room, room_queue.push(student))
24
+ response.reply("#{student}: Help is on the way.")
25
+ end
26
+ end
27
+
28
+ def cancel(response)
29
+ return unless check_room!(response)
30
+ student = response.user.mention_name
31
+ if room_queue.include?(student)
32
+ redis.set(@room, room_queue.reject{ |x| x == student })
33
+ response.reply("#{student}: Glad you figured it out! :)")
34
+ else
35
+ response.reply("#{student}: You know you're not in the queue, right?")
36
+ end
37
+ end
38
+
39
+ def show(response)
40
+ return unless check_room!(response)
41
+ response.reply("Queue for #{@room} => #{room_queue}")
42
+ end
43
+
44
+ def count(response)
45
+ return unless check_room!(response)
46
+ response.reply("Hackers seeking fresh eyes: #{room_queue.count}")
47
+ end
48
+
49
+ def next(response)
50
+ @room = config.classrooms[response.user.mention_name]
51
+ student = room_queue.pop
52
+ redis.set(@room, room_queue.reject { |x| x == student })
53
+ robot.send_message(response.user, "@#{student}: You're up! Let's debug :allthethings:")
54
+ response.reply("#{student} is up next and has been notified.")
55
+ end
56
+
57
+ def drop(response)
58
+ @room = config.classrooms[response.user.mention_name]
59
+ student = response.matches[0][0] # TODO: We could be safer here.
60
+ redis.set(@room, room_queue.reject { |x| x == student })
61
+ response.reply("#{student} has been removed from the queue.")
62
+ end
63
+
64
+ def clear(response)
65
+ @room = config.classrooms[response.user.mention_name]
66
+ redis.del(@room)
67
+ response.reply("Sounds like time for :beer: and ping pong!")
68
+ end
69
+
70
+ private
71
+ def check_room!(response)
72
+ @room = response.message.source.room
73
+ response.reply_privately("You must be in the class channel to send this message.") unless @room
74
+ @room
75
+ end
76
+
77
+ def room_queue
78
+ room = redis.get(@room)
79
+ room ? MultiJson.load(room) : []
80
+ end
81
+ end
82
+
83
+ Lita.register_handler(DebugQueue)
84
+ end
85
+ end
@@ -0,0 +1,24 @@
1
+ Gem::Specification.new do |spec|
2
+ spec.name = "lita-debug-queue"
3
+ spec.version = "0.1.0"
4
+ spec.authors = ["Brit Butler"]
5
+ spec.email = ["brit@kingcons.io"]
6
+ spec.description = "Queue tracking of users who need debugging help with per-channel management"
7
+ spec.summary = "A Lita handler for requesting debugging help"
8
+ spec.homepage = "https://github.com/kingcons/lita-debug-queue"
9
+ spec.license = "MIT"
10
+ spec.metadata = { "lita_plugin_type" => "handler" }
11
+
12
+ spec.files = `git ls-files`.split($/)
13
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
14
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
15
+ spec.require_paths = ["lib"]
16
+
17
+ spec.add_runtime_dependency "lita", ">= 4.5"
18
+
19
+ spec.add_development_dependency "bundler", "~> 1.3"
20
+ spec.add_development_dependency "pry-byebug"
21
+ spec.add_development_dependency "rake"
22
+ spec.add_development_dependency "rack-test"
23
+ spec.add_development_dependency "rspec", ">= 3.0.0"
24
+ end
data/locales/en.yml ADDED
@@ -0,0 +1,4 @@
1
+ en:
2
+ lita:
3
+ handlers:
4
+ help_queue:
@@ -0,0 +1,104 @@
1
+ require "spec_helper"
2
+
3
+ describe Lita::Handlers::DebugQueue, lita_handler: true do
4
+ let(:vedika) { Lita::User.create(456, mention_name: "vedika") }
5
+ let(:brit) { Lita::User.create(789, mention_name: "brit") }
6
+ let(:dylan) { Lita::User.create(123, mention_name: "dylan") }
7
+ let(:rails) { Lita::Room.new("rails") }
8
+
9
+ ## Routes
10
+ it { is_expected.to route_command("debug me").to(:add) }
11
+ it { is_expected.to route_command("debug nvm").to(:cancel) }
12
+ it { is_expected.to route_command("debug queue").to(:show) }
13
+ it { is_expected.to route_command("debug count").to(:count) }
14
+ it { is_expected.to route_command("debug next").with_authorization_for(:instructors).to(:next) }
15
+ it { is_expected.to route_command("debug drop phteven").with_authorization_for(:instructors).to(:drop) }
16
+ it { is_expected.to route_command("debug clear").with_authorization_for(:instructors).to(:clear) }
17
+
18
+ ## General Commands
19
+ context "user commands" do
20
+ let(:ocaml) { Lita::Room.new("ocaml") }
21
+
22
+ it "doesn't allow students to send messages outside the class channel" do
23
+ ["debug me", "debug nvm", "debug queue", "debug count"].each do |cmd|
24
+ send_command(cmd, as: dylan)
25
+ expect(replies.last).to start_with("You must be in the class channel")
26
+ end
27
+ end
28
+
29
+ it "allows students to queue themselves for help" do
30
+ send_command("debug me", as: dylan, from: rails)
31
+ expect(replies.last).to start_with("dylan: Help is on the way.")
32
+ end
33
+
34
+ it "doesn't allow students to queue themselves twice" do
35
+ send_command("debug me", as: dylan, from: rails)
36
+ send_command("debug me", as: dylan, from: rails)
37
+ expect(replies.last).to start_with("dylan: Easy there killer. You're already on the list.")
38
+ end
39
+
40
+ it "allows students to remove themselves if they figure it out" do
41
+ send_command("debug me", as: dylan, from: rails)
42
+ send_command("debug nvm", as: dylan, from: rails)
43
+ expect(replies.last).to start_with("dylan: Glad you figured it out! :)")
44
+ end
45
+
46
+ it "doesn't allow students to remove themselves if they aren't in the queue" do
47
+ send_command("debug nvm", as: dylan, from: rails)
48
+ expect(replies.last).to start_with("dylan: You know you're not in the queue, right?")
49
+ end
50
+
51
+ it "allows students to get an up to date count of people in that room's queue" do
52
+ send_command("debug me", as: vedika, from: rails)
53
+ send_command("debug count", from: rails)
54
+ expect(replies.last).to start_with("Hackers seeking fresh eyes: 1")
55
+
56
+ send_command("debug count", from: ocaml)
57
+ expect(replies.last).to start_with("Hackers seeking fresh eyes: 0")
58
+
59
+ send_command("debug me", as: dylan, from: rails)
60
+ send_command("debug count", from: rails)
61
+ expect(replies.last).to start_with("Hackers seeking fresh eyes: 2")
62
+
63
+ send_command("debug nvm", as: vedika, from: rails)
64
+ send_command("debug count", from: rails)
65
+ expect(replies.last).to start_with("Hackers seeking fresh eyes: 1")
66
+ end
67
+ end
68
+
69
+ context "instructor commands" do
70
+ before(:each) do
71
+ registry.config.handlers.debug_queue.classrooms = {
72
+ 'brit' => 'rails'
73
+ }
74
+ @auth = Lita::Authorization.new(registry.config)
75
+ @auth.add_user_to_group!(brit, :instructors)
76
+ end
77
+
78
+ ## Instructor Commands
79
+ it "allows instructors to notify the next student and pop them from the queue" do
80
+ send_command("debug me", as: vedika, from: rails)
81
+ send_command("debug next", as: brit)
82
+ expect(replies.last).to start_with("vedika is up next and has been notified.")
83
+ send_command("debug count", from: rails)
84
+ expect(replies.last).to start_with("Hackers seeking fresh eyes: 0")
85
+ end
86
+
87
+ it "allows instructors to remove a student from the queue by name" do
88
+ send_command("debug me", as: dylan, from: rails)
89
+ send_command("debug drop dylan", as: brit)
90
+ expect(replies.last).to start_with("dylan has been removed from the queue.")
91
+ send_command("debug count", from: rails)
92
+ expect(replies.last).to start_with("Hackers seeking fresh eyes: 0")
93
+ end
94
+
95
+ it "allows instructors to clear the queue completely" do
96
+ send_command("debug me", as: vedika, from: rails)
97
+ send_command("debug me", as: dylan, from: rails)
98
+ send_command("debug clear", as: brit)
99
+ expect(replies.last).to start_with("Sounds like time for :beer: and ping pong!")
100
+ send_command("debug count", from: rails)
101
+ expect(replies.last).to start_with("Hackers seeking fresh eyes: 0")
102
+ end
103
+ end
104
+ end
@@ -0,0 +1,6 @@
1
+ require "lita-debug-queue"
2
+ require "lita/rspec"
3
+
4
+ # A compatibility mode is provided for older plugins upgrading from Lita 3. Since this plugin
5
+ # was generated with Lita 4, the compatibility mode should be left disabled.
6
+ Lita.version_3_compatibility_mode = false
File without changes
metadata ADDED
@@ -0,0 +1,144 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lita-debug-queue
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Brit Butler
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-08-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: lita
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '4.5'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '4.5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.3'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: pry-byebug
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rack-test
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: 3.0.0
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: 3.0.0
97
+ description: Queue tracking of users who need debugging help with per-channel management
98
+ email:
99
+ - brit@kingcons.io
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - ".gitignore"
105
+ - Gemfile
106
+ - LICENSE
107
+ - README.md
108
+ - Rakefile
109
+ - lib/lita-debug-queue.rb
110
+ - lib/lita/handlers/debug_queue.rb
111
+ - lita-debug-queue.gemspec
112
+ - locales/en.yml
113
+ - spec/lita/handlers/help_queue_spec.rb
114
+ - spec/spec_helper.rb
115
+ - templates/.gitkeep
116
+ homepage: https://github.com/kingcons/lita-debug-queue
117
+ licenses:
118
+ - MIT
119
+ metadata:
120
+ lita_plugin_type: handler
121
+ post_install_message:
122
+ rdoc_options: []
123
+ require_paths:
124
+ - lib
125
+ required_ruby_version: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - ">="
128
+ - !ruby/object:Gem::Version
129
+ version: '0'
130
+ required_rubygems_version: !ruby/object:Gem::Requirement
131
+ requirements:
132
+ - - ">="
133
+ - !ruby/object:Gem::Version
134
+ version: '0'
135
+ requirements: []
136
+ rubyforge_project:
137
+ rubygems_version: 2.2.2
138
+ signing_key:
139
+ specification_version: 4
140
+ summary: A Lita handler for requesting debugging help
141
+ test_files:
142
+ - spec/lita/handlers/help_queue_spec.rb
143
+ - spec/spec_helper.rb
144
+ has_rdoc: