alexa_skillsimulator 0.2.3 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +1 -3
- data/lib/alexa_skillsimulator.rb +11 -106
- metadata +7 -7
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c5c23ff59e4d782bdabcba05b7eb766a04d0d1f2
|
4
|
+
data.tar.gz: ffe92220388a0bd1c0a29ff119519bab719dac73
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 80e11d9382c2077fc9da08e0d48dbc27cf17c062ecf44fbb8f70dc5fbde58a9be97c5f299bef862b89e0c9b6990aea1b2a0276338ada08315cec81f77787d119
|
7
|
+
data.tar.gz: 49792f178f7a1afd677086ec35c46855c634d9e188c1ac2e504c639c415cce089c3ac551807a1c85239cf30fe51cff222a59d09b3a8ac6140b1684b64bd6a901
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
@@ -1,3 +1 @@
|
|
1
|
-
|
2
|
-
������=X}="Ew��
|
3
|
-
�¼ݮH�<����S�.�}!$K}?�e���M����u�ϩX�+���dS)��X}�g�6�
|
1
|
+
c��{i����wׅ�_8���H�,"lD�tO�iKC W��d�(�ok�d_�I�Hn�Je0�p/ʫ�Z��\yX�R����:��xjy4F��|N)�/��յ��[?V�>_�"�*Q瀘����g��V�Oo���R2�A�m�k��>��ֱZ��A� ͦ��Q�U��Jd],�W5[`%�+%q�n�_��B���lc��甋�5�^���0CA3��S-^}�b�S�
|
data/lib/alexa_skillsimulator.rb
CHANGED
@@ -2,8 +2,7 @@
|
|
2
2
|
|
3
3
|
# file: alexa_skillsimulator.rb
|
4
4
|
|
5
|
-
require '
|
6
|
-
require 'rest-client'
|
5
|
+
require 'askio'
|
7
6
|
require 'console_cmdr'
|
8
7
|
require 'securerandom'
|
9
8
|
|
@@ -77,29 +76,12 @@ end
|
|
77
76
|
|
78
77
|
class AlexaSkillSimulator
|
79
78
|
|
80
|
-
attr_reader :invocation
|
79
|
+
attr_reader :invocation
|
81
80
|
|
82
81
|
def initialize(manifest, model, debug: false, userid: nil, deviceid: nil)
|
83
82
|
|
83
|
+
@manifest, @model = manifest, model
|
84
84
|
@debug, @userid, @deviceid = debug, userid, deviceid
|
85
|
-
|
86
|
-
@locale = manifest['manifest']['publishingInformation']['locales']\
|
87
|
-
.keys.first
|
88
|
-
puts '@locale: ' + @locale.inspect if @debug
|
89
|
-
|
90
|
-
@invocation = model['interactionModel']['languageModel']['invocationName']
|
91
|
-
|
92
|
-
@utterances = model['interactionModel']['languageModel']\
|
93
|
-
['intents'].inject({}) do |r, intent|
|
94
|
-
intent['samples'].each {|x| r[x.downcase] = intent['name']}
|
95
|
-
r
|
96
|
-
end
|
97
|
-
|
98
|
-
puts ' debugger::@utterances: ' + @utterances.inspect if @debug
|
99
|
-
|
100
|
-
@endpoint = manifest['manifest']['apis']['custom']['endpoint']['uri']
|
101
|
-
|
102
|
-
puts ' debugger: @endpoint: ' + @endpoint.inspect if @debug
|
103
85
|
|
104
86
|
end
|
105
87
|
|
@@ -107,8 +89,11 @@ class AlexaSkillSimulator
|
|
107
89
|
|
108
90
|
puts
|
109
91
|
puts ' debugger: s: ' + s.inspect if @debug
|
92
|
+
|
93
|
+
aio = AskIO.new(@manifest, @model, debug: @debug, userid: @userid,
|
94
|
+
deviceid: @deviceid)
|
110
95
|
|
111
|
-
invocation =
|
96
|
+
invocation = aio.invocation.gsub(/ /,'\s')
|
112
97
|
|
113
98
|
regex = %r{
|
114
99
|
|
@@ -124,92 +109,12 @@ class AlexaSkillSimulator
|
|
124
109
|
|
125
110
|
return "hmmm, I don't know that one." unless r2
|
126
111
|
return respond() if r2[:action] == 'open'
|
127
|
-
|
128
|
-
r =
|
129
|
-
puts ' debugger: r: ' + r.inspect if @debug
|
130
|
-
puts
|
131
|
-
|
132
|
-
if r then
|
133
|
-
|
134
|
-
puts ' debugger: your intent is to ' + r if @debug
|
135
|
-
|
136
|
-
respond(r)
|
137
|
-
|
138
|
-
else
|
139
|
-
"I'm sorry I didn't understand what you said"
|
140
|
-
end
|
141
|
-
|
142
|
-
end
|
143
|
-
|
144
|
-
|
145
|
-
private
|
146
|
-
|
147
|
-
def post(url, h)
|
148
|
-
|
149
|
-
r = RestClient.post(url, h.to_json,
|
150
|
-
headers={content_type: :json, accept: :json})
|
151
|
-
JSON.parse r.body, symbolize_names: true
|
152
|
-
|
153
|
-
end
|
154
|
-
|
155
|
-
def respond(intent=nil)
|
156
|
-
|
157
|
-
h = {"version"=>"1.0",
|
158
|
-
"session"=>
|
159
|
-
{"new"=>true,
|
160
|
-
"sessionId"=>"amzn1.echo-api.session.1",
|
161
|
-
"application"=>
|
162
|
-
{"applicationId"=>"amzn1.ask.skill.0"},
|
163
|
-
"user"=>
|
164
|
-
{"userId"=>
|
165
|
-
"amzn1.ask.account.I"}},
|
166
|
-
"context"=>
|
167
|
-
{"System"=>
|
168
|
-
{"application"=>
|
169
|
-
{"applicationId"=>
|
170
|
-
"amzn1.ask.skill.0"},
|
171
|
-
"user"=>
|
172
|
-
{"userId"=>
|
173
|
-
"amzn1.ask.account.I"},
|
174
|
-
"device"=>
|
175
|
-
{"deviceId"=>
|
176
|
-
"amzn1.ask.device.A",
|
177
|
-
"supportedInterfaces"=>{}},
|
178
|
-
"apiEndpoint"=>"https://api.eu.amazonalexa.com",
|
179
|
-
"apiAccessToken"=>
|
180
|
-
"A"}},
|
181
|
-
"request"=> {}
|
182
|
-
}
|
183
|
-
|
184
|
-
h['session']['user']['userId'] = @userid if @userid
|
185
|
-
h['context']['System']['user']['userId'] = @userid if @userid
|
186
|
-
|
187
|
-
h['context']['System']['device']['deviceId'] = @deviceid if @deviceid
|
188
|
-
|
189
|
-
|
190
|
-
h['request'] = if intent then
|
191
|
-
{
|
192
|
-
"type"=>"IntentRequest",
|
193
|
-
"requestId"=>"amzn1.echo-api.request.0",
|
194
|
-
"timestamp"=>Time.now.utc.iso8601,
|
195
|
-
"locale"=>@locale,
|
196
|
-
"intent"=>{"name"=>intent, "confirmationStatus"=>"NONE"},
|
197
|
-
"dialogState"=>"STARTED"
|
198
|
-
}
|
199
|
-
else
|
200
|
-
{
|
201
|
-
"type"=>"LaunchRequest",
|
202
|
-
"requestId"=>"amzn1.echo-api.request.a",
|
203
|
-
"timestamp"=> Time.now.utc.iso8601,
|
204
|
-
"locale"=>@locale,
|
205
|
-
"shouldLinkResultBeReturned"=>false
|
206
|
-
}
|
207
|
-
end
|
112
|
+
|
113
|
+
r = aio.ask r2[:request]
|
208
114
|
|
209
|
-
r
|
210
|
-
puts ' degbugger: r: ' + r.inspect if @debug
|
115
|
+
r ? r : "I'm sorry I didn't understand what you said"
|
211
116
|
|
212
|
-
r[:response][:outputSpeech][:text]
|
213
117
|
end
|
214
118
|
|
119
|
+
|
215
120
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: alexa_skillsimulator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -30,28 +30,28 @@ cert_chain:
|
|
30
30
|
gYx7JRswmPvGXlAKr/p3KoEauefzGu8oNgv4HYyTterelwGlwnWJORM09hCjSoNv
|
31
31
|
3NE=
|
32
32
|
-----END CERTIFICATE-----
|
33
|
-
date: 2018-07-
|
33
|
+
date: 2018-07-30 00:00:00.000000000 Z
|
34
34
|
dependencies:
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
|
-
name:
|
36
|
+
name: askio
|
37
37
|
requirement: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
39
|
- - "~>"
|
40
40
|
- !ruby/object:Gem::Version
|
41
|
-
version: '
|
41
|
+
version: '0.1'
|
42
42
|
- - ">="
|
43
43
|
- !ruby/object:Gem::Version
|
44
|
-
version:
|
44
|
+
version: 0.1.0
|
45
45
|
type: :runtime
|
46
46
|
prerelease: false
|
47
47
|
version_requirements: !ruby/object:Gem::Requirement
|
48
48
|
requirements:
|
49
49
|
- - "~>"
|
50
50
|
- !ruby/object:Gem::Version
|
51
|
-
version: '
|
51
|
+
version: '0.1'
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 0.1.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: console_cmdr
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
metadata.gz.sig
CHANGED
Binary file
|