alexa_utteranceresponder 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 5bd7011b17dbb04ca5cee00862a2ec5677155017f6cd61167bb393c1364a30bf
4
+ data.tar.gz: 302cc6d9705d3b298404470e9df76ab20317a912843302db2757dc885a199eb9
5
+ SHA512:
6
+ metadata.gz: 440f41c430c68306ed4e12f30e5af1c399d15697f56e6b2b9576a5cb0c0556aa0acaf89e7a2d2c28f6069c12b6dc67abfa7d636a71f1d1a0db4e6c6d49d17f68
7
+ data.tar.gz: 6970a20c2261e94cc88ada22171311df6b561163dc880b14c63ff8ab01cb3ae9bcd71563b354163aaa5c646fa6c920f92f4bae15001d203071d919c9fab7b605
Binary file
Binary file
@@ -0,0 +1,71 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # file: alexa_utteranceresponder.rb
4
+
5
+ # description: Checks an utterance against an invocation keyword from
6
+ # the available skills and returns an Alexa formatted response
7
+ # to be passed to the skill's endpoint service.
8
+
9
+ require 'askio'
10
+ require 'alexa_modelbuilder'
11
+
12
+
13
+ class AlexaUtteranceResponder
14
+ using ColouredText
15
+
16
+ attr_reader :invocation
17
+ attr_accessor :deviceid
18
+
19
+ def initialize(modelmds=[], debug: false, userid: nil, deviceid: nil)
20
+
21
+ @debug, @userid, @deviceid = debug, userid, deviceid
22
+
23
+ @models = modelmds.inject({}) do |r,x|
24
+
25
+ amb = AlexaModelBuilder.new(x)
26
+ r.merge(amb.invocation => amb)
27
+
28
+ end
29
+
30
+ end
31
+
32
+ def ask(s, deviceid: @deviceid, &blk)
33
+
34
+ puts
35
+ puts ' debugger: s: ' + s.inspect if @debug
36
+
37
+ invocations = @models.keys.map {|invocation| invocation.gsub(/ /,'\s') }\
38
+ .join('|')
39
+ puts 'invocations: ' + invocations.inspect if @debug
40
+
41
+ regex = %r{
42
+
43
+ (?<ask>(?<action>tell|ask)\s(?<invocation>#{invocations})\s(?<request>.*)){0}
44
+ (?<open>(?<action>open)\s(?<invocation>#{invocations})){0}
45
+ \g<ask>|\g<open>
46
+ }x
47
+
48
+ r2 = s.downcase.gsub(/,/,'').match(regex)
49
+
50
+ puts ' debugger: r2: ' + r2.inspect if @debug
51
+ puts
52
+
53
+ return "hmmm, I don't know that one." unless r2
54
+ return respond() if r2[:action] == 'open'
55
+
56
+ puts '@models: ' + @models.inspect if @debug
57
+ amb = @models[r2[:invocation]]
58
+ puts 'amb: ' + amb.inspect if @debug
59
+
60
+ aio = AskIO.new(amb.to_manifest, amb.to_model, debug: @debug,
61
+ userid: @userid, deviceid: deviceid)
62
+
63
+ puts 'request: ' + r2[:request].inspect if @debug
64
+ r = aio.ask r2[:request], &blk
65
+
66
+ r ? r : "I'm sorry I didn't understand what you said"
67
+
68
+ end
69
+
70
+ end
71
+
metadata ADDED
@@ -0,0 +1,111 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: alexa_utteranceresponder
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - James Robertson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain:
11
+ - |
12
+ -----BEGIN CERTIFICATE-----
13
+ MIIEXjCCAsagAwIBAgIBATANBgkqhkiG9w0BAQsFADAsMSowKAYDVQQDDCFnZW1t
14
+ YXN0ZXIvREM9amFtZXNyb2JlcnRzb24vREM9ZXUwHhcNMTkxMjEwMDAyMDU2WhcN
15
+ MjAxMjA5MDAyMDU2WjAsMSowKAYDVQQDDCFnZW1tYXN0ZXIvREM9amFtZXNyb2Jl
16
+ cnRzb24vREM9ZXUwggGiMA0GCSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQCu3PeI
17
+ Lxk8G56PIvhul8ZvKtppFg0qxlrgvDspkCEZgcugL3ZtacTZTwrdg8hqn/iCDJ+C
18
+ 6XTpOEeDZl2ivB/uK8VJAG+7DR0sLQJSK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reinzqd/
34
+ dI9kVRfbePF09IK45TcAILKFIJMrPp7ESym5Kx5N8hFszBr0wZNVP0gIPMjao5Z6
35
+ et+EBeqz/UE1cHo1UQJ46zhnSgmyJAzu7CkkRXvmAL/vpbmZMsnwwMHlqzNFUj3Y
36
+ B0fryIJrom9l8P6WHMK+0kWS
37
+ -----END CERTIFICATE-----
38
+ date: 2019-12-10 00:00:00.000000000 Z
39
+ dependencies:
40
+ - !ruby/object:Gem::Dependency
41
+ name: askio
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '0.1'
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: 0.1.1
50
+ type: :runtime
51
+ prerelease: false
52
+ version_requirements: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - "~>"
55
+ - !ruby/object:Gem::Version
56
+ version: '0.1'
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: 0.1.1
60
+ - !ruby/object:Gem::Dependency
61
+ name: alexa_modelbuilder
62
+ requirement: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: 0.5.0
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: '0.5'
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: 0.5.0
77
+ - - "~>"
78
+ - !ruby/object:Gem::Version
79
+ version: '0.5'
80
+ description:
81
+ email: james@jamesrobertson.eu
82
+ executables: []
83
+ extensions: []
84
+ extra_rdoc_files: []
85
+ files:
86
+ - lib/alexa_utteranceresponder.rb
87
+ homepage: https://github.com/jrobertson/alexa_utteranceresponder
88
+ licenses:
89
+ - MIT
90
+ metadata: {}
91
+ post_install_message:
92
+ rdoc_options: []
93
+ require_paths:
94
+ - lib
95
+ required_ruby_version: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
100
+ required_rubygems_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ requirements: []
106
+ rubygems_version: 3.0.3
107
+ signing_key:
108
+ specification_version: 4
109
+ summary: Checks an utterance against an invocation keyword from the available skills
110
+ and returns an Alexa formatted response to be passed to the skill's endpoint service.
111
+ test_files: []
Binary file