lita-alexa-news-recorder 0.1.5 → 0.1.6

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: 826ab403d2821830bdf7c65957298acff36b3981
4
- data.tar.gz: afe54aaa595ca4ba0c8993eb8f48b61c3fcdc0ee
3
+ metadata.gz: 085b46624e5a01c0b1c17ce7e173e549286ce92f
4
+ data.tar.gz: 5eb387e7e03585cb1c59d7ed357be8e993f848e4
5
5
  SHA512:
6
- metadata.gz: a27c5eb58bd20be15631feb17186e47699c6c662fbfe4f8af2c51b9c1b2e4c8fd07c31bb71078d4962541e3740dae062ed3476ee72d3fb244c03681f0637aab3
7
- data.tar.gz: a0bbcf29fe3b11210156a0c2dfcfe16540fb67aaa6fa8ccd65d42e30ef1cbf857e108cdf8dcbb8f877186205f51c52108c82bf011ef689ad3292959fd75c3ac3
6
+ metadata.gz: ebb003f62ff81faf9a584fc6caa576ee2ebeb5e23758bbce32bfabd47ff4df8215d2cca46e2ab31516a0c7ac2de29bbdc598f4338a172aac35199de466746bb5
7
+ data.tar.gz: c0ce9929f87569703ba2aa57de1d1fac9a900102e95293c8b1af12688e39c42b060640d82bf756490467eef257fd7fb57e5641de8e568dccfd6a694d0103705c
data/.travis.yml CHANGED
@@ -1,8 +1,12 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.0.0
4
- script: bundle exec rake
5
- before_install:
6
- - gem update --system
3
+ - 2.2.6
4
+ - 2.3.3
5
+
6
+ install:
7
+ - bundle install
8
+
7
9
  services:
8
10
  - redis-server
11
+
12
+ script: rspec spec
@@ -6,15 +6,8 @@ module Lita
6
6
  class AlexaNewsRecorder < Handler
7
7
  http.post '/alexa/recorder', :record_message
8
8
 
9
+ # Rack::Request, Rack::Response
9
10
  def record_message(request, response)
10
- check_for_publisher!
11
-
12
- Lita.logger.debug "Inbound request params: "
13
- Lita.logger.debug request.params
14
- Lita.logger.debug "Inbound request body: "
15
-
16
- Lita.logger.debug request.body.string # it's a StringIO
17
-
18
11
  message = extract_message(request.body.string)
19
12
 
20
13
  robot.trigger(:save_alexa_message, username: 'Alexa News Recorder', message: message)
@@ -22,11 +15,6 @@ module Lita
22
15
  response.write JSON.dump(alexa_response(message))
23
16
  end
24
17
 
25
- def check_for_publisher!
26
- return if robot.handlers.include?(Lita::Handlers::AlexaNewsPublisher)
27
- raise ConfigurationError, "Must install AlexaNewsPublisher handler to make me work!"
28
- end
29
-
30
18
  def extract_message(payload)
31
19
  parsed = JSON.parse(payload)
32
20
 
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "lita-alexa-news-recorder"
3
- spec.version = "0.1.5"
3
+ spec.version = "0.1.6"
4
4
  spec.authors = ["Daniel J. Pritchett"]
5
5
  spec.email = ["dpritchett@gmail.com"]
6
6
  spec.description = "Records voice memos via Alexa and transcribes them for publishing to an Alexa Flash Briefing"
