alexa_rubykit 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 +4 -4
- data/Gemfile.lock +3 -12
- data/lib/alexa_rubykit.rb +2 -0
- data/lib/alexa_rubykit/intent_request.rb +2 -1
- data/lib/alexa_rubykit/launch_request.rb +2 -0
- data/lib/alexa_rubykit/request.rb +2 -1
- data/lib/alexa_rubykit/response.rb +18 -4
- data/lib/alexa_rubykit/session.rb +5 -0
- data/lib/alexa_rubykit/session_ended_request.rb +2 -0
- data/lib/alexa_rubykit/version.rb +1 -1
- metadata +15 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3748981d0a9bc0fc1bf4f5b717d167641dcd697a
|
4
|
+
data.tar.gz: 78ada1f9c255e3531fcc578ff6dd5523c8711dc5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2adaf509979b0c18c0db6f64de1416a63878eb87d52bfae7a84bed8db2ae5a78c3dd2b52f6f74351aefb966a15a1100a4d14bc3f2827b0e9ef03219cf2740ad8
|
7
|
+
data.tar.gz: 4fb73941be833903ec6dfb2337ec3aab257e3938006d51c278fc399002358094b8165768aba82554dc3be186e830f7ca75889710a1a364251134e3ef56902b93
|
data/Gemfile.lock
CHANGED
@@ -1,18 +1,14 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
alexa_rubykit (1.0.0
|
4
|
+
alexa_rubykit (1.0.0)
|
5
5
|
bundler (~> 1.7)
|
6
6
|
rake (~> 10.0)
|
7
|
-
sinatra (~> 1.4)
|
8
7
|
|
9
8
|
GEM
|
10
9
|
remote: https://rubygems.org/
|
11
10
|
specs:
|
12
11
|
diff-lcs (1.2.5)
|
13
|
-
rack (1.6.1)
|
14
|
-
rack-protection (1.5.3)
|
15
|
-
rack
|
16
12
|
rake (10.4.2)
|
17
13
|
rspec (3.2.0)
|
18
14
|
rspec-core (~> 3.2.0)
|
@@ -27,16 +23,11 @@ GEM
|
|
27
23
|
diff-lcs (>= 1.2.0, < 2.0)
|
28
24
|
rspec-support (~> 3.2.0)
|
29
25
|
rspec-support (3.2.2)
|
30
|
-
sinatra (1.4.6)
|
31
|
-
rack (~> 1.4)
|
32
|
-
rack-protection (~> 1.4)
|
33
|
-
tilt (>= 1.3, < 3)
|
34
|
-
tilt (2.0.1)
|
35
26
|
|
36
27
|
PLATFORMS
|
37
28
|
ruby
|
38
29
|
|
39
30
|
DEPENDENCIES
|
40
31
|
alexa_rubykit!
|
41
|
-
rspec (~> 3.2.0)
|
42
|
-
rspec-mocks (~> 3.2.0)
|
32
|
+
rspec (~> 3.2, >= 3.2.0)
|
33
|
+
rspec-mocks (~> 3.2, >= 3.2.0)
|
data/lib/alexa_rubykit.rb
CHANGED
@@ -6,10 +6,12 @@ require 'alexa_rubykit/launch_request'
|
|
6
6
|
require 'alexa_rubykit/session_ended_request'
|
7
7
|
|
8
8
|
module AlexaRubykit
|
9
|
+
# Prints a JSON object.
|
9
10
|
def self.print_json(json)
|
10
11
|
p json
|
11
12
|
end
|
12
13
|
|
14
|
+
# Prints the Gem version.
|
13
15
|
def self.print_version
|
14
16
|
p AlexaRubykit::VERSION
|
15
17
|
end
|
@@ -35,6 +35,7 @@ module AlexaRubykit
|
|
35
35
|
slot
|
36
36
|
end
|
37
37
|
|
38
|
+
# Outputs the Intent Name, request Id and slot information.
|
38
39
|
def to_s
|
39
40
|
"IntentRequest: #{@name} requestID: #{request_id} Slots: #{@slots}"
|
40
41
|
end
|
@@ -51,7 +52,7 @@ module AlexaRubykit
|
|
51
52
|
@value = value
|
52
53
|
end
|
53
54
|
|
54
|
-
#
|
55
|
+
# Outputs Slot name and value.
|
55
56
|
def to_s
|
56
57
|
"Slot Name: #{@name}, Value: #{value}"
|
57
58
|
end
|
@@ -8,11 +8,13 @@ module AlexaRubykit
|
|
8
8
|
require 'alexa_rubykit/session'
|
9
9
|
attr_accessor :version, :response, :shouldEndSession, :type, :session
|
10
10
|
|
11
|
+
# Adds a specific session.
|
11
12
|
def add_session(session)
|
12
13
|
@session = session
|
13
14
|
end
|
14
15
|
end
|
15
16
|
|
17
|
+
# Builds a new request for Alexa.
|
16
18
|
def self.build_request(json_request)
|
17
19
|
raise ArgumentError, 'Invalid Alexa Request.' unless AlexaRubykit.valid_alexa?(json_request)
|
18
20
|
@request = nil
|
@@ -32,7 +34,6 @@ module AlexaRubykit
|
|
32
34
|
@request
|
33
35
|
end
|
34
36
|
|
35
|
-
|
36
37
|
# Let's monkey patch Hash.
|
37
38
|
refine Hash do
|
38
39
|
# Take keys of hash and transform those to a symbols
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module AlexaRubykit
|
2
2
|
class Response
|
3
3
|
require 'json'
|
4
|
-
attr_accessor :version, :session, :response_object, :session_attributes, :speech, :response, :card
|
4
|
+
attr_accessor :version, :session, :response_object, :session_attributes, :speech, :reprompt, :response, :card
|
5
5
|
|
6
6
|
# Every response needs a shouldendsession and a version attribute
|
7
7
|
# We initialize version to 1.0, use add_version to set your own.
|
@@ -19,6 +19,12 @@ module AlexaRubykit
|
|
19
19
|
@speech = { :type => 'PlainText', :text => speech_text }
|
20
20
|
@speech
|
21
21
|
end
|
22
|
+
|
23
|
+
def add_reprompt(speech_text)
|
24
|
+
@reprompt = { "outputSpeech" => { :type => 'PlainText', :text => speech_text } }
|
25
|
+
@reprompt
|
26
|
+
end
|
27
|
+
|
22
28
|
#
|
23
29
|
#"type": "string",
|
24
30
|
# "title": "string",
|
@@ -47,6 +53,13 @@ module AlexaRubykit
|
|
47
53
|
{ :outputSpeech => output_speech, :shouldEndSession => end_session }
|
48
54
|
end
|
49
55
|
|
56
|
+
# Incorporates reprompt in the SDK 2015-05
|
57
|
+
def say_response_with_reprompt(speech, reprompt_speech, end_session = true)
|
58
|
+
output_speech = add_speech(speech)
|
59
|
+
reprompt_speech = add_reprompt(reprompt_speech)
|
60
|
+
{ :outputSpeech => output_speech, :reprompt => reprompt_speech, :shouldEndSession => end_session }
|
61
|
+
end
|
62
|
+
|
50
63
|
|
51
64
|
# Creates a session object. We pretty much only use this in testing.
|
52
65
|
def build_session
|
@@ -63,14 +76,15 @@ module AlexaRubykit
|
|
63
76
|
@response = Hash.new
|
64
77
|
@response[:outputSpeech] = @speech unless @speech.nil?
|
65
78
|
@response[:card] = @card unless @card.nil?
|
79
|
+
@response[:reprompt] = @reprompt unless session_end && @reprompt.nil?
|
66
80
|
@response[:shouldEndSession] = session_end
|
67
81
|
@response
|
68
82
|
end
|
69
83
|
|
70
84
|
# Builds a response.
|
71
85
|
# Takes the version, response and should_end_session variables and builds a JSON object.
|
72
|
-
def build_response
|
73
|
-
response_object = build_response_object
|
86
|
+
def build_response(session_end = true)
|
87
|
+
response_object = build_response_object(session_end)
|
74
88
|
response = Hash.new
|
75
89
|
response[:version] = @version
|
76
90
|
response[:sessionAttributes] = @session_attributes unless @session_attributes.empty?
|
@@ -78,7 +92,7 @@ module AlexaRubykit
|
|
78
92
|
response.to_json
|
79
93
|
end
|
80
94
|
|
81
|
-
#
|
95
|
+
# Outputs the version, session object and the response object.
|
82
96
|
def to_s
|
83
97
|
"Version => #{@version}, SessionObj => #{@session}, Response => #{@response}"
|
84
98
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: alexa_rubykit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Damian Finol
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-05-
|
11
|
+
date: 2015-05-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -38,25 +38,14 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '10.0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: sinatra
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '1.4'
|
48
|
-
type: :runtime
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "~>"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '1.4'
|
55
41
|
- !ruby/object:Gem::Dependency
|
56
42
|
name: rspec
|
57
43
|
requirement: !ruby/object:Gem::Requirement
|
58
44
|
requirements:
|
59
45
|
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.2'
|
48
|
+
- - ">="
|
60
49
|
- !ruby/object:Gem::Version
|
61
50
|
version: 3.2.0
|
62
51
|
type: :development
|
@@ -64,6 +53,9 @@ dependencies:
|
|
64
53
|
version_requirements: !ruby/object:Gem::Requirement
|
65
54
|
requirements:
|
66
55
|
- - "~>"
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '3.2'
|
58
|
+
- - ">="
|
67
59
|
- !ruby/object:Gem::Version
|
68
60
|
version: 3.2.0
|
69
61
|
- !ruby/object:Gem::Dependency
|
@@ -71,6 +63,9 @@ dependencies:
|
|
71
63
|
requirement: !ruby/object:Gem::Requirement
|
72
64
|
requirements:
|
73
65
|
- - "~>"
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '3.2'
|
68
|
+
- - ">="
|
74
69
|
- !ruby/object:Gem::Version
|
75
70
|
version: 3.2.0
|
76
71
|
type: :development
|
@@ -78,6 +73,9 @@ dependencies:
|
|
78
73
|
version_requirements: !ruby/object:Gem::Requirement
|
79
74
|
requirements:
|
80
75
|
- - "~>"
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '3.2'
|
78
|
+
- - ">="
|
81
79
|
- !ruby/object:Gem::Version
|
82
80
|
version: 3.2.0
|
83
81
|
description: Alexa Ruby Kit with examples
|
@@ -120,7 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
120
118
|
version: '0'
|
121
119
|
requirements: []
|
122
120
|
rubyforge_project:
|
123
|
-
rubygems_version: 2.4.
|
121
|
+
rubygems_version: 2.4.4
|
124
122
|
signing_key:
|
125
123
|
specification_version: 4
|
126
124
|
summary: Alexa Ruby Kit
|