lita-estimate 0.1.0 → 0.1.1

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: 226efee41b4a539d397bef2fc660fd8f6d6cae32
4
- data.tar.gz: 5ce0ac5fe4914186d6a3e2e3ea9a621996c98e0d
3
+ metadata.gz: 41de7683e7304d3516be6415d3016cea50c3c8b2
4
+ data.tar.gz: b5c595debb988f0dcda69a3f8efd45450fc29fe7
5
5
  SHA512:
6
- metadata.gz: 743b0ab2b3d046c74a2c8b8acdd5a75b348af5ba47be2cf34ee7d2311d7162abf4d90783c0627c6d4d962fb40e884dee71bf349409b7d22501ffc7b55197793c
7
- data.tar.gz: 5035e22c9d28f1083191ee89723d37628a46697c742f0a05af1c9f61bb5dbba6481668240ab745269765b6edc79a2010891cb8fd1846ab7e91fda42493a206ed
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
- > @bot estimates
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
- redis.set([story,response.user.name].join(':'), points)
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.keys("#{story}:*").each do |key|
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
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "lita-estimate"
3
- spec.version = "0.1.0"
3
+ spec.version = "0.1.1"
4
4
  spec.authors = ["Ingo Weiss"]
5
5
  spec.email = ["ingo@ingoweiss.com"]
6
6
  spec.description = "Just a silly little Lita plugin for estimation"
@@ -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.get('US123:Carl')).to eq("5")
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
- peter = Lita::User.create(123, name: "Peter")
26
- paula = Lita::User.create(234, name: "Paula")
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.0
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-26 00:00:00.000000000 Z
11
+ date: 2015-09-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lita