alexa_ruby 1.2.1 → 1.3.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 886142fd610eaa1fb2c0330440f7015301abcbed
4
- data.tar.gz: 6908bfe4be82907c42efb245ea5ad8f16760a257
3
+ metadata.gz: cef6318023e97d0690ce4b2ffbae5f97b33d94a1
4
+ data.tar.gz: 2fbe7fbc0f0fa1d291c046c29b821b958a2f5932
5
5
  SHA512:
6
- metadata.gz: a4b66b2790f1db14d55a685dc862124006544c1f1f93fb60cb60aa3b4caed02f0cb85c967cc0bd92d6faf303718ceb17a0e807aa50458a865972ee59734f29cc
7
- data.tar.gz: d1d691892c405cbe8f01715020b6b371ca7455a963599723659d895203612b8da8a305492ea1ed81b82a437aab952197012c6dcfe5397be656f7b6afe50bcc54
6
+ metadata.gz: b5bca1bc8b0753d216344a946d5c138eac83f8c7db3b04a2d85547180edf875e60fe37fd380742849f7a653d08b578e2bad2ffab1a9ed6850536249e92305331
7
+ data.tar.gz: 33cda627fe06f51af512396f4e09170b74f59cd9d2ca1734dec524bbc7cf1355b6b7b2a6a6acc5261cc833b991e6faafb06e25c741b097496e6bc088e46e6636
data/CHANGELOG CHANGED
@@ -1,3 +1,6 @@
1
+ [1.3.0]
2
+ - Add invocation parameter :disable_validations that allows to disable request validations if set to true
3
+
1
4
  [1.2.1]
2
5
  - Fixed issue with expectedPreviousToken property in enqueuing AudioPlayer.Play directive
3
6
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- alexa_ruby (1.2.0)
4
+ alexa_ruby (1.2.1)
5
5
  bundler (>= 1.6.9)
6
6
  oj (~> 3.0)
7
7
  rake
data/README.md CHANGED
@@ -63,6 +63,12 @@ class App < Roda
63
63
  end
64
64
  ```
65
65
 
66
+ Request validations can be disabled:
67
+
68
+ ```ruby
69
+ AlexaRuby.new(request, disable_validations: true)
70
+ ```
71
+
66
72
  After initializing new AlexaRuby instance you will have a possibility to access
67
73
  all parameters of the received request.
68
74
 
@@ -7,8 +7,11 @@ module AlexaRuby
7
7
  # Initialize new Alexa assistant
8
8
  #
9
9
  # @param request [Hash] request from Amazon Alexa web service
10
- def initialize(request)
10
+ # @param opts [Hash] additional options:
11
+ # :disable_validations [Boolean] disables request validation if true
12
+ def initialize(request, opts)
11
13
  @req = request
14
+ @opts = opts
12
15
  invalid_request_exception if invalid_request?
13
16
  @request = define_request
14
17
  raise ArgumentError, 'Unknown type of Alexa request' if @request.nil?
@@ -17,11 +20,18 @@ module AlexaRuby
17
20
 
18
21
  private
19
22
 
23
+ # Check if validations are enabled
24
+ #
25
+ # @return [Boolean]
26
+ def validations_enabled?
27
+ !@opts[:disable_validations] || @opts[:disable_validations].nil?
28
+ end
29
+
20
30
  # Check if it is an invalid request
21
31
  #
22
32
  # @return [Boolean]
23
33
  def invalid_request?
24
- @req[:version].nil? || @req[:request].nil?
34
+ @req[:version].nil? || @req[:request].nil? if validations_enabled?
25
35
  end
26
36
 
27
37
  # Request structure isn't valid, raise exception
@@ -1,3 +1,3 @@
1
1
  module AlexaRuby
2
- VERSION = '1.2.1'.freeze
2
+ VERSION = '1.3.0'.freeze
3
3
  end
data/lib/alexa_ruby.rb CHANGED
@@ -26,11 +26,13 @@ module AlexaRuby
26
26
  #
27
27
  # @param request [Object] request from Amazon Alexa web service,
28
28
  # can be hash or JSON encoded string
29
+ # @param opts [Hash] additional options:
30
+ # :disable_validations [Boolean] disables request validation if true
29
31
  # @return [Object] new Request object instance
30
32
  # @raise [ArgumentError] if given object isn't a valid JSON object
31
- def new(request)
33
+ def new(request, opts = {})
32
34
  obj = build_json(request)
33
- Alexa.new(obj)
35
+ Alexa.new(obj, opts)
34
36
  end
35
37
 
36
38
  private
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alexa_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Mulev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-07-10 00:00:00.000000000 Z
11
+ date: 2017-07-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler