lita-estimate 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -6
- data/lib/lita/handlers/estimate.rb +12 -4
- data/lita-estimate.gemspec +1 -1
- data/spec/lita/handlers/estimate_spec.rb +17 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 41de7683e7304d3516be6415d3016cea50c3c8b2
|
4
|
+
data.tar.gz: b5c595debb988f0dcda69a3f8efd45450fc29fe7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c1a180364e5b0aae3367e61eab23c9bdf436672de70e4673fad1301798f700f1c3faf1b7b0bac765f43bb81c40e92d237957dd2397931cd8331d95e753410621
|
7
|
+
data.tar.gz: 66d15e1abe080b36d8c5d1beaf5daf5d0a2aa759363e2ddb00d84dda23f6a0ca100a9664826bb8ae8313a448e9e7549ece693f27d9ec597aab93125e78e4372f
|
data/README.md
CHANGED
@@ -13,13 +13,15 @@ Add lita-estimate to your Lita instance's Gemfile:
|
|
13
13
|
gem "lita-estimate"
|
14
14
|
```
|
15
15
|
|
16
|
-
## Configuration
|
17
|
-
|
18
|
-
none
|
19
|
-
|
20
16
|
## Usage
|
21
17
|
|
22
18
|
```
|
23
|
-
> @bot estimate US123 as 5
|
24
|
-
>
|
19
|
+
Peter> @bot estimate US123 as 5
|
20
|
+
Bot> Thanks!
|
21
|
+
Paula> @bot estimate US123 as 3
|
22
|
+
Bot> Thanks!
|
23
|
+
Carl> @bot estimates
|
24
|
+
Bot> Peter: 5
|
25
|
+
Bot> Paula: 3
|
26
|
+
Bot> Average: 4
|
25
27
|
```
|
@@ -7,21 +7,29 @@ module Lita
|
|
7
7
|
|
8
8
|
def estimate(response)
|
9
9
|
story, points = response.matches.first
|
10
|
-
|
10
|
+
if ['1','2','3','5','8','13'].include?(points)
|
11
|
+
redis.hset(key(story), response.user.name, points)
|
12
|
+
response.reply('Thanks!')
|
13
|
+
else
|
14
|
+
response.reply('Please use a Fibonacci number not larger than 13')
|
15
|
+
end
|
11
16
|
end
|
12
17
|
|
13
18
|
def show_estimates(response)
|
14
19
|
story = response.matches.flatten.first
|
15
20
|
estimates = []
|
16
|
-
redis.
|
17
|
-
estimator = key.split(':').last
|
18
|
-
estimates << (estimate = redis.get(key).to_i)
|
21
|
+
redis.hgetall(key(story)).each do |estimator, estimate|
|
19
22
|
response.reply("#{estimator}: #{estimate}")
|
23
|
+
estimates << estimate.to_i
|
20
24
|
end
|
21
25
|
average = estimates.inject{ |sum, e| sum + e }.to_f / estimates.size
|
22
26
|
response.reply("Average: #{average}")
|
23
27
|
end
|
24
28
|
|
29
|
+
def key(story)
|
30
|
+
['estimate', story].join(':')
|
31
|
+
end
|
32
|
+
|
25
33
|
Lita.register_handler(self)
|
26
34
|
end
|
27
35
|
end
|
data/lita-estimate.gemspec
CHANGED
@@ -14,7 +14,20 @@ describe Lita::Handlers::Estimate, lita_handler: true do
|
|
14
14
|
it "should persist estimates" do
|
15
15
|
carl = Lita::User.create(123, name: "Carl")
|
16
16
|
send_command('estimate US123 as 5', :as => carl)
|
17
|
-
expect(subject.redis.
|
17
|
+
expect(subject.redis.hget('estimate:US123', 'Carl')).to eq("5")
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should confirm the estimate" do
|
21
|
+
carl = Lita::User.create(123, name: "Carl")
|
22
|
+
send_command('estimate US123 as 5', :as => carl)
|
23
|
+
expect(replies.last).to eq('Thanks!')
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should reject the estimate if it is not a fibonacci number" do
|
27
|
+
carl = Lita::User.create(123, name: "Carl")
|
28
|
+
send_command('estimate US123 as 4', :as => carl)
|
29
|
+
expect(subject.redis.hget('estimate:US123', 'Carl')).to be_nil
|
30
|
+
expect(replies.last).to eq('Please use a Fibonacci number not larger than 13')
|
18
31
|
end
|
19
32
|
|
20
33
|
end
|
@@ -22,15 +35,13 @@ describe Lita::Handlers::Estimate, lita_handler: true do
|
|
22
35
|
describe "show estimates" do
|
23
36
|
|
24
37
|
before(:each) do
|
25
|
-
|
26
|
-
|
27
|
-
send_command('estimate US123 as 5', :as => peter)
|
28
|
-
send_command('estimate US123 as 3', :as => paula)
|
38
|
+
subject.redis.hset('estimate:US123', 'Peter', '5')
|
39
|
+
subject.redis.hset('estimate:US123', 'Paula', '3')
|
29
40
|
end
|
30
41
|
|
31
42
|
it "should list estimates" do
|
32
43
|
send_command('US123 estimates')
|
33
|
-
expect(replies).to eq([
|
44
|
+
expect(replies.to_set).to eq(Set[
|
34
45
|
"Paula: 3",
|
35
46
|
"Peter: 5",
|
36
47
|
"Average: 4.0"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lita-estimate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ingo Weiss
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-09-
|
11
|
+
date: 2015-09-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lita
|