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: dbb5d83948e34954e3362634fb4eb164def1738c
4
- data.tar.gz: 8a54bd817965a9392ba78a9cce1631ff42c78834
3
+ metadata.gz: 1e8deb8e24128cdaaa437d0300fdf8813a7eafc8
4
+ data.tar.gz: a5cf42788f4069770e16d39df1f16bb02c76f93b
5
5
  SHA512:
6
- metadata.gz: 103d1a396161050c51ac0c3aecc38e2cdc62b97ffc1fdf4d1dc6d3e18167187715661e8551098d3a64d9d87101b99561bf2d08146d139e891d803df4a4d4aab6
7
- data.tar.gz: 39292bdb13b8c5bbeb392ac7f44601a4bd855cc363ab5580d249fc26880014e2dfe91effaa8c63838f09a5cda48028dcaa19f33e44d9235fb80c5f30e1b70f9f
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)
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = 'lita-onewheel-beer-wework'
3
- spec.version = '1.0.0'
3
+ spec.version = '1.1.0'
4
4
  spec.authors = ['Andrew Kreps']
5
5
  spec.email = ['andrew.kreps@gmail.com']
6
6
  spec.description = 'Basic key/value store for wework beers.'
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lita-onewheel-beer-wework
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kreps