dashbot 0.0.4

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a0abd02a04b3cba5c19ca08548e7735161d7393d
4
+ data.tar.gz: e88c3418e6d3e6a377534e48a92133e7217b679e
5
+ SHA512:
6
+ metadata.gz: 0be3fc0c4cba83fac03cddf36959d5cbc3830bdb05a86f4d4e5ee75b31cc8b38449fc7fdacf59b53531896ff7817adad25688a046e65cd378c1e54ec78af3de0
7
+ data.tar.gz: 14ade4f0ceec1ac083ef07922b7705039c11078678baa4c6bc415887e963f216f842b35cc95a56539ba74061ba360a8e451ba870c2ccd54ed281cb75eaa00d6f
@@ -0,0 +1,50 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /spec/examples.txt
9
+ /test/tmp/
10
+ /test/version_tmp/
11
+ /tmp/
12
+
13
+ # Used by dotenv library to load environment variables.
14
+ # .env
15
+
16
+ ## Specific to RubyMotion:
17
+ .dat*
18
+ .repl_history
19
+ build/
20
+ *.bridgesupport
21
+ build-iPhoneOS/
22
+ build-iPhoneSimulator/
23
+
24
+ ## Specific to RubyMotion (use of CocoaPods):
25
+ #
26
+ # We recommend against adding the Pods directory to your .gitignore. However
27
+ # you should judge for yourself, the pros and cons are mentioned at:
28
+ # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
29
+ #
30
+ # vendor/Pods/
31
+
32
+ ## Documentation cache and generated files:
33
+ /.yardoc/
34
+ /_yardoc/
35
+ /doc/
36
+ /rdoc/
37
+
38
+ ## Environment normalization:
39
+ /.bundle/
40
+ /vendor/bundle
41
+ /lib/bundler/man/
42
+
43
+ # for a library or gem, you might want to ignore these files since the code is
44
+ # intended to run in multiple environments; otherwise, check them in:
45
+ # Gemfile.lock
46
+ # .ruby-version
47
+ # .ruby-gemset
48
+
49
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
50
+ .rvmrc
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at nallanisridhar@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2017 VoiceLabs
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,41 @@
1
+ # Dashbot
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/dashbot`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'dashbot'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install dashbot
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/actionably/dashbot_ruby_sdk. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
36
+
37
+
38
+ ## License
39
+
40
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
41
+
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
@@ -0,0 +1,36 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'dashbot/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "dashbot"
8
+ spec.version = Dashbot::VERSION
9
+ spec.authors = ["ryanm"]
10
+ spec.email = ["ryanm@dashbot.io"]
11
+
12
+ spec.summary = "Dashbot Analytics SDK"
13
+ spec.description = "Dashbot Analytics SDK"
14
+ spec.homepage = "http://www.dashbot.io"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
19
+ # if spec.respond_to?(:metadata)
20
+ # spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
21
+ # else
22
+ # raise "RubyGems 2.0 or newer is required to protect against " \
23
+ # "public gem pushes."
24
+ # end
25
+
26
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
27
+ f.match(%r{^(test|spec|features)/})
28
+ end
29
+ # spec.bindir = "exe"
30
+ # spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
31
+ spec.require_paths = ["lib"]
32
+
33
+ spec.add_development_dependency "bundler", "~> 1.13"
34
+ spec.add_development_dependency "rake", "~> 10.0"
35
+ spec.add_dependency "rest-client"
36
+ end
@@ -0,0 +1,179 @@
1
+ require "dashbot/version"
2
+
3
+ module Dashbot
4
+
5
+ require 'json'
6
+ require 'rest-client'
7
+
8
+ class DashbotSDK
9
+
10
+ def initialize(apiKey, session)
11
+
12
+ @apiKey = ''
13
+ @session = nil
14
+ @debug = false
15
+ @urlRoot = 'https://tracker.dashbot.io/track'
16
+ @platform = 'alexa'
17
+ @source = 'gem'
18
+ @version = Dashbot::VERSION
19
+
20
+ if session == nil or apiKey == nil or apiKey.length == 0
21
+ puts "ERROR: invalid session or apiKey passed"
22
+ return
23
+ end
24
+
25
+ if @session and @session['sessionId'] == session['sessionId']
26
+ puts "Session Exists: " + @session['sessionId']
27
+ return self
28
+ end
29
+
30
+ # Instance variables
31
+ @apiKey = apiKey
32
+ @session = session
33
+
34
+ end
35
+
36
+ def regenerateEvent(intent,slots)
37
+ request = {
38
+ type:'intent',
39
+ intent: {
40
+ name:intent,
41
+ slots:slots
42
+ }
43
+ }
44
+ event = {
45
+ session: @session,
46
+ request:request,
47
+ context:{
48
+ System:{
49
+ application:@session['application'],
50
+ user:@session['user']
51
+ }
52
+ }
53
+ }
54
+ return event
55
+ end
56
+
57
+ def generateResponse(speechText)
58
+ if speechText[0,7]=='<speak>'
59
+ return {
60
+ response:{
61
+ outputSpeech:{
62
+ type:'SSML',
63
+ ssml: speechText
64
+ }
65
+ }
66
+ }
67
+ else
68
+ return {
69
+ response:{
70
+ outputSpeech:{
71
+ type:'Plaintext',
72
+ text:speechText
73
+ }
74
+ }
75
+ }
76
+ end
77
+ end
78
+
79
+ def track(intent_name, intent_request, response)
80
+
81
+ if(!intent_name)
82
+ puts "ERROR: intent_name cannot be null"
83
+ return
84
+ end
85
+
86
+ if @session == nil
87
+ puts "ERROR: Dashbot SDK has not been initialized. Initalize() method need to have been invoked before tracking"
88
+ return
89
+ end
90
+
91
+ event = regenerateEvent(intent_name,intent_request['intent']['slots'])
92
+
93
+ begin
94
+ response = JSON.parse(response)
95
+ rescue
96
+ response = response
97
+ end
98
+
99
+ #set data
100
+ if response.is_a? String
101
+ speechText = response
102
+
103
+ elsif response and response.key?('response') and response['response'].key?('outputSpeech')
104
+
105
+ speechObj = response['response']['outputSpeech']
106
+
107
+ if speechObj.key?('type')
108
+
109
+ if speechObj['type'] == 'SSML'
110
+ speechText = response['response']['outputSpeech']['ssml']
111
+
112
+ elsif speechObj['type'] == 'PlainText'
113
+ speechText = response['response']['outputSpeech']['text']
114
+
115
+ else
116
+ puts "ERROR: passed a response object with an unknown Type"
117
+ end
118
+
119
+ else
120
+ puts "ERROR: passed a response object thats not an Alexa response"
121
+ end
122
+
123
+ else
124
+ speechText = nil
125
+ end
126
+
127
+ responseGenerated = generateResponse(speechText)
128
+ logIncoming(event)
129
+ logOutgoing(event,responseGenerated)
130
+ end
131
+
132
+ def makeRequest(sURL,payload)
133
+ begin
134
+ response = RestClient::Request.execute(method: :post,
135
+ url: sURL,
136
+ payload: payload.to_json,
137
+ headers: {content_type: :json},
138
+ timeout: 1)
139
+
140
+ rescue Exception => e
141
+ puts "Exception occurred: msg = " + e.message
142
+ puts e.response.body
143
+ puts e.backtrace.inspect
144
+ end
145
+ end
146
+
147
+ def logIncoming(event)
148
+ url = @urlRoot + '?apiKey=' + @apiKey + '&type=incoming&platform='+ @platform + '&v=' + @version + '-' + @source
149
+
150
+ if @debug
151
+ puts 'Dashbot Incoming:'+url
152
+ puts event
153
+ end
154
+ data={
155
+ event:event,
156
+ }
157
+
158
+ makeRequest(url,data)
159
+ end
160
+
161
+ def logOutgoing(event,response)
162
+ url = @urlRoot + '?apiKey=' + @apiKey + '&type=outgoing&platform='+ @platform + '&v=' + @version + '-' + @source
163
+
164
+ if @debug
165
+ puts 'Dashbot Outgoing:'+url
166
+ puts event
167
+ end
168
+ data={
169
+ event:event,
170
+ response:response
171
+ }
172
+
173
+ makeRequest(url,data)
174
+
175
+ end
176
+
177
+ end
178
+ end
179
+
@@ -0,0 +1,3 @@
1
+ module Dashbot
2
+ VERSION = "0.0.4"
3
+ end
metadata ADDED
@@ -0,0 +1,94 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dashbot
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.4
5
+ platform: ruby
6
+ authors:
7
+ - ryanm
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-01-25 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.13'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.13'
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: rest-client
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Dashbot Analytics SDK
56
+ email:
57
+ - ryanm@dashbot.io
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - CODE_OF_CONDUCT.md
64
+ - LICENSE
65
+ - README.md
66
+ - Rakefile
67
+ - dashbot.gemspec
68
+ - lib/dashbot.rb
69
+ - lib/dashbot/version.rb
70
+ homepage: http://www.dashbot.io
71
+ licenses:
72
+ - MIT
73
+ metadata: {}
74
+ post_install_message:
75
+ rdoc_options: []
76
+ require_paths:
77
+ - lib
78
+ required_ruby_version: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ required_rubygems_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ requirements: []
89
+ rubyforge_project:
90
+ rubygems_version: 2.6.14
91
+ signing_key:
92
+ specification_version: 4
93
+ summary: Dashbot Analytics SDK
94
+ test_files: []