alexa_rubykit 0.0.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1f5d5359d1c4d7d5a871b3d4726dc51a803aafb5
4
+ data.tar.gz: 4eff73b94c008dc9df5d46319d8e551953e59440
5
+ SHA512:
6
+ metadata.gz: 86f49e1913012e0c302cb4f239526feac266f8de7fb56dbcf01d42598a666a3693dc42d1c9584695ec7bece9c212415d3552a54ef209a76683028d70aa0b7771
7
+ data.tar.gz: 0c4018daeb77edc1172f8e351022431ade9bfe23dcbbc55de8fe759cdd73bfe9d7974c8d8a7a08167bc6bf19a59f214c1f85847056b9f2de31c376f7dd7f5d67
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in alexa_rubykit.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,26 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ alexa_rubykit (0.0.1)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ rack (1.6.0)
10
+ rack-protection (1.5.3)
11
+ rack
12
+ rake (10.3.2)
13
+ sinatra (1.4.6)
14
+ rack (~> 1.4)
15
+ rack-protection (~> 1.4)
16
+ tilt (>= 1.3, < 3)
17
+ tilt (2.0.1)
18
+
19
+ PLATFORMS
20
+ ruby
21
+
22
+ DEPENDENCIES
23
+ alexa_rubykit!
24
+ bundler (~> 1.7)
25
+ rake (~> 10.0)
26
+ sinatra (~> 1.4)
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Damian Finol
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,36 @@
1
+ # AlexaRubykit
2
+
3
+ This gem implements a quick back-end service for deploying applications for Amazon's Echo (Alexa), the gem,
4
+ and samples are provided as-is and are in current development.
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'alexa_rubykit'
12
+ ```
13
+
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install alexa_rubykit
21
+
22
+ ## Usage
23
+
24
+ For running the sample "say" application:
25
+ * Configure your endpoint for SSL and load the certificate in the developer portal.
26
+ * Execute alexa_rubyengine under the bin folder
27
+ Sinatra will run in the background and serve a say command when it receives a LoginRequest command from
28
+ the Alexa app.
29
+
30
+ ## Contributing
31
+
32
+ 1. Fork it ( https://github.com/[my-github-username]/alexa_rubykit/fork )
33
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
34
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
35
+ 4. Push to the branch (`git push origin my-new-feature`)
36
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env ruby
2
+ # Alexa RubyEngine
3
+ # This Engine receives and responds to Amazon Echo's (Alexa) JSON requests.
4
+ require 'sinatra'
5
+ require 'json'
6
+ require 'alexa_rubykit'
7
+
8
+
9
+ enable :sessions
10
+ post '/' do
11
+ # Check that it's a valid Alexa request
12
+ request_json = JSON.parse(request.body.read.to_s)
13
+ halt 500 if request_json['session'].nil? || request_json['version'].nil? || request_json['request'].nil?
14
+
15
+ request = AlexaRubykit::Request.new(request_json['request'])
16
+ request.version = '1.0'
17
+ request.should_end_session = true
18
+ request.say_response('Hello, this is a test')
19
+ request.build_response
20
+ end
data/config.ru ADDED
@@ -0,0 +1,2 @@
1
+ require './bin/alexa_rubyengine'
2
+ run Sinatra::Application
@@ -0,0 +1,6 @@
1
+ require 'alexa_rubykit/request'
2
+ module AlexaRubykit
3
+ def self.print_json(json)
4
+ p json
5
+ end
6
+ end
@@ -0,0 +1,50 @@
1
+ module AlexaRubykit
2
+ # Echo can send 3 types of requests
3
+ # - LaunchRequest: The start of the app.
4
+ # - IntentRequest: The intent of the app.
5
+ # - SessionEndedRequest: Session has ended.
6
+ class Request
7
+ require 'json'
8
+ require 'sinatra'
9
+ attr_accessor :version, :session_attributes, :response, :should_end_session
10
+
11
+ @request = ''
12
+ @type = ''
13
+ def initialize(json_request)
14
+ halt 500 if json_request.nil?
15
+ @request = json_request
16
+ case @request['type']
17
+ when /Launch/
18
+ @type = 'LAUNCH'
19
+ when /Intent/
20
+ @type = 'INTENT'
21
+ when /SessionEnded/
22
+ @type = 'SESSIONENDED'
23
+ else
24
+ halt 500
25
+ end
26
+ end
27
+
28
+ # Builds a response.
29
+ def build_response
30
+ # Need to set all 3 parameters or the response is invalid
31
+ halt 500 if @version.nil? || @response.nil? || @should_end_session.nil?
32
+ response = Hash.new
33
+ response[:version] = @version
34
+ response[:response] = @response
35
+ response[:should_end_session] = @should_end_session
36
+ response.to_json
37
+ end
38
+
39
+ # Creates a outputspeech JSON object for responding with voice.
40
+ # Data type:
41
+ #"outputSpeech": {
42
+ # "type": "string",
43
+ # "text": "string"
44
+ #}
45
+ def say_response(speech)
46
+ output_speech = { :type => 'string', :text => speech }
47
+ @response = { :outputSpeech => output_speech }
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,3 @@
1
+ module AlexaRubykit
2
+ VERSION = "0.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,97 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: alexa_rubykit
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Damian Finol
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-04-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: sinatra
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.4'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.4'
55
+ description: Alexa Ruby Kit with examples
56
+ email:
57
+ - damian.finol@gmail.com
58
+ executables:
59
+ - alexa_rubyengine.rb
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - Gemfile
64
+ - Gemfile.lock
65
+ - LICENSE.txt
66
+ - README.md
67
+ - Rakefile
68
+ - bin/alexa_rubyengine.rb
69
+ - config.ru
70
+ - lib/alexa_rubykit.rb
71
+ - lib/alexa_rubykit/request.rb
72
+ - lib/alexa_rubykit/version.rb
73
+ homepage: ''
74
+ licenses:
75
+ - MIT
76
+ metadata: {}
77
+ post_install_message:
78
+ rdoc_options: []
79
+ require_paths:
80
+ - lib
81
+ required_ruby_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ required_rubygems_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ requirements: []
92
+ rubyforge_project:
93
+ rubygems_version: 2.4.4
94
+ signing_key:
95
+ specification_version: 4
96
+ summary: Alexa Ruby Kit
97
+ test_files: []