robut-quiz 0.2.0 → 0.2.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.
- data/History.txt +4 -0
- data/README.md +30 -3
- data/lib/choice.rb +42 -0
- data/lib/quiz.rb +2 -1
- data/lib/robut_quiz.rb +1 -1
- data/spec/choice_spec.rb +140 -0
- metadata +35 -38
data/History.txt
CHANGED
data/README.md
CHANGED
@@ -4,19 +4,46 @@ A Plugin for [Robut](https://github.com/justinweiss/robut) that allows you to as
|
|
4
4
|
|
5
5
|
## Usage
|
6
6
|
|
7
|
-
###
|
7
|
+
### Yes/No Question (Polar)
|
8
8
|
|
9
9
|
```
|
10
|
-
user_a > @robut ask 'Do you want to go to the bar at 4:30?'
|
10
|
+
user_a > @robut ask 'Do you want to go to the bar at 4:30?'
|
11
11
|
robut > @user I have enqueued your question
|
12
12
|
robut > @all Question: 'Do you want to go to the bar at 4:30?'
|
13
13
|
user_a > @robut answer YES
|
14
14
|
user_b > @robut answer yes
|
15
15
|
user_c > @robut answer n
|
16
|
-
robut > @all The results are in for 'Do you want to go to the bar at 4:30
|
16
|
+
robut > @all The results are in for 'Do you want to go to the bar at 4:30?':
|
17
17
|
2 YES votes and 1 NO vote
|
18
18
|
```
|
19
19
|
|
20
|
+
|
21
|
+
### Scale/Range Questions
|
22
|
+
|
23
|
+
```
|
24
|
+
user_a > @robut ask range 'How much did you like the bar we went to last week?' 1..10
|
25
|
+
robut > @user I have enqueued your question
|
26
|
+
robut > @all Question 'How much did you like the bar we went to last week?' (1..10)
|
27
|
+
user_a > @robut answer 1
|
28
|
+
user_b > @robut answer 5
|
29
|
+
user_c > @robut answer 10
|
30
|
+
robut > @all The results are in for 'How much did you like the bar we went to last week?':
|
31
|
+
3 votes with a mean of 5.333333
|
32
|
+
```
|
33
|
+
|
34
|
+
### Choice Questions
|
35
|
+
|
36
|
+
```
|
37
|
+
user_a > @robut ask choice 'What drink should I order?' 'PBR', 'Martini', 'Bourbon'
|
38
|
+
robut > @user I have enqueued your question
|
39
|
+
robut > @all Question 'What drink should I order?' (1..10)
|
40
|
+
user_a > @robut answer PBR
|
41
|
+
user_b > @robut answer Martini
|
42
|
+
user_c > @robut answer Martini
|
43
|
+
robut > @all The results are in for 'What drink should I order?':
|
44
|
+
1 'PBR', 2 'Martini'
|
45
|
+
```
|
46
|
+
|
20
47
|
## Installation
|
21
48
|
|
22
49
|
Install the gem
|
data/lib/choice.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
class Robut::Plugin::Quiz::Choice
|
4
|
+
include Robut::Plugin::Quiz::Question
|
5
|
+
|
6
|
+
def ask
|
7
|
+
"@all Question '#{@question}' #{@parameters.map {|p| "'#{p}'" }.join(", ")})"
|
8
|
+
end
|
9
|
+
|
10
|
+
def handle_response(sender_nick,response)
|
11
|
+
|
12
|
+
if a_valid_choice response
|
13
|
+
store_response sender_nick, response
|
14
|
+
true
|
15
|
+
else
|
16
|
+
false
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
def a_valid_choice(response)
|
22
|
+
@parameters.find {|choice| choice == response }
|
23
|
+
end
|
24
|
+
|
25
|
+
def store_response(sender_nick,response)
|
26
|
+
captured_results[sender_nick] = response
|
27
|
+
end
|
28
|
+
|
29
|
+
def results
|
30
|
+
|
31
|
+
response = @parameters.map do |choice|
|
32
|
+
found = captured_results.values.find_all {|result| result == choice }
|
33
|
+
|
34
|
+
"#{found.length} '#{choice}'" unless found.empty?
|
35
|
+
|
36
|
+
end.compact.join(", ")
|
37
|
+
|
38
|
+
response.empty? ? "No votes have been made" : response
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
data/lib/quiz.rb
CHANGED
data/lib/robut_quiz.rb
CHANGED
data/spec/choice_spec.rb
ADDED
@@ -0,0 +1,140 @@
|
|
1
|
+
require_relative 'spec_helper'
|
2
|
+
|
3
|
+
describe Robut::Plugin::Quiz::Choice do
|
4
|
+
|
5
|
+
subject do
|
6
|
+
Robut::Plugin::Quiz::Choice.new 'person',"'Should I continue the presentation?' 'yes', 'no', 'meh'"
|
7
|
+
end
|
8
|
+
|
9
|
+
let(:time) { Time.now }
|
10
|
+
|
11
|
+
describe "#handle_response" do
|
12
|
+
|
13
|
+
context "when the response is a 'yes'" do
|
14
|
+
|
15
|
+
it "should store the yes response for the user" do
|
16
|
+
|
17
|
+
subject.should_receive(:store_response).with('person','yes')
|
18
|
+
subject.handle_response('person','yes')
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
context "when the response is a 'no'" do
|
25
|
+
|
26
|
+
it "should store the no response for the user" do
|
27
|
+
|
28
|
+
subject.should_receive(:store_response).with('person','no')
|
29
|
+
subject.handle_response('person','no')
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
context "when the response is a 'meh'" do
|
35
|
+
|
36
|
+
it "should store the meh response for the user" do
|
37
|
+
|
38
|
+
subject.should_receive(:store_response).with('person','meh')
|
39
|
+
subject.handle_response('person','meh')
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
context "when the response is not valid" do
|
45
|
+
|
46
|
+
it "should not store the response for the user" do
|
47
|
+
|
48
|
+
subject.handle_response('person','no way').should be_false
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
|
57
|
+
describe "#declare_results" do
|
58
|
+
|
59
|
+
context "when there have been no votes" do
|
60
|
+
|
61
|
+
it "should reply that there are no votes" do
|
62
|
+
|
63
|
+
subject.results.should eq "No votes have been made"
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
|
69
|
+
context "when there has been a 'yes' vote" do
|
70
|
+
|
71
|
+
it "should reply that there is 1 'yes' vote" do
|
72
|
+
|
73
|
+
subject.handle_response('person','yes')
|
74
|
+
subject.results.should eq "1 'yes'"
|
75
|
+
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
79
|
+
|
80
|
+
context "when there has been a 'no' vote" do
|
81
|
+
|
82
|
+
it "should reply that there is 1 'no' vote" do
|
83
|
+
|
84
|
+
subject.handle_response('person','no')
|
85
|
+
subject.results.should eq "1 'no'"
|
86
|
+
|
87
|
+
end
|
88
|
+
|
89
|
+
end
|
90
|
+
|
91
|
+
context "when there has been a 'meh' vote" do
|
92
|
+
|
93
|
+
it "should reply that there is 1 'no' vote" do
|
94
|
+
|
95
|
+
subject.handle_response('person','meh')
|
96
|
+
subject.results.should eq "1 'meh'"
|
97
|
+
|
98
|
+
end
|
99
|
+
|
100
|
+
end
|
101
|
+
|
102
|
+
context "when there have been several different votes" do
|
103
|
+
|
104
|
+
it "should reply that there is 1 'no' vote" do
|
105
|
+
|
106
|
+
subject.handle_response('person_a','yes')
|
107
|
+
subject.handle_response('person_b','no')
|
108
|
+
subject.handle_response('person_c','meh')
|
109
|
+
subject.results.should eq "1 'yes', 1 'no', 1 'meh'"
|
110
|
+
|
111
|
+
end
|
112
|
+
|
113
|
+
end
|
114
|
+
|
115
|
+
context "when there has been multiple votes by the same user" do
|
116
|
+
|
117
|
+
it "should count as one vote" do
|
118
|
+
|
119
|
+
subject.handle_response('person','no')
|
120
|
+
subject.handle_response('person','no')
|
121
|
+
subject.handle_response('person','no')
|
122
|
+
subject.results.should eq "1 'no'"
|
123
|
+
|
124
|
+
end
|
125
|
+
|
126
|
+
it "should only count the last vote" do
|
127
|
+
|
128
|
+
subject.handle_response('person','yes')
|
129
|
+
subject.handle_response('person','yes')
|
130
|
+
subject.handle_response('person','no')
|
131
|
+
subject.results.should eq "1 'no'"
|
132
|
+
|
133
|
+
end
|
134
|
+
|
135
|
+
end
|
136
|
+
|
137
|
+
end
|
138
|
+
|
139
|
+
|
140
|
+
end
|
metadata
CHANGED
@@ -1,48 +1,47 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: robut-quiz
|
3
|
-
version: !ruby/object:Gem::Version
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.1
|
4
5
|
prerelease:
|
5
|
-
version: 0.2.0
|
6
6
|
platform: ruby
|
7
|
-
authors:
|
7
|
+
authors:
|
8
8
|
- Franklin Webber
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2011-11-06 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
16
15
|
name: robut
|
17
|
-
|
18
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: &70256048684460 !ruby/object:Gem::Requirement
|
19
17
|
none: false
|
20
|
-
requirements:
|
18
|
+
requirements:
|
21
19
|
- - ~>
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version:
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0.3'
|
24
22
|
type: :runtime
|
25
|
-
|
26
|
-
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70256048684460
|
25
|
+
description: ! ' Robut plugin that provides quiz asking functionality. '
|
27
26
|
email: franklin.webber@gmail.com
|
28
27
|
executables: []
|
29
|
-
|
30
28
|
extensions: []
|
31
|
-
|
32
|
-
extra_rdoc_files:
|
29
|
+
extra_rdoc_files:
|
33
30
|
- README.md
|
34
31
|
- History.txt
|
35
|
-
files:
|
32
|
+
files:
|
36
33
|
- Gemfile
|
37
34
|
- Guardfile
|
38
35
|
- History.txt
|
39
36
|
- README.md
|
37
|
+
- lib/choice.rb
|
40
38
|
- lib/polar.rb
|
41
39
|
- lib/question.rb
|
42
40
|
- lib/quiz.rb
|
43
41
|
- lib/range.rb
|
44
42
|
- lib/robut_quiz.rb
|
45
43
|
- robut-quiz.gemspec
|
44
|
+
- spec/choice_spec.rb
|
46
45
|
- spec/polar_spec.rb
|
47
46
|
- spec/question_spec.rb
|
48
47
|
- spec/quiz_spec.rb
|
@@ -50,32 +49,30 @@ files:
|
|
50
49
|
- spec/spec_helper.rb
|
51
50
|
homepage: http://github.com/burtlo/robut-quiz
|
52
51
|
licenses: []
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
--------------------------------------------------------------------------------"
|
57
|
-
rdoc_options:
|
52
|
+
post_install_message: ! "\n--------------------------------------------------------------------------------\n
|
53
|
+
\ ___\n !(O-0)! ~ Thank you for installing robut-quiz 0.2.1 / 2011-11-06\n >==[
|
54
|
+
]==<\n @ @\n\n Changes:\n \n * Added a choice question 'a', 'b', or 'c'\n
|
55
|
+
\ \n\n--------------------------------------------------------------------------------"
|
56
|
+
rdoc_options:
|
58
57
|
- --charset=UTF-8
|
59
|
-
require_paths:
|
58
|
+
require_paths:
|
60
59
|
- lib
|
61
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
60
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
62
61
|
none: false
|
63
|
-
requirements:
|
64
|
-
- -
|
65
|
-
- !ruby/object:Gem::Version
|
66
|
-
version:
|
67
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
68
67
|
none: false
|
69
|
-
requirements:
|
70
|
-
- -
|
71
|
-
- !ruby/object:Gem::Version
|
72
|
-
version:
|
68
|
+
requirements:
|
69
|
+
- - ! '>='
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '0'
|
73
72
|
requirements: []
|
74
|
-
|
75
73
|
rubyforge_project:
|
76
|
-
rubygems_version: 1.8.
|
74
|
+
rubygems_version: 1.8.6
|
77
75
|
signing_key:
|
78
76
|
specification_version: 3
|
79
77
|
summary: Quiz asking Robut
|
80
78
|
test_files: []
|
81
|
-
|