amazon_echo 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -2
- data/circle.yml +3 -0
- data/lib/amazon_echo.rb +24 -2
- data/lib/amazon_echo/intent_request.rb +14 -0
- data/lib/amazon_echo/launch_request.rb +3 -0
- data/lib/amazon_echo/request.rb +15 -4
- data/lib/amazon_echo/response.rb +10 -10
- data/lib/amazon_echo/session_ended_request.rb +5 -0
- data/lib/amazon_echo/version.rb +1 -1
- metadata +19 -17
- data/.travis.yml +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 91bacec08069d97bf559f45182dc6d2ef0d00cdd
|
4
|
+
data.tar.gz: 079be9a77217165c9dff17f4591925d5e2d96428
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 747bade76e15c8a78533dc87dfee4dbf5b93e10b30fe63622757cd25d8bf67db280c98aad09e19c51c1e149d244a48ec088af6fff17cc951ef1b37d9d22c32e9
|
7
|
+
data.tar.gz: 4a1619d7a3b6d8d6fbbff1d78990cde07bd89df902f35a294187213b5c27647ac9e314d63051d8f61e2a1f10d84c223647f64a8a3009916b6a7e2aea139a0d2d
|
data/README.md
CHANGED
@@ -1,7 +1,10 @@
|
|
1
1
|
# AmazonEcho
|
2
2
|
|
3
|
+
[![Build Status](https://circleci.com/gh/gomayonqui/amazon_echo.png?style=shield)](https://circleci.com/gh/gomayonqui/amazon_echo)
|
4
|
+
|
3
5
|
Simple client that supports requests and responses for amazon echo
|
4
6
|
|
7
|
+
|
5
8
|
## Installation
|
6
9
|
|
7
10
|
Add this line to your application's Gemfile:
|
@@ -22,7 +25,7 @@ Or install it yourself as:
|
|
22
25
|
To start using the gem, create a new object
|
23
26
|
```ruby
|
24
27
|
echo = AmazonEcho.new
|
25
|
-
echo.
|
28
|
+
echo.say("Yes master")
|
26
29
|
```
|
27
30
|
|
28
31
|
## Development
|
@@ -40,7 +43,7 @@ For running all tests
|
|
40
43
|
|
41
44
|
## Contributing
|
42
45
|
|
43
|
-
1. Fork it ( https://github.com/
|
46
|
+
1. Fork it ( https://github.com/gomayonqui/amazon_echo/fork )
|
44
47
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
45
48
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
46
49
|
4. Push to the branch (`git push origin my-new-feature`)
|
data/circle.yml
ADDED
data/lib/amazon_echo.rb
CHANGED
@@ -1,12 +1,34 @@
|
|
1
1
|
require 'amazon_echo/version'
|
2
2
|
require 'amazon_echo/response'
|
3
3
|
require 'amazon_echo/request'
|
4
|
+
require 'amazon_echo/intent_request'
|
5
|
+
require 'amazon_echo/launch_request'
|
6
|
+
require 'amazon_echo/session_ended_request'
|
4
7
|
|
5
8
|
class AmazonEcho
|
6
9
|
attr_reader :request, :response
|
7
10
|
|
8
|
-
def initialize(request
|
9
|
-
@request =
|
11
|
+
def initialize(request: nil, response: {})
|
12
|
+
@request = build_request(request)
|
10
13
|
@response = Response.new(response)
|
11
14
|
end
|
15
|
+
|
16
|
+
def say(output_speech)
|
17
|
+
response.say(output_speech)
|
18
|
+
end
|
19
|
+
|
20
|
+
def build_request(request)
|
21
|
+
if request && request["request"]
|
22
|
+
case request["request"].fetch("type")
|
23
|
+
when "LaunchRequest"
|
24
|
+
AmazonEcho::LaunchRequest
|
25
|
+
when "IntentRequest"
|
26
|
+
AmazonEcho::IntentRequest
|
27
|
+
when "SessionEndedRequest"
|
28
|
+
AmazonEcho::SessionEndedRequest
|
29
|
+
end.new(request)
|
30
|
+
else
|
31
|
+
"Invalid request"
|
32
|
+
end
|
33
|
+
end
|
12
34
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class AmazonEcho::IntentRequest < AmazonEcho::Request
|
2
|
+
|
3
|
+
def intent
|
4
|
+
@request["intent"]["name"]
|
5
|
+
end
|
6
|
+
|
7
|
+
def slot_value(slot_name)
|
8
|
+
@request["intent"]['slots'][slot_name]['value'] rescue nil
|
9
|
+
end
|
10
|
+
|
11
|
+
def slots
|
12
|
+
@request["intent"]['slots']
|
13
|
+
end
|
14
|
+
end
|
data/lib/amazon_echo/request.rb
CHANGED
@@ -1,7 +1,18 @@
|
|
1
1
|
class AmazonEcho::Request
|
2
|
-
def initialize(request
|
3
|
-
@
|
4
|
-
@session = request[:session]
|
5
|
-
@request = request[:request]
|
2
|
+
def initialize(request)
|
3
|
+
@request = request
|
6
4
|
end
|
5
|
+
|
6
|
+
def type
|
7
|
+
@request["type"]
|
8
|
+
end
|
9
|
+
|
10
|
+
def timestamp
|
11
|
+
@request["timestamp"]
|
12
|
+
end
|
13
|
+
|
14
|
+
def request_id
|
15
|
+
@request["requestId"]
|
16
|
+
end
|
17
|
+
|
7
18
|
end
|
data/lib/amazon_echo/response.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
class AmazonEcho::Response
|
2
|
-
def initialize(response
|
2
|
+
def initialize(response: {})
|
3
3
|
@version = response[:version]
|
4
4
|
@session_attributes = response[:session_attributes]
|
5
5
|
@output_speech = 'OK, done'
|
6
6
|
end
|
7
7
|
|
8
|
-
def
|
8
|
+
def say(output_speech=nil)
|
9
9
|
@output_speech = output_speech if output_speech
|
10
10
|
response
|
11
11
|
end
|
@@ -20,22 +20,22 @@ class AmazonEcho::Response
|
|
20
20
|
|
21
21
|
def response_hash
|
22
22
|
{ 'outputSpeech' => response_output_speech,
|
23
|
-
card
|
24
|
-
reprompt
|
25
|
-
shouldEndSession
|
23
|
+
'card' => response_card,
|
24
|
+
'reprompt' => response_reprompt,
|
25
|
+
'shouldEndSession' => response_end_session
|
26
26
|
}
|
27
27
|
end
|
28
28
|
|
29
29
|
def response_output_speech
|
30
|
-
{ type
|
30
|
+
{ 'type' => 'PlainText', 'text' => @output_speech }
|
31
31
|
end
|
32
32
|
|
33
33
|
def response_card
|
34
|
-
{ type
|
34
|
+
{ 'type' => 'Simple', 'title' => 'Amazon Echo gem', 'content' => 'Response from amazon echo gem' }
|
35
35
|
end
|
36
36
|
|
37
37
|
def response_reprompt
|
38
|
-
{ 'outputSpeech' => { type
|
38
|
+
{ 'outputSpeech' => { 'type' => 'PlainText', 'text' => 'Try again' }}
|
39
39
|
end
|
40
40
|
|
41
41
|
def response_end_session
|
@@ -44,9 +44,9 @@ class AmazonEcho::Response
|
|
44
44
|
|
45
45
|
def response
|
46
46
|
{
|
47
|
-
version
|
47
|
+
'version' => version,
|
48
48
|
'sessionAttributes' => session_attributes,
|
49
|
-
response
|
49
|
+
'response' => response_hash,
|
50
50
|
}
|
51
51
|
end
|
52
52
|
end
|
data/lib/amazon_echo/version.rb
CHANGED
metadata
CHANGED
@@ -1,69 +1,69 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: amazon_echo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- gomayonqui
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-10-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.8'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.8'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '10.0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - ~>
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '10.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - ~>
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '3.3'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - ~>
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '3.3'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: byebug
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
description: 'Simple client that supports requests and responses for amazon echo '
|
@@ -73,9 +73,8 @@ executables: []
|
|
73
73
|
extensions: []
|
74
74
|
extra_rdoc_files: []
|
75
75
|
files:
|
76
|
-
- .gitignore
|
77
|
-
- .rspec
|
78
|
-
- .travis.yml
|
76
|
+
- ".gitignore"
|
77
|
+
- ".rspec"
|
79
78
|
- CODE_OF_CONDUCT.md
|
80
79
|
- Gemfile
|
81
80
|
- LICENSE.txt
|
@@ -84,9 +83,13 @@ files:
|
|
84
83
|
- amazon_echo.gemspec
|
85
84
|
- bin/console
|
86
85
|
- bin/setup
|
86
|
+
- circle.yml
|
87
87
|
- lib/amazon_echo.rb
|
88
|
+
- lib/amazon_echo/intent_request.rb
|
89
|
+
- lib/amazon_echo/launch_request.rb
|
88
90
|
- lib/amazon_echo/request.rb
|
89
91
|
- lib/amazon_echo/response.rb
|
92
|
+
- lib/amazon_echo/session_ended_request.rb
|
90
93
|
- lib/amazon_echo/version.rb
|
91
94
|
homepage: https://github.com/gomayonqui/amazon_echo
|
92
95
|
licenses:
|
@@ -98,19 +101,18 @@ require_paths:
|
|
98
101
|
- lib
|
99
102
|
required_ruby_version: !ruby/object:Gem::Requirement
|
100
103
|
requirements:
|
101
|
-
- -
|
104
|
+
- - ">="
|
102
105
|
- !ruby/object:Gem::Version
|
103
106
|
version: '0'
|
104
107
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
105
108
|
requirements:
|
106
|
-
- -
|
109
|
+
- - ">="
|
107
110
|
- !ruby/object:Gem::Version
|
108
111
|
version: '0'
|
109
112
|
requirements: []
|
110
113
|
rubyforge_project:
|
111
|
-
rubygems_version: 2.4.5
|
114
|
+
rubygems_version: 2.4.5.1
|
112
115
|
signing_key:
|
113
116
|
specification_version: 4
|
114
117
|
summary: Simple client for amazon echo interface
|
115
118
|
test_files: []
|
116
|
-
has_rdoc:
|
data/.travis.yml
DELETED