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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fe3d4e567729e994efcff5222076507a045bb6ed
4
- data.tar.gz: 0cabe19a3a25a1d6c396a86b9f357ceb6f753faa
3
+ metadata.gz: 4d16d65efc278c6cc7ae66e43012323a7675f45d
4
+ data.tar.gz: 4a4a3392ab0fb18640a23d6f56f848d731b113e9
5
5
  SHA512:
6
- metadata.gz: 2e6fbb4ee203832c867036bff4e20a814b64d6d722306c616a677e04a6fe67627019edba8893d974a7ff5b09890faadf39c88aee074915cae058078aa6030964
7
- data.tar.gz: 458eb4c1e9c41be7b509239acdd16d92d9c12ad41d9d99f33d54a8dca4770d5353cc889a33f27d1b53e2a472c23a52f7130591f89f0cbc13cc943f9dfd4dfc33
6
+ metadata.gz: 074ba2f86c6761a2e5c41f4dbca6bd1f8a5b7d226a19370c297b9fc1b6410d1123784f2f7540e6596498a84e502fdb4fabc733055bd5ceb4ef4a270b94f2393a
7
+ data.tar.gz: 040856718b74ad9f9fd9ecabd7e3d77c1cdd0257051d3aa126bf82007118696aa63a9152df5b14aa3cc15250c0718f8215934066ffc7360082f445b5e3738ec3
@@ -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, 0.3.0. See [UPGRADING](UPGRADING.md) when upgrading from an older version.
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 MyServerClass < SlackRubyBotServer::Server
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 = MyServerClass
126
+ config.server_class = MyServer
101
127
  end
102
128
  ```
103
129
 
@@ -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
@@ -13,7 +13,7 @@ module SlackRubyBotServer
13
13
  end
14
14
 
15
15
  def self.instance
16
- @instance ||= SlackRubyBotServer::App.new
16
+ @instance ||= new
17
17
  end
18
18
 
19
19
  private
@@ -1,3 +1,3 @@
1
1
  module SlackRubyBotServer
2
- VERSION = '0.3.0'.freeze
2
+ VERSION = '0.3.1'.freeze
3
3
  end
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.0
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-04 00:00:00.000000000 Z
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