alexa_rubykit 1.1.0 → 1.1.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: 3748981d0a9bc0fc1bf4f5b717d167641dcd697a
4
- data.tar.gz: 78ada1f9c255e3531fcc578ff6dd5523c8711dc5
3
+ metadata.gz: d3b7bcf9c3859a9434906cf1d1e1bb3123ec4277
4
+ data.tar.gz: e1e52a2d3116620bd2d17069f2ebb76dc4c07ddb
5
5
  SHA512:
6
- metadata.gz: 2adaf509979b0c18c0db6f64de1416a63878eb87d52bfae7a84bed8db2ae5a78c3dd2b52f6f74351aefb966a15a1100a4d14bc3f2827b0e9ef03219cf2740ad8
7
- data.tar.gz: 4fb73941be833903ec6dfb2337ec3aab257e3938006d51c278fc399002358094b8165768aba82554dc3be186e830f7ca75889710a1a364251134e3ef56902b93
6
+ metadata.gz: 6c20b3b2d6be9adc312f33154bf29cc6cc6c8883a19d8e00c560cf80dc27cd5fbbd5f1f9164ea2993c9bab8382c7ce783bd7a7f53b65ed0caa5ede0211263f70
7
+ data.tar.gz: d8695ccc7ea17a6884b477f2e83c7f1ba141ba672d33c4643fee71925d76f500e846fda99b1d73dff32f7c200abb8be7ac2b6f53bbc28845a9336b8c2a52dba4
@@ -1,14 +1,18 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- alexa_rubykit (1.0.0)
4
+ alexa_rubykit (0.0.12.pre.dev)
5
5
  bundler (~> 1.7)
6
6
  rake (~> 10.0)
7
+ sinatra (~> 1.4)
7
8
 
8
9
  GEM
9
10
  remote: https://rubygems.org/
10
11
  specs:
11
12
  diff-lcs (1.2.5)
13
+ rack (1.6.1)
14
+ rack-protection (1.5.3)
15
+ rack
12
16
  rake (10.4.2)
13
17
  rspec (3.2.0)
14
18
  rspec-core (~> 3.2.0)
@@ -23,11 +27,16 @@ GEM
23
27
  diff-lcs (>= 1.2.0, < 2.0)
24
28
  rspec-support (~> 3.2.0)
25
29
  rspec-support (3.2.2)
30
+ sinatra (1.4.6)
31
+ rack (~> 1.4)
32
+ rack-protection (~> 1.4)
33
+ tilt (>= 1.3, < 3)
34
+ tilt (2.0.1)
26
35
 
27
36
  PLATFORMS
28
37
  ruby
29
38
 
30
39
  DEPENDENCIES
31
40
  alexa_rubykit!
32
- rspec (~> 3.2, >= 3.2.0)
33
- rspec-mocks (~> 3.2, >= 3.2.0)
41
+ rspec (~> 3.2.0)
42
+ rspec-mocks (~> 3.2.0)
data/README.md CHANGED
@@ -78,3 +78,4 @@ To use the stable/master branch, rename 'dev' to 'master' or remove :branch all
78
78
 
79
79
  # <a name="team-members"></a>Team Members
80
80
  * "Damian Finol" <damian.finol@gmail.com>
81
+ * "Dave Shapiro" <dss.shapiro@gmail.com>
@@ -1,16 +1,16 @@
1
1
  module AlexaRubykit
2
2
  class IntentRequest < Request
3
- attr_accessor :request_id, :intent, :name, :slots
3
+ attr_accessor :intent, :name, :slots
4
4
 
5
5
  # We still don't know if all of the parameters in the request are required.
6
6
  # Checking for the presence of intent on an IntentRequest.
7
- def initialize(request_id, intent)
8
- raise ArgumentError, 'Intent should exist on an IntentRequest' if intent.nil?
7
+ def initialize(json_request)
8
+ super
9
+ @intent = json_request['request']['intent']
10
+ raise ArgumentError, 'Intent should exist on an IntentRequest' if @intent.nil?
9
11
  @type = 'INTENT_REQUEST'