@@ -0,0 +1,51 @@
1
+ {
2
+ "session": {
3
+ "new": false,
4
+ "sessionId": "SessionId.bd30aa35-f5e1-4970-8b09-dfaf495b0fff",
5
+ "application": {
6
+ "applicationId": "amzn1.ask.skill.052f4499-460c-482e-a46f-6c6cbbb269bc"
7
+ },
8
+ "attributes": {
9
+ "supportedHoriscopePeriods": {
10
+ "daily": true,
11
+ "weekly": false,
12
+ "monthly": false
13
+ }
14
+ },
15
+ "user": {
16
+ "userId": "amzn1.ask.account.AFOTF7K2PX7RO6PYSDICEFORTI65BUVYGZTP5MB2G7DFFB7OWXDVGTIBWRPT7A43MJDKVJSIPNJAPHXNLMMQQ4O72RYM4ZALKLG7IHOMO7PPZ4YDXUDZHXVU5EAPYR6QJOMUL6G5YXMTUG2RF7PV2SPTZPXQ62TZW4S66X2GODEZBEOGD2HWPI3O4ELCG2UQY35PX5RZYJLS6OY"
17
+ }
18
+ },
19
+ "request": {
20
+ "type": "IntentRequest",
21
+ "requestId": "EdwRequestId.b6a27fb6-0d84-4104-9af8-f2504d8a03fd",
22
+ "intent": {
23
+ "name": "RecordMessage",
24
+ "slots": {
25
+ "Message": {
26
+ "name": "Message",
27
+ "value": "hi dad"
28
+ }
29
+ }
30
+ },
31
+ "locale": "en-US",
32
+ "timestamp": "2017-08-20T21:25:18Z"
33
+ },
34
+ "context": {
35
+ "AudioPlayer": {
36
+ "playerActivity": "IDLE"
37
+ },
38
+ "System": {
39
+ "application": {
40
+ "applicationId": "amzn1.ask.skill.052f4499-460c-482e-a46f-6c6cbbb269bc"
41
+ },
42
+ "user": {
43
+ "userId": "amzn1.ask.account.AFOTF7K2PX7RO6PYSDICEFORTI65BUVYGZTP5MB2G7DFFB7OWXDVGTIBWRPT7A43MJDKVJSIPNJAPHXNLMMQQ4O72RYM4ZALKLG7IHOMO7PPZ4YDXUDZHXVU5EAPYR6QJOMUL6G5YXMTUG2RF7PV2SPTZPXQ62TZW4S66X2GODEZBEOGD2HWPI3O4ELCG2UQY35PX5RZYJLS6OY"
44
+ },
45
+ "device": {
46
+ "supportedInterfaces": {}
47
+ }
48
+ }
49
+ },
50
+ "version": "1.0"
51
+ }
@@ -1,4 +1,42 @@
1
1
  require "spec_helper"
2
+ require 'pry'
3
+ require 'date'
2
4
 
3
5
  describe Lita::Handlers::AlexaNewsRecorder, lita_handler: true do
6
+ let(:robot) { Lita::Robot.new(registry) }
7
+
8
+ subject { described_class.new(robot) }
9
+
10
+ describe 'routes' do
11
+ it { is_expected.to route_http(:post, "/alexa/recorder").to(:record_message) }
12
+ end
13
+
14
+ describe ':record_message' do
15
+ # "hello, Alexa" fixture
16
+ let(:amazon_formatted_json_request_body) { open("./spec/fixtures/inbound_message.json").read }
17
+
18
+ it 'can accept an inbound message in alexa dictation format' do
19
+ response = http.post('/alexa/recorder', amazon_formatted_json_request_body)
20
+ body = JSON.parse(response.body, symbolize_names: true)
21
+
22
+ expect(body.dig(:response, :outputSpeech, :text)).to include('hi dad')
23
+ end
24
+
25
+ it 'emits an event to trigger another handler to save alexa messages' do
26
+ expect(robot).to receive(:trigger).with(:save_alexa_message, {:username=>"Alexa News Recorder", :message=>"hi dad"})
27
+
28
+ response = http.post('/alexa/recorder', amazon_formatted_json_request_body)
29
+ end
30
+ end
31
+
32
+ describe ':alexa_response' do
33
+ let(:body) { 'responding to alexa' }
34
+
35
+ it 'should return an alexa-shaped response hash with the supplied message body' do
36
+ result = subject.alexa_response(body)
37
+
38
+ expect(result.dig(:response, :outputSpeech, :text)).to include(body)
39
+ end
40
+ end
41
+
4
42
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lita-alexa-news-recorder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel J. Pritchett
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-20 00:00:00.000000000 Z
11
+ date: 2017-08-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lita
@@ -153,6 +153,7 @@ files:
153
153
  - lib/lita/handlers/alexa_news_recorder.rb
154
154
  - lita-alexa-news-recorder.gemspec
155
155
  - locales/en.yml
156
+ - spec/fixtures/inbound_message.json
156
157
  - spec/lita/handlers/alexa_news_recorder_spec.rb
157
158
  - spec/spec_helper.rb
158
159
  - templates/.gitkeep
@@ -183,5 +184,6 @@ specification_version: 4
183
184
  summary: Records voice memos via Alexa and transcribes them for publishing to an Alexa
184
185
  Flash Briefing
185
186
  test_files:
187
+ - spec/fixtures/inbound_message.json
186
188
  - spec/lita/handlers/alexa_news_recorder_spec.rb
187
189
  - spec/spec_helper.rb