lita-lunch 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +21 -6
- data/lib/lita/handlers/lunch.rb +7 -8
- data/lita-lunch.gemspec +1 -1
- data/locales/en.yml +1 -0
- data/spec/lita/handlers/lunch_spec.rb +16 -2
- 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: 755cce4899f9b00ba7eab7bda7a0728fde4a483d
|
4
|
+
data.tar.gz: 3e633a2dbbea3000b0d8edf3aacf33cc5d3e398a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: abbbf314b32e5974c6b70ceb95415c0ec3a303ab1c1474b17317bf044a9459002ed2146a70249d18e25582aa0dc0a1dc2378786caf1d980497e078da921cfb7e
|
7
|
+
data.tar.gz: 8736ff2b04212544f823ea3820d8767b3534878057002dbe6d272ffbc4bf208acccba6e03a5be14ba3232126504506d86c58765175b6337e0eacf3efc3ad9c3c
|
data/README.md
CHANGED
@@ -5,6 +5,8 @@
|
|
5
5
|
|
6
6
|
A lita handler to help you pick where to go for lunch.
|
7
7
|
|
8
|
+
Populate Lita with a list of of your favourite lunch places, so next next time someone asks "where should I go for lunch?" you get a useful suggestion.
|
9
|
+
|
8
10
|
## Installation
|
9
11
|
|
10
12
|
Add lita-lunch to your Lita instance's Gemfile:
|
@@ -22,25 +24,38 @@ There is no additional configuration.
|
|
22
24
|
First you will to add some of your favorite lunch places:
|
23
25
|
|
24
26
|
```
|
25
|
-
lita lunch add the taco hut
|
26
|
-
|
27
|
+
You: lita lunch add the taco hut
|
28
|
+
Lita: taco hut has been added
|
29
|
+
|
30
|
+
You: lita lunch add Korean BBQ
|
31
|
+
Lita: Korean BBQ has been added
|
32
|
+
|
33
|
+
You: lita lunch add :hamburger:
|
34
|
+
Lita: :hamburger: has been added
|
27
35
|
```
|
28
36
|
|
29
37
|
Then you can get a lunch suggestion:
|
30
38
|
|
31
39
|
```
|
32
|
-
where should I go for lunch?
|
33
|
-
|
40
|
+
You: where should I go for lunch?
|
41
|
+
Lita: How about the taco hut?
|
42
|
+
|
43
|
+
You: lita lunch suggestion
|
44
|
+
Lita: How about :hamburger:?
|
34
45
|
```
|
35
46
|
|
36
47
|
You can list all stored places:
|
37
48
|
|
38
49
|
```
|
39
|
-
lita lunch places
|
50
|
+
You: lita lunch places
|
51
|
+
Lita: taco hut
|
52
|
+
Korean BBQ
|
53
|
+
:hamburger:
|
40
54
|
```
|
41
55
|
|
42
56
|
And remove unwanted places:
|
43
57
|
|
44
58
|
```
|
45
|
-
lita lunch remove the taco hut
|
59
|
+
You: lita lunch remove the taco hut
|
60
|
+
Lita: taco hut has been removed
|
46
61
|
```
|
data/lib/lita/handlers/lunch.rb
CHANGED
@@ -10,28 +10,27 @@ module Lita
|
|
10
10
|
route(/where should (we|i|they) go for lunch/i, :suggest, command: false)
|
11
11
|
|
12
12
|
def suggest(response)
|
13
|
-
|
14
|
-
random = redis.lindex(REDIS_KEY, index) || t('.fallback')
|
13
|
+
random = redis.srandmember(REDIS_KEY) || t('.fallback')
|
15
14
|
response.reply t('.suggest', place: random)
|
16
15
|
end
|
17
16
|
|
18
17
|
def list_suggestions(response)
|
19
|
-
values = redis.
|
20
|
-
response.reply values.size > 0 ? values.join("\n") : t('.empty')
|
18
|
+
values = redis.smembers(REDIS_KEY)
|
19
|
+
response.reply values.size > 0 ? values.sort.join("\n") : t('.empty')
|
21
20
|
end
|
22
21
|
|
23
22
|
def add_suggestion(response)
|
24
23
|
place = response.matches[0][0].strip
|
25
24
|
return if place.empty?
|
26
|
-
redis.
|
27
|
-
response.reply t('.added', place: place)
|
25
|
+
result = redis.sadd(REDIS_KEY, place)
|
26
|
+
response.reply result ? t('.added', place: place) : t('.duplicate', place: place)
|
28
27
|
end
|
29
28
|
|
30
29
|
def remove_suggestion(response)
|
31
30
|
place = response.matches[0][0].strip
|
32
31
|
return if place.empty?
|
33
|
-
result = redis.
|
34
|
-
response.reply result
|
32
|
+
result = redis.srem(REDIS_KEY, place)
|
33
|
+
response.reply result ? t('.removed', place: place) : t('.unfound')
|
35
34
|
end
|
36
35
|
|
37
36
|
def reset!
|
data/lita-lunch.gemspec
CHANGED
data/locales/en.yml
CHANGED
@@ -46,10 +46,18 @@ describe Lita::Handlers::Lunch, lita_handler: true do
|
|
46
46
|
end
|
47
47
|
|
48
48
|
it 'lists all the known places' do
|
49
|
-
send_command('lunch place add foo')
|
50
49
|
send_command('lunch place add bar')
|
50
|
+
send_command('lunch place add foo')
|
51
51
|
send_command('lunch places')
|
52
|
-
expect(replies.last).to eq "
|
52
|
+
expect(replies.last).to eq "bar\nfoo"
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'sorts the places it knows' do
|
56
|
+
send_command('lunch place add Zoo')
|
57
|
+
send_command('lunch place add Avec')
|
58
|
+
send_command('lunch place add Longs')
|
59
|
+
send_command('lunch places')
|
60
|
+
expect(replies.last).to eq "Avec\nLongs\nZoo"
|
53
61
|
end
|
54
62
|
end
|
55
63
|
|
@@ -67,6 +75,12 @@ describe Lita::Handlers::Lunch, lita_handler: true do
|
|
67
75
|
send_command('lunch place add ')
|
68
76
|
expect(replies.last).to eq nil
|
69
77
|
end
|
78
|
+
|
79
|
+
it 'will not add a duplicate place' do
|
80
|
+
send_command('lunch place add BurgerCzar')
|
81
|
+
send_command('lunch place add BurgerCzar')
|
82
|
+
expect(replies.last).to eq 'I already know about BurgerCzar'
|
83
|
+
end
|
70
84
|
end
|
71
85
|
|
72
86
|
describe 'removing a place' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lita-lunch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- neilang
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-08-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lita
|