ralyxa 1.7.0 → 1.8.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: e2097ed5c0dd85b2f0f5d04d0f6c524b9cc90b8b
4
- data.tar.gz: 004060b9f538e547270050bcab4a584bd243ef02
2
+ SHA256:
3
+ metadata.gz: 4da33b74c6ebde802beeae1a7ed472f336cdec0500e918faac4d9b1e86faa8ac
4
+ data.tar.gz: fa62e5c812eaeb8988c59b806ea5fe587b5c24f43c9fb26be46fb18c4d9410ea
5
5
  SHA512:
6
- metadata.gz: ec37369ea357d04fbde3353ae06b12407eb34282b466a3895ace4a0276f9c0a63ee05c4359436141ec02db1aca8b9e40a0dfa8a9030767c851032a5075c48008
7
- data.tar.gz: 840cf253a18ff2a3e552ea359a7ed15e9a120f869c0cf93020286394add6b86cee9d98f054f404abf83ee3c84eb73dc29b9685f41854442335d5445fcfa1758d
6
+ metadata.gz: ac804873ee91d760efde8248d0e5c301770a1ce78177ec3649d009089e61e000394064e453ad29df7fc115d0dc0bcbcf11d5192904a6d5d2d2b0078a536c54ec
7
+ data.tar.gz: d81d0756ee6b462ba906de4b67e4d03d01caf22a1fb2e9834b451f77f7841fe97259bb658e24bf3bd38ea11af79d5a21d4de3e95b5d43f99ae07945183369039
@@ -1 +1 @@
1
- 2.3.1
1
+ 2.5.1
@@ -3,18 +3,20 @@ require_relative './response_entities/response'
3
3
 
4
4
  module Ralyxa
5
5
  class ResponseBuilder
6
- def initialize(response_class, output_speech_class, options)
6
+ def initialize(response_class, output_speech_class, reprompt_class, options)
7
7
  @response_class = response_class
8
8
  @output_speech_class = output_speech_class
9
+ @reprompt_class = reprompt_class
9
10
  @options = options
10
11
  end
11
12
 
12
- def self.build(options = {}, response_class = Ralyxa::ResponseEntities::Response, output_speech_class = Ralyxa::ResponseEntities::OutputSpeech)
13
- new(response_class, output_speech_class, options).build
13
+ def self.build(options = {}, response_class = Ralyxa::ResponseEntities::Response, output_speech_class = Ralyxa::ResponseEntities::OutputSpeech, reprompt_class = Ralyxa::ResponseEntities::Reprompt)
14
+ new(response_class, output_speech_class, reprompt_class, options).build
14
15
  end
15
16
 
16
17
  def build
17
18
  merge_output_speech if response_text_exists?
19
+ merge_reprompt if reprompt_exists?
18
20
  merge_card if card_exists?
19
21
 
20
22
  @response_class.as_hash(@options).to_json
@@ -26,6 +28,10 @@ module Ralyxa
26
28
  @options.merge!(output_speech: output_speech)
27
29
  end
28
30
 
31
+ def merge_reprompt
32
+ @options.merge!(reprompt: reprompt)
33
+ end
34
+
29
35
  def merge_card
30
36
  @options[:card] = @options[:card].to_h
31
37
  end
@@ -38,11 +44,22 @@ module Ralyxa
38
44
  @options[:response_text]
39
45
  end
40
46
 
47
+ def reprompt_exists?
48
+ @options[:reprompt]
49
+ end
50
+
41
51
  def output_speech
42
52
  output_speech_params = { speech: @options.delete(:response_text) }
43
53
  output_speech_params[:ssml] = @options.delete(:ssml) if @options[:ssml]
44
54
 
45
55
  @output_speech_class.as_hash(output_speech_params)
46
56
  end
