slack-ruby-bot-server-rtm 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +10 -0
  3. data/.rspec +3 -0
  4. data/.rubocop.yml +15 -0
  5. data/.rubocop_todo.yml +29 -0
  6. data/.travis.yml +21 -0
  7. data/CHANGELOG.md +5 -0
  8. data/CONTRIBUTING.md +125 -0
  9. data/Dangerfile +3 -0
  10. data/Gemfile +40 -0
  11. data/LICENSE +21 -0
  12. data/README.md +61 -0
  13. data/RELEASING.md +61 -0
  14. data/Rakefile +16 -0
  15. data/lib/slack-ruby-bot-server-rtm.rb +10 -0
  16. data/lib/slack-ruby-bot-server-rtm/config.rb +29 -0
  17. data/lib/slack-ruby-bot-server-rtm/ext.rb +3 -0
  18. data/lib/slack-ruby-bot-server-rtm/ext/slack-ruby-bot.rb +4 -0
  19. data/lib/slack-ruby-bot-server-rtm/ext/slack-ruby-bot/client.rb +14 -0
  20. data/lib/slack-ruby-bot-server-rtm/ext/slack-ruby-bot/commands/base.rb +20 -0
  21. data/lib/slack-ruby-bot-server-rtm/lifecycle.rb +31 -0
  22. data/lib/slack-ruby-bot-server-rtm/rspec.rb +5 -0
  23. data/lib/slack-ruby-bot-server-rtm/server.rb +52 -0
  24. data/lib/slack-ruby-bot-server-rtm/version.rb +7 -0
  25. data/sample_apps/sample_app_activerecord/.rspec +3 -0
  26. data/sample_apps/sample_app_activerecord/.standalone_migrations +3 -0
  27. data/sample_apps/sample_app_activerecord/Gemfile +26 -0
  28. data/sample_apps/sample_app_activerecord/Procfile +1 -0
  29. data/sample_apps/sample_app_activerecord/README.md +12 -0
  30. data/sample_apps/sample_app_activerecord/Rakefile +16 -0
  31. data/sample_apps/sample_app_activerecord/commands.rb +4 -0
  32. data/sample_apps/sample_app_activerecord/commands/help.rb +21 -0
  33. data/sample_apps/sample_app_activerecord/commands/whoami.rb +8 -0
  34. data/sample_apps/sample_app_activerecord/config.ru +24 -0
  35. data/sample_apps/sample_app_activerecord/config/newrelic.yml +217 -0
  36. data/sample_apps/sample_app_activerecord/config/postgresql.yml +17 -0
  37. data/sample_apps/sample_app_activerecord/db/migrate/20170307164946_create_teams_table.rb +14 -0
  38. data/sample_apps/sample_app_activerecord/db/migrate/20190323181453_add_activated_fields.rb +9 -0
  39. data/sample_apps/sample_app_activerecord/db/schema.rb +31 -0
  40. data/sample_apps/sample_app_activerecord/spec/api/root_spec.rb +18 -0
  41. data/sample_apps/sample_app_activerecord/spec/commands/help_spec.rb +16 -0
  42. data/sample_apps/sample_app_activerecord/spec/commands/whoami_spec.rb +16 -0
  43. data/sample_apps/sample_app_activerecord/spec/spec_helper.rb +21 -0
  44. data/sample_apps/sample_app_mongoid/.rspec +3 -0
  45. data/sample_apps/sample_app_mongoid/Gemfile +22 -0
  46. data/sample_apps/sample_app_mongoid/Procfile +1 -0
  47. data/sample_apps/sample_app_mongoid/README.md +14 -0
  48. data/sample_apps/sample_app_mongoid/Rakefile +12 -0
  49. data/sample_apps/sample_app_mongoid/commands.rb +4 -0
  50. data/sample_apps/sample_app_mongoid/commands/help.rb +21 -0
  51. data/sample_apps/sample_app_mongoid/commands/whoami.rb +8 -0
  52. data/sample_apps/sample_app_mongoid/config.ru +16 -0
  53. data/sample_apps/sample_app_mongoid/config/mongoid.yml +27 -0
  54. data/sample_apps/sample_app_mongoid/config/newrelic.yml +217 -0
  55. data/sample_apps/sample_app_mongoid/spec/api/root_spec.rb +18 -0
  56. data/sample_apps/sample_app_mongoid/spec/commands/help_spec.rb +16 -0
  57. data/sample_apps/sample_app_mongoid/spec/commands/whoami_spec.rb +16 -0
  58. data/sample_apps/sample_app_mongoid/spec/spec_helper.rb +29 -0
  59. data/slack-ruby-bot-server-rtm.gemspec +22 -0
  60. metadata +142 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 8a105023529b8c8461a6e3cd0c27c28aed730128cc33035d5a6545f4e38c9235
4
+ data.tar.gz: a83384ddb9ac372730192f8e7fba3c96d3d8c87610c280e7fa566482ecf0a653
5
+ SHA512:
6
+ metadata.gz: d9b72617f72ad3efd05b8240988d97199d55aeed0e77a11f1a4131fb80903889669133ed3408f3dd137bdedef00c38b5babadc9567277cb711cf87c94d6bf67b
7
+ data.tar.gz: b3aae099e4b071b44ec2f0e8ac705a66538aa8cb57a62e6e30a7ba9e24e488982d94b423adc71f5c74e153ce0f1b152de299e63c1ecfc24fc63402f1b9df2102
@@ -0,0 +1,10 @@
1
+ .DS_Store
2
+ .rvmrc
3
+ .irbrc
4
+ .bundle
5
+ log
6
+ .env
7
+ *.swp
8
+ Gemfile.lock
9
+ .ruby-version
10
+ pkg
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --color
2
+ --format=documentation
3
+
@@ -0,0 +1,15 @@
1
+ Metrics:
2
+ Enabled: false
3
+
4
+ Layout/LineLength:
5
+ Max: 500
6
+ Enabled: false
7
+
8
+ Style/Documentation:
9
+ Enabled: false
10
+
11
+ Style/ModuleFunction:
12
+ EnforcedStyle: extend_self
13
+
14
+ inherit_from: .rubocop_todo.yml
15
+
@@ -0,0 +1,29 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2020-11-14 17:59:41 -0500 using RuboCop version 0.81.0.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 1
10
+ # Configuration parameters: IgnoreImplicitReferences.
11
+ Lint/ShadowedArgument:
12
+ Exclude:
13
+ - 'lib/slack-ruby-bot-server-rtm/lifecycle.rb'
14
+
15
+ # Offense count: 2
16
+ # Configuration parameters: ExpectMatchingDefinition, Regex, IgnoreExecutableScripts, AllowedAcronyms.
17
+ # AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS
18
+ Naming/FileName:
19
+ Exclude:
20
+ - 'lib/slack-ruby-bot-server-rtm.rb'
21
+ - 'lib/slack-ruby-bot-server-rtm/ext/slack-ruby-bot.rb'
22
+
23
+ # Offense count: 2
24
+ # Configuration parameters: ForbiddenDelimiters.
25
+ # ForbiddenDelimiters: (?-mix:(^|\s)(EO[A-Z]{1}|END)(\s|$))
26
+ Naming/HeredocDelimiterNaming:
27
+ Exclude:
28
+ - 'sample_apps/sample_app_activerecord/commands/help.rb'
29
+ - 'sample_apps/sample_app_mongoid/commands/help.rb'
@@ -0,0 +1,21 @@
1
+ language: ruby
2
+
3
+ cache: bundler
4
+
5
+ matrix:
6
+ include:
7
+ - rvm: 2.6.6
8
+ script:
9
+ - bundle exec danger
10
+ - rvm: 2.6.6
11
+ env: DATABASE_ADAPTER=activerecord
12
+ services:
13
+ - postgresql
14
+ - rvm: 2.6.6
15
+ env: DATABASE_ADAPTER=mongoid
16
+ services:
17
+ - mongodb
18
+
19
+ script:
20
+ - bundle exec rake
21
+ - BUNDLE_GEMFILE=Gemfile && cd sample_apps/sample_app_$DATABASE_ADAPTER && bundle && RACK_ENV=test bundle exec rake
@@ -0,0 +1,5 @@
1
+ ### Changelog
2
+
3
+ #### 0.1.0 (2020/11/15)
4
+
5
+ * Initial public release - [@dblock](https://github.com/dblock).
@@ -0,0 +1,125 @@
1
+ # Contributing to SlackRubyBotServer::RealTime
2
+
3
+ This project is work of [many contributors](https://github.com/slack-ruby/slack-ruby-bot-server-rtm/graphs/contributors).
4
+
5
+ You're encouraged to submit [pull requests](https://github.com/slack-ruby/slack-ruby-bot-server-rtm/pulls), [propose features and discuss issues](https://github.com/slack-ruby/slack-ruby-bot-server-rtm/issues).
6
+
7
+ In the examples below, substitute your Github username for `contributor` in URLs.
8
+
9
+ ## Fork the Project
10
+
11
+ Fork the [project on Github](https://github.com/slack-ruby/slack-ruby-bot-server-rtm) and check out your copy.
12
+
13
+ ```
14
+ git clone https://github.com/contributor/slack-ruby-bot-server-rtm.git
15
+ cd slack-ruby-bot-server-rtm
16
+ git remote add upstream https://github.com/slack-ruby/slack-ruby-bot-server-rtm.git
17
+ ```
18
+
19
+ ## Create a Topic Branch
20
+
21
+ Make sure your fork is up-to-date and create a topic branch for your feature or bug fix.
22
+
23
+ ```
24
+ git checkout master
25
+ git pull upstream master
26
+ git checkout -b my-feature-branch
27
+ ```
28
+
29
+ ## Bundle Install and Test
30
+
31
+ Ensure that you can build the project and run tests.
32
+
33
+ ```
34
+ bundle install
35
+ bundle exec rake
36
+ ```
37
+
38
+ ## Write Tests
39
+
40
+ Try to write a test that reproduces the problem you're trying to fix or describes a feature that you want to build.
41
+ Add to [spec](spec).
42
+
43
+ We definitely appreciate pull requests that highlight or reproduce a problem, even without a fix.
44
+
45
+ ## Write Code
46
+
47
+ Implement your feature or bug fix.
48
+
49
+ Ruby style is enforced with [Rubocop](https://github.com/bbatsov/rubocop).
50
+ Run `bundle exec rubocop` and fix any style issues highlighted.
51
+
52
+ Make sure that `bundle exec rake` completes without errors.
53
+
54
+ ## Write Documentation
55
+
56
+ Document any external behavior in the [README](README.md).
57
+
58
+ ## Update Changelog
59
+
60
+ Add a line to [CHANGELOG](CHANGELOG.md) under *Next Release*.
61
+ Make it look like every other line, including your name and link to your Github account.
62
+
63
+ ## Commit Changes
64
+
65
+ Make sure git knows your name and email address:
66
+
67
+ ```
68
+ git config --global user.name "Your Name"
69
+ git config --global user.email "contributor@example.com"
70
+ ```
71
+
72
+ Writing good commit logs is important. A commit log should describe what changed and why.
73
+
74
+ ```
75
+ git add ...
76
+ git commit
77
+ ```
78
+
79
+ ## Push
80
+
81
+ ```
82
+ git push origin my-feature-branch
83
+ ```
84
+
85
+ ## Make a Pull Request
86
+
87
+ Go to https://github.com/contributor/slack-ruby-bot-server-rtm and select your feature branch.
88
+ Click the 'Pull Request' button and fill out the form. Pull requests are usually reviewed within a few days.
89
+
90
+ ## Rebase
91
+
92
+ If you've been working on a change for a while, rebase with upstream/master.
93
+
94
+ ```
95
+ git fetch upstream
96
+ git rebase upstream/master
97
+ git push origin my-feature-branch -f
98
+ ```
99
+
100
+ ## Update CHANGELOG Again
101
+
102
+ Update the [CHANGELOG](CHANGELOG.md) with the pull request number. A typical entry looks as follows.
103
+
104
+ ```
105
+ * [#123](https://github.com/slack-ruby/slack-ruby-bot-server-rtm/pull/123): Reticulated splines - [@contributor](https://github.com/contributor).
106
+ ```
107
+
108
+ Amend your previous commit and force push the changes.
109
+
110
+ ```
111
+ git commit --amend
112
+ git push origin my-feature-branch -f
113
+ ```
114
+
115
+ ## Check on Your Pull Request
116
+
117
+ Go back to your pull request after a few minutes and see whether it passed muster with Travis-CI. Everything should look green, otherwise fix issues and amend your commit as described above.
118
+
119
+ ## Be Patient
120
+
121
+ It's likely that your change will not be merged and that the nitpicky maintainers will ask you to do more, or fix seemingly benign problems. Hang on there!
122
+
123
+ ## Thank You
124
+
125
+ Please do know that we really appreciate and value your time and work. We love you, really.
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ danger.import_dangerfile(gem: 'slack-ruby-danger')
data/Gemfile ADDED
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ case ENV['DATABASE_ADAPTER']
6
+ when 'mongoid' then
7
+ gem 'kaminari-mongoid'
8
+ gem 'mongoid'
9
+ gem 'mongoid-scroll'
10
+ when 'activerecord' then
11
+ gem 'activerecord', '~> 5.0.0'
12
+ gem 'otr-activerecord', '~> 1.2.1'
13
+ gem 'virtus'
14
+ gem 'cursor_pagination' # rubocop:disable Bundler/OrderedGems
15
+ gem 'pg'
16
+ when nil
17
+ warn "Missing ENV['DATABASE_ADAPTER']."
18
+ else
19
+ warn "Invalid ENV['DATABASE_ADAPTER']: #{ENV['DATABASE_ADAPTER']}."
20
+ end
21
+
22
+ gemspec
23
+
24
+ group :development, :test do
25
+ gem 'bundler'
26
+ gem 'database_cleaner'
27
+ gem 'fabrication'
28
+ gem 'faker'
29
+ gem 'hyperclient'
30
+ gem 'rack-test'
31
+ gem 'rake'
32
+ gem 'rspec'
33
+ gem 'rubocop', '0.81.0'
34
+ gem 'vcr'
35
+ gem 'webmock'
36
+ end
37
+
38
+ group :test do
39
+ gem 'slack-ruby-danger', '~> 0.2.0', require: false
40
+ end
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 Daniel Doubrovkine & Contributors
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,61 @@
1
+ Slack Ruby Bot Server RealTime (RTM) Extension
2
+ ==============================================
3
+
4
+ [![Gem Version](https://badge.fury.io/rb/slack-ruby-bot-server-rtm.svg)](https://badge.fury.io/rb/slack-ruby-bot-server-rtm)
5
+ [![Build Status](https://travis-ci.org/slack-ruby/slack-ruby-bot-server-rtm.svg?branch=master)](https://travis-ci.org/slack-ruby/slack-ruby-bot-server-rtm)
6
+
7
+ An extension to [slack-ruby-bot-server](https://github.com/slack-ruby/slack-ruby-bot-server) that makes it easy to implement Slack RTM bots.
8
+
9
+ ### Sample
10
+
11
+ See [slack-ruby/slack-ruby-bot-server-rtm-sample](https://github.com/slack-ruby/slack-ruby-bot-server-rtm-sample) for a working sample.
12
+
13
+ ### Usage
14
+
15
+ #### Gemfile
16
+
17
+ Add 'slack-ruby-bot-server-rtm' to Gemfile.
18
+
19
+ ```ruby
20
+ gem 'slack-ruby-bot-server-rtm'
21
+ ```
22
+
23
+ #### Configure
24
+
25
+ ```ruby
26
+ SlackRubyBotServer::RealTime.configure do |config|
27
+ config.server_class = ...
28
+ end
29
+ ```
30
+
31
+ The following settings are supported.
32
+
33
+ setting | description
34
+ ----------------------|------------------------------------------------------------------
35
+ server_class | Handler class for additional events.
36
+
37
+ ##### Server Class
38
+
39
+ You can override the server class to handle additional events, and configure the service to use it.
40
+
41
+ ```ruby
42
+ class MyServer < SlackRubyBotServer::Server
43
+ on :hello do |client, data|
44
+ # connected to Slack
45
+ end
46
+
47
+ on :channel_joined do |client, data|
48
+ # the bot joined a channel in data.channel['id']
49
+ end
50
+ end
51
+
52
+ SlackRubyBotServer::RealTime.configure do |config|
53
+ config.server_class = MyServer
54
+ end
55
+ ```
56
+
57
+ ### Copyright & License
58
+
59
+ Copyright [Daniel Doubrovkine](http://code.dblock.org) and Contributors, 2020
60
+
61
+ [MIT License](LICENSE)
@@ -0,0 +1,61 @@
1
+ # Releasing Slack-Ruby-Bot-Server-Rtm
2
+
3
+ There're no hard rules about when to release slack-ruby-bot-server-rtm. Release bug fixes frequently, features not so frequently and breaking API changes rarely.
4
+
5
+ ### Release
6
+
7
+ Run tests, check that all tests succeed locally.
8
+
9
+ ```
10
+ bundle install
11
+ rake
12
+ ```
13
+
14
+ Check that the last build succeeded in [Travis CI](https://travis-ci.org/slack-ruby/slack-ruby-bot-server-rtm) for all supported platforms.
15
+
16
+ Change "Next" in [CHANGELOG.md](CHANGELOG.md) to the current date.
17
+
18
+ ```
19
+ ### 0.2.2 (7/10/2015)
20
+ ```
21
+
22
+ Remove the line with "Your contribution here.", since there will be no more contributions to this release.
23
+
24
+ Commit your changes.
25
+
26
+ ```
27
+ git add CHANGELOG.md
28
+ git commit -m "Preparing for release, 0.2.2."
29
+ git push origin master
30
+ ```
31
+
32
+ Release.
33
+
34
+ ```
35
+ $ rake release
36
+
37
+ slack-ruby-bot-server-rtm 0.2.2 built to pkg/slack-ruby-bot-server-rtm-0.2.2.gem.
38
+ Tagged v0.2.2.
39
+ Pushed git commits and tags.
40
+ Pushed slack-ruby-bot-server-rtm 0.2.2 to rubygems.org.
41
+ ```
42
+
43
+ ### Prepare for the Next Version
44
+
45
+ Add the next release to [CHANGELOG.md](CHANGELOG.md).
46
+
47
+ ```
48
+ ### 0.2.3 (Next)
49
+
50
+ * Your contribution here.
51
+ ```
52
+
53
+ Increment the third version number in [lib/slack-ruby-bot-server-rtm/version.rb](lib/slack-ruby-bot-server-rtm/version.rb).
54
+
55
+ Commit your changes.
56
+
57
+ ```
58
+ git add CHANGELOG.md lib/slack-ruby-bot-server-rtm/version.rb
59
+ git commit -m "Preparing for next development iteration, 0.2.3."
60
+ git push origin master
61
+ ```
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rubygems'
4
+ require 'bundler/gem_tasks'
5
+
6
+ require 'rspec/core'
7
+ require 'rspec/core/rake_task'
8
+
9
+ RSpec::Core::RakeTask.new(:spec) do |spec|
10
+ spec.pattern = FileList['spec/**/*_spec.rb'].exclude(%r{ext\/(?!#{ENV['DATABASE_ADAPTER']})})
11
+ end
12
+
13
+ require 'rubocop/rake_task'
14
+ RuboCop::RakeTask.new
15
+
16
+ task default: %i[rubocop spec]
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'slack-ruby-bot'
4
+ require 'slack-ruby-bot-server'
5
+
6
+ require_relative 'slack-ruby-bot-server-rtm/version'
7
+ require_relative 'slack-ruby-bot-server-rtm/server'
8
+ require_relative 'slack-ruby-bot-server-rtm/config'
9
+ require_relative 'slack-ruby-bot-server-rtm/ext'
10
+ require_relative 'slack-ruby-bot-server-rtm/lifecycle'