alexa_rubykit 1.3.0 → 1.3.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2bdb573ced8e9c3a6e907e44d2d2f803b6c8baf6
4
- data.tar.gz: 9fce8086d8e9a97c46643607a8d408e372e9a6b0
3
+ metadata.gz: 2da22e95d080523407bf1a30905d62b1e95a9859
4
+ data.tar.gz: f1d40fb1ffe7e342d7c8b331fc5ec1a075bc023f
5
5
  SHA512:
6
- metadata.gz: 02c7d0c0dca8be917cbd7356e5a87319ba0a930dd45c0cb95247ed4264a134a499bc962c1f87aaf77c215fe699e9566d56c13de308e676fc5ef2a7019e873547
7
- data.tar.gz: 39b261cfed6aa0523e91a8f72a3e60643aaea153b303d147979a3cdd01bfd7d8e444d095de30a5fffc7ca73d6e9fbb8cb94ae14a9f79019aecd008bd341fec0d
6
+ metadata.gz: 0e0f445ffa7384722c08f4fced7a1e5239a30c9e2fc3a0f62ae3a9b02cd5b7b534031a801b0095f8aad6b1ec181a7dfead8c96c355d01169215abbd13bf4bcad
7
+ data.tar.gz: a586a863967f2cbf27a2d99ba19d29efbd3dbfa914d8d21a9fe9fe6c9e6acbb6df48da16d829ef37d5f928ca1c12badc480a0910920e187ecdae89a13caaf382
@@ -1,28 +1,28 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- alexa_rubykit (1.2.1)
4
+ alexa_rubykit (1.3.0)
5
5
  bundler (~> 1.7)
6
6
  rake
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- diff-lcs (1.2.5)
12
- rake (10.4.2)
13
- rspec (3.2.0)
14
- rspec-core (~> 3.2.0)
15
- rspec-expectations (~> 3.2.0)
16
- rspec-mocks (~> 3.2.0)
17
- rspec-core (3.2.3)
18
- rspec-support (~> 3.2.0)
19
- rspec-expectations (3.2.1)
11
+ diff-lcs (1.3)
12
+ rake (12.3.0)
13
+ rspec (3.7.0)
14
+ rspec-core (~> 3.7.0)
15
+ rspec-expectations (~> 3.7.0)
16
+ rspec-mocks (~> 3.7.0)
17
+ rspec-core (3.7.0)
18
+ rspec-support (~> 3.7.0)
19
+ rspec-expectations (3.7.0)
20
20
  diff-lcs (>= 1.2.0, < 2.0)
21
- rspec-support (~> 3.2.0)
22
- rspec-mocks (3.2.1)
21
+ rspec-support (~> 3.7.0)
22
+ rspec-mocks (3.7.0)
23
23
  diff-lcs (>= 1.2.0, < 2.0)
24
- rspec-support (~> 3.2.0)
25
- rspec-support (3.2.2)
24
+ rspec-support (~> 3.7.0)
25
+ rspec-support (3.7.0)
26
26
 
27
27
  PLATFORMS
28
28
  ruby
@@ -31,3 +31,6 @@ DEPENDENCIES
31
31
  alexa_rubykit!
32
32
  rspec (~> 3.2, >= 3.2.0)
33
33
  rspec-mocks (~> 3.2, >= 3.2.0)
34
+
35
+ BUNDLED WITH
36
+ 1.16.0
@@ -1,13 +1,20 @@
1
1
  module AlexaRubykit
2
2
  class Response
3
+ class SlotNotFound < StandardError; end
4
+
3
5
  require 'json'
4
- attr_accessor :version, :session, :response_object, :session_attributes, :speech, :reprompt, :response, :card
6
+ require 'alexa_rubykit/response/dialog'
7
+
8
+ attr_accessor :version, :session, :response_object, :session_attributes,
9
+ :speech, :reprompt, :response, :card, :intents, :request
5
10
 
6
11
  # Every response needs a shouldendsession and a version attribute
7
12
  # We initialize version to 1.0, use add_version to set your own.
8
- def initialize(version = '1.0')
13
+ def initialize(request=nil, version='1.0')
9
14
  @session_attributes = Hash.new
10
15
  @version = version
16
+ @request = request
17
+ @intents = request.intent if request && request.type == "INTENT_REQUEST"
11
18
  @directives = []
12
19
  end
13
20
 
@@ -39,6 +46,29 @@ module AlexaRubykit
39
46
  }
40
47
  end
41
48
 
49
+ def delegate_dialog_response
50
+ @directives = [Dialog.delegate_directive(intents)]
51
+ end
52
+
53
+ def elicit_dialog_response(slot)
54
+ @directives = [Dialog.elicit_slot_directive(slot, intents)]
55
+ end
56
+
57
+ def confirm_dialog_slot(slot)
58
+ @directives = [Dialog.confirm_slot_directive(slot, intents)]
59
+ end
60
+
61
+ def confirm_dialog_intent
62
+ @directives = [Dialog.confirm_intent_directive(intents)]
63
+ end
64
+
65
+ def modify_slot(name, value, confirmation_status)
66
+ raise SlotNotFound if @intents['slots'][name].nil?
67
+
68
+ @intents['slots'][name]['value'] = value
69
+ @intents['slots'][name]['confirmationStatus'] = confirmation_status
70
+ end
71
+
42
72
  def add_reprompt(speech_text, ssml = false)
43
73
  if ssml
44
74
  @reprompt = { "outputSpeech" => { :type => 'SSML', :ssml => check_ssml(speech_text) } }
@@ -83,7 +113,6 @@ module AlexaRubykit
83
113
  { :outputSpeech => output_speech, :reprompt => reprompt_speech, :shouldEndSession => end_session }
84
114
  end
85
115
 
86
-
87
116
  # Creates a session object. We pretty much only use this in testing.
88
117
  def build_session
89
118
  # If it's empty assume user doesn't need session attributes.
@@ -0,0 +1,42 @@
1
+ module AlexaRubykit
2
+ # Represents the encapsulation of Amazon Alexa Dialog Interface
3
+ # https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/dialog-interface-reference
4
+ class Dialog
5
+ DELEGATE_TYPE = "Dialog.Delegate".freeze
6
+ ELICIT_SLOT_TYPE = "Dialog.ElicitSlot".freeze
7
+ CONFIRM_SLOT_TYPE = "Dialog.ConfirmSlot".freeze
8
+ CONFIRM_INTENT_TYPE = "Dialog.ConfirmIntent".freeze
9
+
10
+ class << self
11
+ def delegate_directive(updated_intents)
12
+ {
13
+ 'type' => DELEGATE_TYPE,
14
+ 'updatedIntent' => updated_intents
15
+ }
16
+ end
17
+
18
+ def elicit_slot_directive(slot, updated_intents)
19
+ {
20
+ 'type' => ELICIT_SLOT_TYPE,
21
+ 'slotToElicit' => slot,
22
+ 'updatedIntent' => updated_intents
23
+ }
24
+ end
25
+
26
+ def confirm_slot_directive(slot, updated_intents)
27
+ {
28
+ 'type' => CONFIRM_SLOT_TYPE,
29
+ 'slotToConfirm' => slot,
30
+ 'updatedIntent' => updated_intents
31
+ }
32
+ end
33
+
34
+ def confirm_intent_directive(updated_intents)
35
+ {
36
+ 'type' => CONFIRM_INTENT_TYPE,
37
+ 'updatedIntent' => updated_intents
38
+ }
39
+ end
40
+ end
41
+ end
42
+ end
@@ -1,3 +1,3 @@
1
1
  module AlexaRubykit
2
- VERSION = '1.3.0'
2
+ VERSION = '1.3.1'
3
3
  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.3.0
4
+ version: 1.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Damian Finol
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-13 00:00:00.000000000 Z
11
+ date: 2017-12-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -95,6 +95,7 @@ files:
95
95
  - lib/alexa_rubykit/launch_request.rb
96
96
  - lib/alexa_rubykit/request.rb
97
97
  - lib/alexa_rubykit/response.rb
98
+ - lib/alexa_rubykit/response/dialog.rb
98
99
  - lib/alexa_rubykit/session.rb
99
100
  - lib/alexa_rubykit/session_ended_request.rb
100
101
  - lib/alexa_rubykit/version.rb
@@ -118,7 +119,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
118
119
  version: '0'
119
120
  requirements: []
120
121
  rubyforge_project:
121
- rubygems_version: 2.4.6
122
+ rubygems_version: 2.6.14
122
123
  signing_key:
123
124
  specification_version: 4
124
125
  summary: Alexa Ruby Kit