lita-estimate 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/lita/handlers/estimate.rb +16 -8
- data/lita-estimate.gemspec +1 -1
- data/spec/lita/handlers/estimate_spec.rb +16 -15
- data/spec/spec_helper.rb +4 -0
- 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: ad344b1cdb4aa633161c6a85c6a23f4bb43bb6db
|
4
|
+
data.tar.gz: f3d41d7944d1a0cc24fc588f8305d4b1b52cff89
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0faf63327375d93f7feb54af5f3960e7495c76f3d1d4418c1d6109cad5abd9dfab916579c4d110ce250062b26eb4d1e4fee76fbcc23769c6d3413dca87d11028
|
7
|
+
data.tar.gz: b99c5d4444ec437e42730c7bccea4ca009fa6e22cde754ce2074c403ba319aecf51a01685a0e4d81210ce7f85710ce1165b00001e9928e9037ef3626e90eacae
|
@@ -19,19 +19,27 @@ module Lita
|
|
19
19
|
|
20
20
|
def show_estimates(response)
|
21
21
|
story = response.matches.flatten.first
|
22
|
-
estimates =
|
23
|
-
|
24
|
-
response.reply("
|
25
|
-
|
22
|
+
estimates = redis.hgetall(key(story))
|
23
|
+
if estimates.empty?
|
24
|
+
response.reply("No estimates yet for #{story}")
|
25
|
+
else
|
26
|
+
lines = []
|
27
|
+
estimates.keys.sort.each do |estimator|
|
28
|
+
lines << "#{estimator}: #{estimates[estimator]}"
|
29
|
+
end
|
30
|
+
average = estimates.values.inject(0){ |sum, e| sum + e.to_i }.to_f / estimates.size
|
31
|
+
lines << "Average: #{average}"
|
32
|
+
response.reply(lines.join("\n"))
|
26
33
|
end
|
27
|
-
average = estimates.inject{ |sum, e| sum + e }.to_f / estimates.size
|
28
|
-
response.reply("Average: #{average}")
|
29
34
|
end
|
30
35
|
|
31
36
|
def show_estimators(response)
|
32
37
|
story = response.matches.flatten.first
|
33
|
-
redis.hgetall(key(story))
|
34
|
-
|
38
|
+
estimates = redis.hgetall(key(story))
|
39
|
+
if estimates.empty?
|
40
|
+
response.reply("No estimators yet for #{story}")
|
41
|
+
else
|
42
|
+
response.reply(estimates.keys.sort.join("\n"))
|
35
43
|
end
|
36
44
|
end
|
37
45
|
|
data/lita-estimate.gemspec
CHANGED
@@ -38,47 +38,48 @@ describe Lita::Handlers::Estimate, lita_handler: true do
|
|
38
38
|
|
39
39
|
describe "show estimates" do
|
40
40
|
|
41
|
-
|
41
|
+
it "should list estimates" do
|
42
42
|
subject.redis.hset('estimate:US123', 'Peter', '5')
|
43
43
|
subject.redis.hset('estimate:US123', 'Paula', '3')
|
44
|
-
end
|
45
|
-
|
46
|
-
it "should list estimates" do
|
47
44
|
send_command('US123 estimates')
|
48
|
-
expect(replies.
|
45
|
+
expect(lines(replies.last)).to eq([
|
49
46
|
"Paula: 3",
|
50
47
|
"Peter: 5",
|
51
48
|
"Average: 4.0"
|
52
49
|
])
|
53
50
|
end
|
54
51
|
|
52
|
+
it "should show a message if no estimates are found" do
|
53
|
+
send_command('US456 estimates')
|
54
|
+
expect(replies.last).to eq('No estimates yet for US456')
|
55
|
+
end
|
56
|
+
|
55
57
|
end
|
56
58
|
|
57
59
|
describe "show estimators" do
|
58
60
|
|
59
|
-
before(:each) do
|
60
|
-
subject.redis.hset('estimate:US123', 'Peter', '5')
|
61
|
-
subject.redis.hset('estimate:US123', 'Paula', '3')
|
62
|
-
end
|
63
|
-
|
64
61
|
it "should list estimates" do
|
62
|
+
subject.redis.hset('estimate:US123', 'Paula', '3')
|
63
|
+
subject.redis.hset('estimate:US123', 'Peter', '5')
|
65
64
|
send_command('US123 estimators')
|
66
|
-
expect(replies.
|
65
|
+
expect(lines(replies.last)).to eq([
|
67
66
|
"Paula",
|
68
67
|
"Peter"
|
69
68
|
])
|
70
69
|
end
|
71
70
|
|
71
|
+
it "should show a message if no estimates are found" do
|
72
|
+
send_command('US456 estimators')
|
73
|
+
expect(replies.last).to eq('No estimators yet for US456')
|
74
|
+
end
|
75
|
+
|
72
76
|
end
|
73
77
|
|
74
78
|
describe "reset estimates" do
|
75
79
|
|
76
|
-
|
80
|
+
it "should reset estimates" do
|
77
81
|
subject.redis.hset('estimate:US123', 'Peter', '5')
|
78
82
|
subject.redis.hset('estimate:US123', 'Paula', '3')
|
79
|
-
end
|
80
|
-
|
81
|
-
it "should reset estimates" do
|
82
83
|
send_command('US123 estimates reset')
|
83
84
|
expect(subject.redis.hgetall('estimate:US123')).to eq({})
|
84
85
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -13,3 +13,7 @@ require "lita/rspec"
|
|
13
13
|
# A compatibility mode is provided for older plugins upgrading from Lita 3. Since this plugin
|
14
14
|
# was generated with Lita 4, the compatibility mode should be left disabled.
|
15
15
|
Lita.version_3_compatibility_mode = false
|
16
|
+
|
17
|
+
def lines(multi_line_response)
|
18
|
+
multi_line_response.split("\n")
|
19
|
+
end
|
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.5
|
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-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lita
|