57
+
58
+ def reprompt
59
+ reprompt_params = { reprompt_speech: @options.delete(:reprompt) }
60
+ reprompt_params[:reprompt_ssml] = @options.delete(:reprompt_ssml) if @options[:reprompt_ssml]
61
+
62
+ @reprompt_class.as_hash(reprompt_params)
63
+ end
47
64
  end
48
65
  end
@@ -0,0 +1,20 @@
1
+ module Ralyxa
2
+ module ResponseEntities
3
+ class Reprompt
4
+ def initialize(reprompt_speech, reprompt_ssml)
5
+ @reprompt_speech = reprompt_speech
6
+ @reprompt_ssml = reprompt_ssml
7
+ end
8
+
9
+ def to_h
10
+ {}.tap do |reprompt|
11
+ reprompt[:outputSpeech] = Ralyxa::ResponseEntities::OutputSpeech.as_hash(speech: @reprompt_speech, ssml: @reprompt_ssml)
12
+ end
13
+ end
14
+
15
+ def self.as_hash(reprompt_speech: nil, reprompt_ssml: false)
16
+ new(reprompt_speech, reprompt_ssml).to_h
17
+ end
18
+ end
19
+ end
20
+ end
@@ -1,11 +1,13 @@
1
1
  require_relative './output_speech'
2
+ require_relative './reprompt'
2
3
  require_relative './directives'
3
4
 
4
5
  module Ralyxa
5
6
  module ResponseEntities
6
7
  class Response
7
- def initialize(output_speech, session_attributes, end_session, start_over, card, directives)
8
+ def initialize(output_speech, reprompt, session_attributes, end_session, start_over, card, directives)
8
9
  @output_speech = output_speech
10
+ @reprompt = reprompt
9
11
  @session_attributes = session_attributes
10
12
  @end_session = end_session
11
13
  @start_over = start_over
@@ -21,8 +23,8 @@ module Ralyxa
21
23
  end
22
24
  end
23
25
 
24
- def self.as_hash(output_speech: false, session_attributes: {}, end_session: false, start_over: false, card: false, directives: false)
25
- new(output_speech, session_attributes, end_session, start_over, card, directives).to_h
26
+ def self.as_hash(output_speech: false, reprompt: false, session_attributes: {}, end_session: false, start_over: false, card: false, directives: false)
27
+ new(output_speech, reprompt, session_attributes, end_session, start_over, card, directives).to_h
26
28
  end
27
29
 
28
30
  private
@@ -41,6 +43,7 @@ module Ralyxa
41
43
  def add_response(response)
42
44
  response[:response] = {}.tap do |response_object|
43
45
  response_object[:outputSpeech] = @output_speech if @output_speech
46
+ response_object[:reprompt] = @reprompt if @reprompt
44
47
  response_object[:card] = @card if @card
45
48
  response_object[:directives] = @directives if @directives
46
49
  response_object[:shouldEndSession] = @end_session
@@ -1,3 +1,3 @@
1
1
  module Ralyxa
2
- VERSION = '1.7.0'.freeze
2
+ VERSION = '1.8.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ralyxa
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.0
4
+ version: 1.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Morgan
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-03-09 00:00:00.000000000 Z
11
+ date: 2018-06-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: alexa_verifier
@@ -161,6 +161,7 @@ files:
161
161
  - lib/ralyxa/response_entities/directives/audio_player/play.rb
162
162
  - lib/ralyxa/response_entities/directives/audio_player/stop.rb
163
163
  - lib/ralyxa/response_entities/output_speech.rb
164
+ - lib/ralyxa/response_entities/reprompt.rb
164
165
  - lib/ralyxa/response_entities/response.rb
165
166
  - lib/ralyxa/skill.rb
166
167
  - lib/ralyxa/version.rb
@@ -186,7 +187,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
186
187
  version: '0'
187
188
  requirements: []
188
189
  rubyforge_project:
189
- rubygems_version: 2.6.10
190
+ rubygems_version: 2.7.6
190
191
  signing_key:
191
192
  specification_version: 4
192
193
  summary: A Ruby framework for interacting with Amazon Alexa.