10
- @request_id = request_id
11
- @intent = intent
12
- @name = intent['name']
13
- @slots = intent['slots']
12
+ @name = @intent['name']
13
+ @slots = @intent['slots']
14
14
  end
15
15
 
16
16
  # Takes a Hash object.
@@ -37,7 +37,7 @@ module AlexaRubykit
37
37
 
38
38
  # Outputs the Intent Name, request Id and slot information.
39
39
  def to_s
40
- "IntentRequest: #{@name} requestID: #{request_id} Slots: #{@slots}"
40
+ "IntentRequest: #{name} requestID: #{request_id} Slots: #{slots}"
41
41
  end
42
42
  end
43
43
 
@@ -54,7 +54,7 @@ module AlexaRubykit
54
54
 
55
55
  # Outputs Slot name and value.
56
56
  def to_s
57
- "Slot Name: #{@name}, Value: #{value}"
57
+ "Slot Name: #{name}, Value: #{value}"
58
58
  end
59
59
  end
60
60
  end
@@ -1,18 +1,15 @@
1
1
  module AlexaRubykit
2
2
  class LaunchRequest < Request
3
- attr_accessor :request_id
4
-
5
3
  # We still don't know if all of the parameters in the request are required.
6
4
  # Checking for the presence of intent on an IntentRequest.
7
- def initialize(request_id)
8
- raise ArgumentError, 'Request ID should exist on a LaunchRequest' if request_id.nil?
5
+ def initialize(json_request)
6
+ super
9
7
  @type = 'LAUNCH_REQUEST'
10
- @request_id = request_id
11
8
  end
12
9
 
13
10
  # Outputs the launch requestID.
14
11
  def to_s
15
- "LaunchRequest requestID: #{@request_id}"
12
+ "LaunchRequest requestID: #{request_id}"
16
13
  end
17
14
  end
18
15
  end
@@ -6,11 +6,18 @@ module AlexaRubykit
6
6
  class Request
7
7
  require 'json'
8
8
  require 'alexa_rubykit/session'
9
- attr_accessor :version, :response, :shouldEndSession, :type, :session
9
+ attr_accessor :version, :type, :session, :json # global
10
+ attr_accessor :request_id, :locale # on request
10
11
 
11
- # Adds a specific session.
12
- def add_session(session)
13
- @session = session
12
+ def initialize(json_request)
13
+ @request_id = json_request['request']['requestId']
14
+ raise ArgumentError, 'Request ID should exist on all Requests' if @request_id.nil?
15
+ @version = json_request['version']
16
+ @locale = json_request['request']['locale']
17
+ @json = json_request
18
+
19
+ # TODO: We probably need better session handling.
20
+ @session = AlexaRubykit::Session.new(json_request['session'])
14
21
  end
15
22
  end
16
23
 
@@ -18,29 +25,23 @@ module AlexaRubykit
18
25
  def self.build_request(json_request)
19
26
  raise ArgumentError, 'Invalid Alexa Request.' unless AlexaRubykit.valid_alexa?(json_request)
20
27
  @request = nil
21
- # TODO: We probably need better session handling.
22
- session = AlexaRubykit::Session.new(json_request['session'])
23
28
  case json_request['request']['type']
24
29
  when /Launch/
25
- @request = LaunchRequest.new(json_request['request']['requestId'])
30
+ @request = LaunchRequest.new(json_request)
26
31
  when /Intent/
27
- @request = IntentRequest.new(json_request['request']['requestId'], json_request['request']['intent'])
32
+ @request = IntentRequest.new(json_request)
28
33
  when /SessionEnded/
29
- @request = SessionEndedRequest.new(json_request['request']['requestId'], json_request['request']['reason'])
34
+ @request = SessionEndedRequest.new(json_request)
30
35
  else
