lita-queue 0.1.0 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 33fd47f0ec810e138b6c4ad01136929edb6c54ac
4
- data.tar.gz: bbff179f4261205af069b78e88ddbc7fd946ab87
3
+ metadata.gz: fb902787e39a653ac07718c6d84dc1cf33f9b066
4
+ data.tar.gz: 523a6d6ec43a1d645f24e872089ac61a40b11349
5
5
  SHA512:
6
- metadata.gz: a4dd70f59ae79592e5d0a03b2d1c8b8c514493f16952ea7ceb5ee38a2399d4550208ba492758ef3b2ca21d24973883da63747b8b52e67814a66d12a13f216180
7
- data.tar.gz: 6a21b6e05bceb50fb4bf3f6fc675a6337dc7f10a5814e59f73aac45ea7574ead51b76268bd60d42d8150573b71d8b5ebb5b0a9c54402668afc8ab4389704fa5b
6
+ metadata.gz: 2ff331250ad6460c32ab3808c1eda94408dfb9b73a99743f39191bf11e2566dd9d40983bf51820ad67ade07472bbc780814f454b0c893b79a5de448528613bf6
7
+ data.tar.gz: 3563b154f31d16ef18329f86d97585358e046b2f92865b118e6babfe81566208fb41858cdf46431b8ecd577fa6986b817d9d57f28b0908b3f6e9a9f8e67c066b
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color --profile 5
@@ -4,6 +4,14 @@ This project adheres to [Semantic Versioning](http://semver.org/).
4
4
 
5
5
  We follow [Keep a Changelog](http://keepachangelog.com/) format.
6
6
 
7
+ ## 0.2.0 - 2015-06-21
8
+ ### Added
9
+ - Respond to the following additional command:
10
+ * lita rotate!
11
+
12
+ ### Changed
13
+ - More granular specs and better RSpec defaults (.rspec)
14
+
7
15
  ## 0.1.0 - 2015-06-14
8
16
  ### Added
9
17
  - Initial plugin import with support for the following commands:
data/README.md CHANGED
@@ -23,7 +23,7 @@ The following commands are available:
23
23
  * lita unqueue me
24
24
  * lita queue next?
25
25
  * lita queue next!
26
+ * lita queue rotate!
26
27
 
27
28
  The following commands will be available in a further version:
28
- * lita queue rotate!
29
29
  * lita queue = [<new_queue,comma_separated>]
@@ -7,7 +7,7 @@ module Lita
7
7
  route(/^unqueue me$/, :unqueue_me, command: :true)
8
8
  route(/^queue next\?$/, :queue_list_next, command: :true)
9
9
  route(/^queue next!$/, :queue_change_to_next, command: :true)
10
- #route(/^queue rotate!$/, :queue_rotate, command: :true)
10
+ route(/^queue rotate!$/, :queue_rotate, command: :true)
11
11
  #route(/^queue = \[([^\]]*)\]\s*$$/, :queue_recreate, command: :true)
12
12
 
13
13
  # API
@@ -83,13 +83,27 @@ module Lita
83
83
  unless queue.empty?
84
84
  removed = queue.shift
85
85
  store_queue(room, queue)
86
- response.reply "#{removed} have been removed from queue"
86
+ response.reply "#{removed} have been removed from queue."
87
87
  response.reply "#{queue.first} is the next. Go ahead!" unless queue.empty?
88
88
  end
89
89
 
90
90
  response.reply display_queue(queue, room)
91
91
  end
92
92
 
93
+ def queue_rotate(response)
94
+ room = room_for(response)
95
+ queue = fetch_queue(room)
96
+
97
+ unless queue.empty?
98
+ new_queue = queue.rotate
99
+ store_queue(room, new_queue)
100
+ response.reply "#{queue.first} has been moved to the end of the queue."
101
+ response.reply "#{new_queue.first} is the next. Go ahead!"
102
+ end
103
+
104
+ response.reply display_queue(queue, room)
105
+ end
106
+
93
107
  private
94
108
 
95
109
  def room_for(response)
@@ -98,7 +112,7 @@ module Lita
98
112
 
99
113
  def display_queue(queue, room)
100
114
  if queue.empty?
101
- "Queue is empty"
115
+ "Queue is empty!"
102
116
  else
103
117
  "Queue for #{room}: #{queue}"
104
118
  end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "lita-queue"
3
- spec.version = "0.1.0"
3
+ spec.version = "0.2.0"
4
4
  spec.authors = ["Gabriel Mazetto"]
5
5
  spec.email = ["brodock@gmail.com"]
6
6
  spec.description = "Lita plugin to manage channel specific queue"
@@ -4,6 +4,7 @@ describe Lita::Handlers::Queue, lita_handler: true do
4
4
 
5
5
  user1 = Lita::User.create(100, name: 'User 1')
6
6
  user2 = Lita::User.create(101, name: 'User 2')
7
+ user3 = Lita::User.create(102, name: 'User 3')
7
8
 
8
9
  # Routes
9
10
  it { is_expected.to route_command("queue").to(:queue_list) }
@@ -11,7 +12,7 @@ describe Lita::Handlers::Queue, lita_handler: true do
11
12
  it { is_expected.to route_command("unqueue me").to(:unqueue_me) }
12
13
  it { is_expected.to route_command("queue next?").to(:queue_list_next) }
13
14
  it { is_expected.to route_command("queue next!").to(:queue_change_to_next) }
14
- #it { is_expected.to route_command("queue rotate!").to(:queue_rotate) }
15
+ it { is_expected.to route_command("queue rotate!").to(:queue_rotate) }
15
16
  #it { is_expected.to route_command("queue = [something,here]").to(:queue_recreate) }
16
17
 
17
18
  let(:channel) { source.room || '--global--' }
@@ -20,6 +21,7 @@ describe Lita::Handlers::Queue, lita_handler: true do
20
21
  describe "#queue_list" do
21
22
  context "when queue is empty" do
22
23
  before { subject.store_queue(channel, []) }
24
+
23
25
  it "replies with an empty queue message" do
24
26
  send_command("queue")
25
27
  expect(replies.last).to include("Queue is empty")
@@ -39,6 +41,7 @@ describe Lita::Handlers::Queue, lita_handler: true do
39
41
  describe "#queue_me" do
40
42
  context "when I'm already queued" do
41
43
  before { subject.store_queue(channel, [user.mention_name]) }
44
+
42
45
  it "replies with an error message" do
43
46
  send_command("queue me")
44
47
  expect(replies.last).to include("already on queue")
@@ -57,6 +60,7 @@ describe Lita::Handlers::Queue, lita_handler: true do
57
60
  describe "#unqueue_me" do
58
61
  context "when I'm already queued" do
59
62
  before { subject.store_queue(channel, [user.mention_name]) }
63
+
60
64
  it "replies with a confirmation and remove from queue" do
61
65
  send_command("unqueue me")
62
66
  expect(replies.last).to include("#{user.name} have been removed from queue")
@@ -66,6 +70,7 @@ describe Lita::Handlers::Queue, lita_handler: true do
66
70
 
67
71
  context "when I'm not on queue" do
68
72
  before { subject.store_queue(channel, []) }
73
+
69
74
  it "replies with an error message" do
70
75
  send_command("unqueue me")
71
76
  expect(replies.last).to include("not on queue!")
@@ -83,6 +88,7 @@ describe Lita::Handlers::Queue, lita_handler: true do
83
88
 
84
89
  context "when queue has only one element" do
85
90
  before { subject.store_queue(channel, [user1.mention_name]) }
91
+
86
92
  it "replies listing current user on queue and warning that's the last one" do
87
93
  send_command("queue next?")
88
94
  expect(replies.last).to include(user1.mention_name)
@@ -92,6 +98,7 @@ describe Lita::Handlers::Queue, lita_handler: true do
92
98
 
93
99
  context "when queue has more than one elements" do
94
100
  before { subject.store_queue(channel, [user1.mention_name, user2.mention_name]) }
101
+
95
102
  it "replies listing the next one on the queue" do
96
103
  send_command("queue next?")
97
104
  expect(replies.last).to include(user2.mention_name)
@@ -107,23 +114,53 @@ describe Lita::Handlers::Queue, lita_handler: true do
107
114
  end
108
115
  end
109
116
 
110
- context "when queue has elements" do
111
- it "remove the first element and replies with current queue" do
112
- subject.store_queue(channel, [user1.mention_name, user2.mention_name])
117
+ context "when queue has enough elements" do
118
+ let(:queue) { [user1.mention_name, user2.mention_name] }
119
+ before { subject.store_queue(channel, queue) }
120
+
121
+ it "remove the first element from the queue" do
122
+ send_command("queue next!")
123
+ expect(subject.fetch_queue(channel)).to eq([user2.mention_name])
124
+ end
113
125
 
126
+ it "replies informing who was been removed and who is next" do
114
127
  send_command("queue next!")
115
128
  expect(replies.first).to include("#{user1.mention_name} have been removed from queue")
116
129
  expect(replies[1]).to include("#{user2.mention_name} is the next")
130
+
131
+ end
132
+
133
+ it "informs the new queue after execution" do
134
+ send_command("queue next!")
117
135
  expect(replies.last).to include(user2.mention_name)
118
136
  expect(replies.last).not_to include(user1.mention_name)
119
137
  end
120
138
 
121
- it "replies with a notification message when removing the last element from queue" do
122
- subject.store_queue(channel, [user2.mention_name])
139
+ context "when queue has only one element" do
140
+ let(:queue) { [user2.mention_name] }
123
141
 
124
- send_command("queue next!")
125
- expect(replies.first).to include("#{user2.mention_name} have been removed from queue")
126
- expect(replies.last).to include("Queue is empty")
142
+ it "replies with a notification message when removing the last element from queue" do
143
+ send_command("queue next!")
144
+ expect(replies.first).to include("#{user2.mention_name} have been removed from queue")
145
+ expect(replies.last).to include("Queue is empty")
146
+ end
147
+ end
148
+ end
149
+ end
150
+
151
+ describe "#queue_rotate" do
152
+ context "when queue has enough elements" do
153
+ before { subject.store_queue(channel, [user1.mention_name, user2.mention_name, user3.mention_name]) }
154
+
155
+ it "removes the first element and add to the end" do
156
+ send_command("queue rotate!")
157
+ expect(subject.fetch_queue(channel)).to eq([user2.mention_name, user3.mention_name, user1.mention_name])
158
+ end
159
+
160
+ it "replies mentioning the next user on queue and notifing the rotated one" do
161
+ send_command("queue rotate!")
162
+ expect(replies.first).to include("#{user1.mention_name} has been moved to the end of the queue")
163
+ expect(replies[1]).to include("#{user2.mention_name} is the next")
127
164
  end
128
165
  end
129
166
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lita-queue
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gabriel Mazetto
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-15 00:00:00.000000000 Z
11
+ date: 2015-06-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lita
@@ -130,6 +130,7 @@ extensions: []
130
130
  extra_rdoc_files: []
131
131
  files:
132
132
  - ".gitignore"
133
+ - ".rspec"
133
134
  - ".travis.yml"
134
135
  - CHANGELOG.md
135
136
  - Gemfile