slack-ruby-bot-server 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +30 -4
- data/UPGRADING.md +32 -0
- data/lib/slack-ruby-bot-server/app.rb +1 -1
- data/lib/slack-ruby-bot-server/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4d16d65efc278c6cc7ae66e43012323a7675f45d
|
4
|
+
data.tar.gz: 4a4a3392ab0fb18640a23d6f56f848d731b113e9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 074ba2f86c6761a2e5c41f4dbca6bd1f8a5b7d226a19370c297b9fc1b6410d1123784f2f7540e6596498a84e502fdb4fabc733055bd5ceb4ef4a270b94f2393a
|
7
|
+
data.tar.gz: 040856718b74ad9f9fd9ecabd7e3d77c1cdd0257051d3aa126bf82007118696aa63a9152df5b14aa3cc15250c0718f8215934066ffc7360082f445b5e3738ec3
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
### Changelog
|
2
2
|
|
3
|
+
#### 0.3.1 (7/10/2016)
|
4
|
+
|
5
|
+
* [#22](https://github.com/dblock/slack-ruby-bot-server/issues/22): Subclassing `SlackRubyBotServer::App` creates an `.instance` of child class - [@dblock](https://github.com/dblock).
|
6
|
+
|
3
7
|
#### 0.3.0 (7/4/2016)
|
4
8
|
|
5
9
|
* Specify the server class via `SlackRubyBotServer.configure`, default is `SlackRubyBotServer::Server` - [@dblock](https://github.com/dblock).
|
data/README.md
CHANGED
@@ -13,7 +13,7 @@ A library that contains a [Grape](http://github.com/ruby-grape/grape) API servin
|
|
13
13
|
|
14
14
|
### Stable Release
|
15
15
|
|
16
|
-
You're reading the documentation for the **stable** release of slack-ruby-bot-server
|
16
|
+
You're reading the documentation for the **stable** release of slack-ruby-bot-server 0.3.1. See [UPGRADING](UPGRADING.md) when upgrading from an older version.
|
17
17
|
|
18
18
|
### Try Me
|
19
19
|
|
@@ -41,7 +41,33 @@ If you deploy to Heroku set `SLACK_CLIENT_ID` and `SLACK_CLIENT_SECRET` via `her
|
|
41
41
|
|
42
42
|
### API
|
43
43
|
|
44
|
-
This library implements a service manager, [SlackRubyBotServer::Service](lib/slack-ruby-bot-server/service.rb) that creates multiple instances of a bot server class, [SlackRubyBotServer::Server](lib/slack-ruby-bot-server/server.rb), one per team.
|
44
|
+
This library implements an app, [SlackRubyBotServer::App](lib/slack-ruby-bot-server/app.rb), a service manager, [SlackRubyBotServer::Service](lib/slack-ruby-bot-server/service.rb) that creates multiple instances of a bot server class, [SlackRubyBotServer::Server](lib/slack-ruby-bot-server/server.rb), one per team.
|
45
|
+
|
46
|
+
#### App
|
47
|
+
|
48
|
+
The app instance checks for a working MongoDB connection, ensures database indexes, performs database migrations, sets up bot aliases and log levels. You can introduce custom behavior into the app lifecycle by subclassing `SlackRubyBotServer::App` and creating an instance of the child class in `config.ru`.
|
49
|
+
|
50
|
+
```ruby
|
51
|
+
class MyApp < SlackRubyBotServer::App
|
52
|
+
def prepare!
|
53
|
+
super
|
54
|
+
deactivate_sleepy_teams!
|
55
|
+
end
|
56
|
+
|
57
|
+
private
|
58
|
+
|
59
|
+
def deactivate_sleepy_teams!
|
60
|
+
Team.active.each do |team|
|
61
|
+
next unless team.sleepy?
|
62
|
+
team.deactivate!
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
```
|
67
|
+
|
68
|
+
```ruby
|
69
|
+
MyApp.instance.prepare!
|
70
|
+
```
|
45
71
|
|
46
72
|
#### Service Manager
|
47
73
|
|
@@ -86,7 +112,7 @@ The following callbacks are supported. All callbacks receive a `team`, except `e
|
|
86
112
|
You can override the server class to handle additional events, and configure the service to use it.
|
87
113
|
|
88
114
|
```ruby
|
89
|
-
class
|
115
|
+
class MyServer < SlackRubyBotServer::Server
|
90
116
|
on :hello do |client, data|
|
91
117
|
# connected to Slack
|
92
118
|
end
|
@@ -97,7 +123,7 @@ class MyServerClass < SlackRubyBotServer::Server
|
|
97
123
|
end
|
98
124
|
|
99
125
|
SlackRubyBotServer.configure do |config|
|
100
|
-
config.server_class =
|
126
|
+
config.server_class = MyServer
|
101
127
|
end
|
102
128
|
```
|
103
129
|
|
data/UPGRADING.md
CHANGED
@@ -1,6 +1,38 @@
|
|
1
1
|
Upgrading Slack-Ruby-Bot-Server
|
2
2
|
===============================
|
3
3
|
|
4
|
+
### Upgrading to >= 0.3.1
|
5
|
+
|
6
|
+
#### Remove Monkey-Patching of SlackRubyBotServer::App
|
7
|
+
|
8
|
+
You no longer need to monkey-patch the app class. You can subclass it and invoke additional `prepare!` methods.
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
class MyApp < SlackRubyBotServer::App
|
12
|
+
def prepare!
|
13
|
+
super
|
14
|
+
deactivate_sleepy_teams!
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def deactivate_sleepy_teams!
|
20
|
+
Team.active.each do |team|
|
21
|
+
next unless team.sleepy?
|
22
|
+
team.deactivate!
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
```
|
27
|
+
|
28
|
+
Make sure to create an `.instance` of the child class.
|
29
|
+
|
30
|
+
```ruby
|
31
|
+
MyApp.instance.prepare!
|
32
|
+
```
|
33
|
+
|
34
|
+
See [#22](https://github.com/dblock/slack-ruby-bot-server/issues/22) for additional information.
|
35
|
+
|
4
36
|
### Upgrading to >= 0.3.0
|
5
37
|
|
6
38
|
#### Remove Monkey-Patching of SlackRubyBotServer::Server
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slack-ruby-bot-server
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Doubrovkine
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-07-
|
11
|
+
date: 2016-07-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: slack-ruby-bot
|