lita-onewheel-beer-wework 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1e8deb8e24128cdaaa437d0300fdf8813a7eafc8
|
4
|
+
data.tar.gz: a5cf42788f4069770e16d39df1f16bb02c76f93b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 95b259ba4bfc65d3cf53d9fd38c214760ab1a23f69926d45ced12c2222bedd3e2aff8829a6ae01ecd69bcc0c88ff4ac645abf757477100855ed7a0ac1b3964c9
|
7
|
+
data.tar.gz: 800a7349c1e86e9cacd0703642b17046d60b49b5db7037744f94b0fd635e0650445c72e3eee3c6c2fab8c0c63c8f18e6b324e7e1825d53d7d999071b95af94f2
|
@@ -19,6 +19,8 @@ module Lita
|
|
19
19
|
command: true,
|
20
20
|
help: {'!wework 2fS ' => 'fetch the beer for 2fS'}
|
21
21
|
|
22
|
+
http.get '/wework', :get_json_beers # For aaronpk and Loqi
|
23
|
+
|
22
24
|
def command_add_beer(response)
|
23
25
|
key = response.matches[0][0].downcase
|
24
26
|
unless LOCATIONS.include? key
|
@@ -53,7 +55,6 @@ module Lita
|
|
53
55
|
end
|
54
56
|
|
55
57
|
def command_list_beers(response)
|
56
|
-
test = redis.hgetall(REDIS_KEY)
|
57
58
|
LOCATIONS.each do |floor|
|
58
59
|
if (data = redis.hget(REDIS_KEY, floor))
|
59
60
|
floor, keg_name = get_floor_and_keg_name(floor => data)
|
@@ -62,6 +63,16 @@ module Lita
|
|
62
63
|
end
|
63
64
|
end
|
64
65
|
|
66
|
+
def get_json_beers(request, response)
|
67
|
+
all_beers = []
|
68
|
+
LOCATIONS.each do |floor|
|
69
|
+
if (data = redis.hget(REDIS_KEY, floor))
|
70
|
+
all_beers.push floor => JSON.parse(data)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
response.body = all_beers.to_json
|
74
|
+
end
|
75
|
+
|
65
76
|
def get_values_that_start_with_key(key)
|
66
77
|
values = []
|
67
78
|
all = redis.hgetall(REDIS_KEY)
|
@@ -3,6 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe Lita::Handlers::OnewheelBeerWework, lita_handler: true do
|
4
4
|
it { is_expected.to route_command('wework') }
|
5
5
|
it { is_expected.to route_command('wework 2fS Breakfast Stout') }
|
6
|
+
it { is_expected.to route_http(:get, '/wework') }
|
6
7
|
|
7
8
|
it 'sets a beer' do
|
8
9
|
send_command 'wework 2fs Breakfast Stout'
|
@@ -27,4 +28,11 @@ describe Lita::Handlers::OnewheelBeerWework, lita_handler: true do
|
|
27
28
|
expect(replies[2]).to eq('2fs: one')
|
28
29
|
expect(replies.last).to eq('2fn: two')
|
29
30
|
end
|
31
|
+
|
32
|
+
# it 'wework http routes' do
|
33
|
+
# send_command 'wework 2fs one'
|
34
|
+
# send_command 'wework 2fN two'
|
35
|
+
# response = http.get('/wework')
|
36
|
+
# expect(JSON.parse response.body).to eq('bar')
|
37
|
+
# end
|
30
38
|
end
|