31
36
  raise ArgumentError, 'Invalid Request Type.'
32
37
  end
33
- @request.add_session(session)
34
38
  @request
35
39
  end
36
40
 
37
- # Let's monkey patch Hash.
38
- refine Hash do
39
- # Take keys of hash and transform those to a symbols
40
- def self.transform_keys_to_symbols(value)
41
- return value if not value.is_a?(Hash)
42
- hash = value.inject({}){|memo,(k,v)| memo[k.to_sym] = Hash.transform_keys_to_symbols(v); memo}
43
- return hash
44
- end
41
+ # Take keys of hash and transform those to a symbols
42
+ def self.transform_keys_to_symbols(value)
43
+ return value if not value.is_a?(Hash)
44
+ hash = value.inject({}){|memo,(k,v)| memo[k.to_sym] = self.transform_keys_to_symbols(v); memo}
45
+ return hash
45
46
  end
46
- end
47
+ end
@@ -33,7 +33,7 @@ module AlexaRubykit
33
33
  def add_card(type = nil, title = nil , subtitle = nil, content = nil)
34
34
  # A Card must have a type which the default is Simple.
35
35
  @card = Hash.new()
36
- @card[:type] = 'Simple' if type.nil?
36
+ @card[:type] = type || 'Simple'
37
37
  @card[:title] = title unless title.nil?
38
38
  @card[:subtitle] = subtitle unless subtitle.nil?
39
39
  @card[:content] = content unless content.nil?
@@ -12,7 +12,7 @@ module AlexaRubykit
12
12
 
13
13
  # Returns whether this is a new session or not.
14
14
  def new?
15
- @new
15
+ !!@new
16
16
  end
17
17
 
18
18
  # Returns true if a user is defined.
@@ -22,7 +22,11 @@ module AlexaRubykit
22
22
 
23
23
  # Returns the user_id.
24
24
  def user_id
25
- @user['userId'] if user_defined?
25
+ @user['userId'] if @user
26
+ end
27
+
28
+ def access_token
29
+ @user['accessToken'] if @user
26
30
  end
27
31
 
28
32
  # Check to see if attributes are present.
@@ -1,21 +1,20 @@
1
1
  # Session end request class.
2
2
  module AlexaRubykit
3
3
  class SessionEndedRequest < Request
4
- attr_accessor :request_id, :reason, :type
4
+ attr_accessor :reason
5
5
 
6
6
  # TODO: Validate the reason.
7
7
  # We still don't know if all of the parameters in the request are required.
8
8
  # Checking for the presence of intent on an IntentRequest.
9
- def initialize(request_id, reason)
10
- raise ArgumentError, 'Request ID should exist on a Session Ended Request.' if request_id.nil?
9
+ def initialize(json_request)
10
+ super
11
11
  @type = 'SESSION_ENDED_REQUEST'
12
- @request_id = request_id
13
- @reason = reason
12
+ @reason = json_request['request']['reason']
14
13
  end
15
14
 
16
15
  # Ouputs the request_id and the reason why.
17
16
  def to_s
18
- "Session Ended for requestID: #{@request_id} with reason #{@reason}"
17
+ "Session Ended for requestID: #{request_id} with reason #{reason}"
19
18
  end
20
19
  end
21
20
  end
@@ -1,3 +1,3 @@
1
1
  module AlexaRubykit
2
- VERSION = '1.1.0'
2
+ VERSION = '1.1.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.1.0
4
+ version: 1.1.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: 2015-05-30 00:00:00.000000000 Z
11
+ date: 2017-02-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -28,16 +28,16 @@ dependencies:
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '10.0'
33
+ version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '10.0'
40
+ version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -118,7 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
118
118
  version: '0'
119
119
  requirements: []
120
120
  rubyforge_project:
121
- rubygems_version: 2.4.4
121
+ rubygems_version: 2.4.6
122
122
  signing_key:
123
123
  specification_version: 4
124
124
  summary: Alexa Ruby Kit