alexa_skillsimulator 0.2.2 → 0.4.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
- SHA1:
3
- metadata.gz: eda4c8521fe356ac3e21e4eb12ff8b34f3cebb90
4
- data.tar.gz: 19569c55e3729175c9ca234e9dce2053ca5b96cb
2
+ SHA256:
3
+ metadata.gz: 93bff20714288108b6afba43e7c5a847456157a64c259202205930d5147c8132
4
+ data.tar.gz: e9b5a47d744ff6f6019f076ee2621321cbc41954a3db269b5111ad3ea38e1497
5
5
  SHA512:
6
- metadata.gz: ce586ca8ba2d70fe334a63575331611136e0f9f449fdeee6a605cb5e62c4afb02668834317016b2eee2f35aeea2d189018d0e7e5759560b319c2f00217639b9e
7
- data.tar.gz: 7f3fdafe5ecea8292ee26375ad78646f04c356535eeefac50fc5facce88daab7e6d03cbe057ab9d7a2ba5fe94d232934ab6c9d720aa61c1aee4d598e0f114b02
6
+ metadata.gz: 295d8c8620ee033b6beabc9bc16c24c61c7a81b644b4ba6999b64854498ccc51de6c5597ad32802fbb2e4f4afb87814722f00a7467dc719f7145849ab2bb322b
7
+ data.tar.gz: a30ab51ae824341478072bae9118269b8c6fc6282e181a44525db346afd0a25db0a98eeea79df06a9d2ddcee766a6bff585a215ea30d226fd9f413ad7a9d2b46
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -2,17 +2,16 @@
2
2
 
3
3
  # file: alexa_skillsimulator.rb
4
4
 
5
- require 'time'
6
- require 'rest-client'
7
5
  require 'console_cmdr'
8
6
  require 'securerandom'
7
+ require 'alexa_utteranceresponder'
9
8
 
10
9
 
11
10
  class AlexaShell < ConsoleCmdr
12
11
 
13
- def initialize(manifest, model, debug: false, userid: nil, deviceid: nil)
12
+ def initialize(modelstxt=[], debug: false, userid: nil, deviceid: nil)
14
13
 
15
- @alexa = AlexaSkillSimulator.new(manifest, model, debug: debug,
14
+ @alexa = AlexaSkillSimulator.new(modelstxt, debug: debug,
16
15
  userid: userid, deviceid: deviceid)
17
16
  super(debug: debug)
18
17
 
@@ -62,7 +61,7 @@ class AlexaShell < ConsoleCmdr
62
61
  return (@running=false; '' )
63
62
 
64
63
  else
65
- return false
64
+ return @alexa.ask command
66
65
  end
67
66
 
68
67
  end
@@ -77,139 +76,23 @@ end
77
76
 
78
77
  class AlexaSkillSimulator
79
78
 
80
- attr_reader :invocation, :utterances
79
+ attr_reader :invocation
80
+ attr_accessor :deviceid
81
81
 
82
- def initialize(manifest, model, debug: false, userid: nil, deviceid: nil)
82
+ def initialize(modelstxt=[], debug: false, userid: nil, deviceid: nil)
83
83
 
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
84
+ @debug, @deviceid = debug, deviceid
85
+ @aur = AlexaUtteranceResponder.new(modelstxt, userid: userid, deviceid: deviceid, debug: true)
103
86
 
104
87
  end
105
88
 
106
- def ask(s)
89
+ def ask(s, deviceid: @deviceid, &blk)
107
90
 
108
91
  puts
109
92
  puts ' debugger: s: ' + s.inspect if @debug
110
-
111
- invocation = @invocation.gsub(/ /,'\s')
112
-
113
- regex = %r{
114
-
115
- (?<ask>(?<action>tell|ask)\s#{invocation}\s(?<request>.*)){0}
116
- (?<open>(?<action>open)\s#{invocation}){0}
117
- \g<ask>|\g<open>
118
- }x
119
-
120
- r2 = s.downcase.match(regex)
121
-
122
- puts ' debugger: r2: ' + r2.inspect if @debug
123
- puts
124
-
125
- return "hmmm, I don't know that one." unless r2
126
- return respond() if r2[:action] == 'open'
127
-
128
- r = @utterances[r2[:request]]
129
- puts ' debugger: r: ' + r.inspect if @debug
130
- puts
131
93
 
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
208
-
209
- r = post @endpoint, h
210
- puts ' degbugger: r: ' + r.inspect if @debug
94
+ @aur.ask(s)
211
95
 
212
- r[:response][:outputSpeech][:text]
213
96
  end
214
97
 
215
98
  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.2.2
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -10,68 +10,93 @@ bindir: bin
10
10
  cert_chain:
11
11
  - |
12
12
  -----BEGIN CERTIFICATE-----
13
- MIIDXjCCAkagAwIBAgIBATANBgkqhkiG9w0BAQUFADAsMSowKAYDVQQDDCFnZW1t
14
- YXN0ZXIvREM9amFtZXNyb2JlcnRzb24vREM9ZXUwHhcNMTgwNzAyMTEyMzUyWhcN
15
- MTkwNzAyMTEyMzUyWjAsMSowKAYDVQQDDCFnZW1tYXN0ZXIvREM9amFtZXNyb2Jl
16
- cnRzb24vREM9ZXUwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDIwvDS
17
- RzduR7D0dDqabmSil0pQoEKjeO9gIoaQph/aYUXArqyodwVNWjX556qAK7lXp969
18
- fqEmzgpGCPZfTH5ElarvonTbqmRX8ANwKFPt5ZaBfrfSYQq+Ur1ZtW1DVvtAocdO
19
- KiIlNUkDho1fVkah9+WSdN/lDAWwcJAelwFdvZcsMhjz1Me01uhx4f8P9b5XFeVz
20
- 33mPVgZpi1cHwg0uqhSFJUocnYqCp14gAGNbLrQAmOya9PRo1yjy2EvQVSg44xfD
21
- q5qOm03DvL1C+Gk156OyFoacKRlpAlOTjz4Vl3AJlMjHdsghogqp97udG1c7M0om
22
- pLngPwImNikDalRVAgMBAAGjgYowgYcwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAw
23
- HQYDVR0OBBYEFMKyzHQC4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
32
37
  -----END CERTIFICATE-----
33
- date: 2018-07-13 00:00:00.000000000 Z
38
+ date: 2020-06-26 00:00:00.000000000 Z
34
39
  dependencies:
35
40
  - !ruby/object:Gem::Dependency
36
- name: rest-client
41
+ name: askio
37
42
  requirement: !ruby/object:Gem::Requirement
38
43
  requirements:
39
44
  - - "~>"
40
45
  - !ruby/object:Gem::Version
41
- version: '2.0'
46
+ version: '0.1'
42
47
  - - ">="
43
48
  - !ruby/object:Gem::Version
44
- version: 2.0.2
49
+ version: 0.1.1
45
50
  type: :runtime
46
51
  prerelease: false
47
52
  version_requirements: !ruby/object:Gem::Requirement
48
53
  requirements:
49
54
  - - "~>"
50
55
  - !ruby/object:Gem::Version
51
- version: '2.0'
56
+ version: '0.1'
52
57
  - - ">="
53
58
  - !ruby/object:Gem::Version
54
- version: 2.0.2
59
+ version: 0.1.1
55
60
  - !ruby/object:Gem::Dependency
56
61
  name: console_cmdr
57
62
  requirement: !ruby/object:Gem::Requirement
58
63
  requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: '0.5'
62
64
  - - ">="
63
65
  - !ruby/object:Gem::Version
64
66
  version: 0.5.0
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: '0.5'
65
70
  type: :runtime
66
71
  prerelease: false
67
72
  version_requirements: !ruby/object:Gem::Requirement
68
73
  requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: 0.5.0
69
77
  - - "~>"
70
78
  - !ruby/object:Gem::Version
71
79
  version: '0.5'
80
+ - !ruby/object:Gem::Dependency
81
+ name: alexa_utteranceresponder
82
+ requirement: !ruby/object:Gem::Requirement
83
+ requirements:
72
84
  - - ">="
73
85
  - !ruby/object:Gem::Version
74
- version: 0.5.0
86
+ version: 0.2.0
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.2'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: 0.2.0
97
+ - - "~>"
98
+ - !ruby/object:Gem::Version
99
+ version: '0.2'
75
100
  description:
76
101
  email: james@jamesrobertson.eu
77
102
  executables: []
@@ -98,8 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
98
123
  - !ruby/object:Gem::Version
99
124
  version: '0'
100
125
  requirements: []
101
- rubyforge_project:
102
- rubygems_version: 2.6.13
126
+ rubygems_version: 3.0.3
103
127
  signing_key:
104
128
  specification_version: 4
105
129
  summary: A local simulator for your Alexa Skill.
metadata.gz.sig CHANGED
Binary file