lita-alexa-news-publisher 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/lita/handlers/alexa_news_publisher.rb +11 -1
- data/lita-alexa-news-publisher.gemspec +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 097566f85426f2859b7ec5ec8b1b5602fb64e905
|
4
|
+
data.tar.gz: 2cbe5af8fc3837e1ea9d850d2a9f383eb5f41486
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b10195d095fee73146deb3445d68387ad060c3812665638c0947bea603cd6092eb61433d4bfb9c04b8fbd3ec00d08083fc3faea7e25eb7de269fefe938aa4de9
|
7
|
+
data.tar.gz: 8b0d74459eb07705d44a1a86899c671b07dc6c46afcc7a8fcf6213d06e93832b3d05f9811571f2df826549061b343b3cbe62153fa208c0c4bf33d7d7fdfd6448
|
@@ -8,11 +8,12 @@ module Lita
|
|
8
8
|
http.get '/alexa/newsfeed/:username', :user_newsfeed
|
9
9
|
|
10
10
|
STORE_KEY = 'alexa_newsfeed'
|
11
|
+
MAX_MESSAGE_COUNT = 100
|
11
12
|
|
12
13
|
def user_newsfeed(request, response)
|
13
14
|
username = request.env["router.params"][:username]
|
14
15
|
|
15
|
-
messages = Lita.redis.lrange(STORE_KEY, 0,
|
16
|
+
messages = Lita.redis.lrange(STORE_KEY, 0, MAX_MESSAGE_COUNT)
|
16
17
|
|
17
18
|
formatted_messages = messages.map { |m| alexify m }
|
18
19
|
|
@@ -47,6 +48,8 @@ module Lita
|
|
47
48
|
|
48
49
|
begin
|
49
50
|
Lita.redis.rpush(STORE_KEY, JSON.dump(payload))
|
51
|
+
|
52
|
+
prune_message_list!
|
50
53
|
rescue Redis::CommandError
|
51
54
|
@retries ||= 0
|
52
55
|
@retries += 1
|
@@ -71,6 +74,13 @@ module Lita
|
|
71
74
|
response.reply("Saved message for Alexa: [#{msg}]")
|
72
75
|
end
|
73
76
|
|
77
|
+
# only store the latest N messages in redis at a time
|
78
|
+
def prune_message_list!
|
79
|
+
while Lita.redis.llen(STORE_KEY) > MAX_MESSAGE_COUNT do
|
80
|
+
Lita.redis.lpop(STORE_KEY)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
74
84
|
Lita.register_handler(self)
|
75
85
|
end
|
76
86
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |spec|
|
2
2
|
spec.name = "lita-alexa-news-publisher"
|
3
|
-
spec.version = "0.1.
|
3
|
+
spec.version = "0.1.4"
|
4
4
|
spec.authors = ["Daniel J. Pritchett"]
|
5
5
|
spec.email = ["dpritchett@gmail.com"]
|
6
6
|
spec.description = "Allows Lita users to publish a .plan-style personal news feed for consumption as an Alexa Flash Briefing source"
|