slack-ruby-bot-server 1.2.1 → 2.1.0
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.
- checksums.yaml +4 -4
- data/.github/workflows/danger.yml +1 -1
- data/.github/workflows/rubocop.yml +3 -3
- data/.github/workflows/test-mongodb.yml +5 -0
- data/.github/workflows/test-postgresql.yml +7 -2
- data/.gitignore +1 -0
- data/.rubocop.yml +4 -1
- data/.rubocop_todo.yml +121 -14
- data/CHANGELOG.md +20 -0
- data/CONTRIBUTING.md +7 -0
- data/Gemfile +7 -6
- data/README.md +11 -6
- data/RELEASING.md +10 -10
- data/UPGRADING.md +12 -0
- data/lib/slack-ruby-bot-server/api/endpoints/teams_endpoint.rb +1 -1
- data/lib/slack-ruby-bot-server/api/helpers/cursor_helpers.rb +8 -2
- data/lib/slack-ruby-bot-server/config/database_adapters/activerecord.rb +3 -0
- data/lib/slack-ruby-bot-server/config/pagy.rb +236 -0
- data/lib/slack-ruby-bot-server/config.rb +1 -1
- data/lib/slack-ruby-bot-server/ext/bson/object_id.rb +9 -7
- data/lib/slack-ruby-bot-server/ext.rb +2 -3
- data/lib/slack-ruby-bot-server/models/team/methods.rb +2 -2
- data/lib/slack-ruby-bot-server/service.rb +32 -15
- data/lib/slack-ruby-bot-server/version.rb +1 -1
- metadata +8 -8
- data/lib/slack-ruby-bot-server/ext/mongoid/slack-ruby-bot/commands/base.rb +0 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c2763c471bf4339d40cc6d190d695a0afdf82ae671d33580638fc52d857c4428
|
4
|
+
data.tar.gz: fd852824309f190ce382ed605e14e80e60215c5b1daf70969d30d9d78d100a09
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e6bd7d7fee1bb591d6991370292fe56304dfa92a580ea566e6077ddbdbd761c7aa748dbf32a5e4019425e9f66dd24c940833257eccd35a39c0b08968161d2267
|
7
|
+
data.tar.gz: d4255577b57693820a47cbffe0fac3bc659c63edb5c5a49023de6e2e757f056ef506a4c4a9e78bc2e6fa1803c19636cf7b69de9b595bfce46346a6a3d7de7014
|
@@ -19,5 +19,5 @@ jobs:
|
|
19
19
|
run: |
|
20
20
|
bundle install
|
21
21
|
# the personal token is public, this is ok, base64 encode to avoid tripping Github
|
22
|
-
TOKEN=$(echo -n
|
22
|
+
TOKEN=$(echo -n Z2hwX0xNQ3VmanBFeTBvYkZVTWh6NVNqVFFBOEUxU25abzBqRUVuaAo= | base64 --decode)
|
23
23
|
DANGER_GITHUB_API_TOKEN=$TOKEN bundle exec danger --verbose
|
@@ -1,16 +1,16 @@
|
|
1
1
|
---
|
2
|
-
name:
|
2
|
+
name: lint
|
3
3
|
on: [push, pull_request]
|
4
4
|
jobs:
|
5
5
|
lint:
|
6
6
|
name: RuboCop
|
7
7
|
runs-on: ubuntu-latest
|
8
8
|
steps:
|
9
|
-
- uses: actions/checkout@
|
9
|
+
- uses: actions/checkout@v3
|
10
10
|
- name: Set up Ruby
|
11
11
|
uses: ruby/setup-ruby@v1
|
12
12
|
with:
|
13
|
-
ruby-version:
|
13
|
+
ruby-version: '3.1'
|
14
14
|
bundler-cache: true
|
15
15
|
- name: Run RuboCop
|
16
16
|
run: bundle exec rubocop
|
@@ -10,6 +10,9 @@ jobs:
|
|
10
10
|
- { ruby: 2.6.2, mongoid: 6.4.8, mongodb: 4.4 }
|
11
11
|
- { ruby: 2.6.2, mongoid: 7.2.3, mongodb: 4.4 }
|
12
12
|
- { ruby: 2.6.2, mongoid: 7.3.0, mongodb: 4.4 }
|
13
|
+
- { ruby: 3.1.1, mongoid: 7.3.0, mongodb: 4.4 }
|
14
|
+
- { ruby: 3.1.1, mongoid: 7.3.0, mongodb: 5.0 }
|
15
|
+
- { ruby: 3.2.1, mongoid: 7.5.2, mongodb: 5.0 }
|
13
16
|
name: test (ruby=${{ matrix.entry.ruby }}, mongoid=${{ matrix.entry.mongoid }}, mongodb=${{ matrix.entry.mongodb }})
|
14
17
|
steps:
|
15
18
|
- uses: actions/checkout@v2
|
@@ -17,6 +20,8 @@ jobs:
|
|
17
20
|
with:
|
18
21
|
ruby-version: ${{ matrix.entry.ruby }}
|
19
22
|
- uses: browser-actions/setup-geckodriver@latest
|
23
|
+
with:
|
24
|
+
token: ${{ secrets.GITHUB_TOKEN }}
|
20
25
|
- run: geckodriver --version
|
21
26
|
- uses: supercharge/mongodb-github-action@1.7.0
|
22
27
|
with:
|
@@ -7,14 +7,18 @@ jobs:
|
|
7
7
|
strategy:
|
8
8
|
matrix:
|
9
9
|
entry:
|
10
|
-
- { ruby: 2.6.2, postgresql: 11 }
|
11
|
-
|
10
|
+
- { ruby: 2.6.2, postgresql: 11, active_record: '~> 6.0.0' }
|
11
|
+
- { ruby: 3.1.1, postgresql: 11, active_record: '~> 6.1.0' }
|
12
|
+
- { ruby: 3.1.1, postgresql: 14, active_record: '~> 7.0.0' }
|
13
|
+
name: test (ruby=${{ matrix.entry.ruby }}, postgresql=${{ matrix.entry.postgresql }}, active_record=${{ matrix.entry.active_record }})
|
12
14
|
steps:
|
13
15
|
- uses: actions/checkout@v2
|
14
16
|
- uses: ruby/setup-ruby@v1
|
15
17
|
with:
|
16
18
|
ruby-version: ${{ matrix.entry.ruby }}
|
17
19
|
- uses: browser-actions/setup-geckodriver@latest
|
20
|
+
with:
|
21
|
+
token: ${{ secrets.GITHUB_TOKEN }}
|
18
22
|
- run: geckodriver --version
|
19
23
|
- uses: harmon758/postgresql-action@v1
|
20
24
|
with:
|
@@ -26,6 +30,7 @@ jobs:
|
|
26
30
|
uses: GabrielBB/xvfb-action@v1
|
27
31
|
env:
|
28
32
|
DATABASE_ADAPTER: activerecord
|
33
|
+
ACTIVERECORD_VERSION: ${{ matrix.entry.active_record }}
|
29
34
|
DATABASE_URL: postgres://test:password@localhost/slack_ruby_bot_server_test
|
30
35
|
with:
|
31
36
|
run: |
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
data/.rubocop_todo.yml
CHANGED
@@ -1,32 +1,46 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config`
|
3
|
-
# on
|
3
|
+
# on 2023-03-02 20:56:34 UTC using RuboCop version 1.47.0.
|
4
4
|
# The point is for the user to remove these configuration records
|
5
5
|
# one by one as the offenses are removed from the code base.
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
7
7
|
# versions of RuboCop, may require this file to be generated again.
|
8
8
|
|
9
9
|
# Offense count: 1
|
10
|
-
#
|
11
|
-
#
|
12
|
-
|
10
|
+
# Configuration parameters: Severity, Include.
|
11
|
+
# Include: **/*.gemspec
|
12
|
+
Gemspec/RequiredRubyVersion:
|
13
|
+
Exclude:
|
14
|
+
- 'slack-ruby-bot-server.gemspec'
|
15
|
+
|
16
|
+
# Offense count: 1
|
17
|
+
# This cop supports safe autocorrection (--autocorrect).
|
13
18
|
Layout/HeredocIndentation:
|
14
19
|
Exclude:
|
15
20
|
- 'lib/slack-ruby-bot-server/info.rb'
|
16
21
|
|
17
22
|
# Offense count: 1
|
23
|
+
# This cop supports safe autocorrection (--autocorrect).
|
24
|
+
Layout/RescueEnsureAlignment:
|
25
|
+
Exclude:
|
26
|
+
- 'lib/slack-ruby-bot-server/models/team/methods.rb'
|
27
|
+
|
28
|
+
# Offense count: 1
|
29
|
+
# This cop supports safe autocorrection (--autocorrect).
|
18
30
|
Lint/AmbiguousOperator:
|
19
31
|
Exclude:
|
20
32
|
- 'spec/slack-ruby-bot-server/service_spec.rb'
|
21
33
|
|
22
|
-
# Offense count:
|
23
|
-
#
|
24
|
-
|
34
|
+
# Offense count: 1
|
35
|
+
# Configuration parameters: AllowedMethods.
|
36
|
+
# AllowedMethods: enums
|
37
|
+
Lint/ConstantDefinitionInBlock:
|
25
38
|
Exclude:
|
26
|
-
- '
|
39
|
+
- 'lib/slack-ruby-bot-server/models/team/methods.rb'
|
27
40
|
|
28
41
|
# Offense count: 1
|
29
|
-
# Configuration parameters: ExpectMatchingDefinition, Regex, IgnoreExecutableScripts, AllowedAcronyms.
|
42
|
+
# Configuration parameters: ExpectMatchingDefinition, CheckDefinitionPathHierarchy, CheckDefinitionPathHierarchyRoots, Regex, IgnoreExecutableScripts, AllowedAcronyms.
|
43
|
+
# CheckDefinitionPathHierarchyRoots: lib, spec, test, src
|
30
44
|
# 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
|
31
45
|
Naming/FileName:
|
32
46
|
Exclude:
|
@@ -34,33 +48,126 @@ Naming/FileName:
|
|
34
48
|
|
35
49
|
# Offense count: 1
|
36
50
|
# Configuration parameters: ForbiddenDelimiters.
|
37
|
-
# ForbiddenDelimiters: (
|
51
|
+
# ForbiddenDelimiters: (?i-mx:(^|\s)(EO[A-Z]{1}|END)(\s|$))
|
38
52
|
Naming/HeredocDelimiterNaming:
|
39
53
|
Exclude:
|
40
54
|
- 'lib/slack-ruby-bot-server/info.rb'
|
41
55
|
|
42
56
|
# Offense count: 3
|
43
57
|
# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
|
44
|
-
# AllowedNames:
|
58
|
+
# AllowedNames: as, at, by, cc, db, id, if, in, io, ip, of, on, os, pp, to
|
45
59
|
Naming/MethodParameterName:
|
46
60
|
Exclude:
|
47
61
|
- 'lib/slack-ruby-bot-server/models/team/activerecord.rb'
|
48
62
|
- 'lib/slack-ruby-bot-server/models/team/mongoid.rb'
|
49
63
|
- 'lib/slack-ruby-bot-server/service.rb'
|
50
64
|
|
65
|
+
# Offense count: 5
|
66
|
+
# This cop supports safe autocorrection (--autocorrect).
|
67
|
+
# Configuration parameters: EnforcedStyle.
|
68
|
+
# SupportedStyles: separated, grouped
|
69
|
+
Style/AccessorGrouping:
|
70
|
+
Exclude:
|
71
|
+
- 'lib/slack-ruby-bot-server/config.rb'
|
72
|
+
|
73
|
+
# Offense count: 3
|
74
|
+
# This cop supports unsafe autocorrection (--autocorrect-all).
|
75
|
+
Style/GlobalStdStream:
|
76
|
+
Exclude:
|
77
|
+
- 'spec/database_adapters/activerecord/activerecord.rb'
|
78
|
+
- 'tasks/db.rake'
|
79
|
+
|
80
|
+
# Offense count: 18
|
81
|
+
# This cop supports safe autocorrection (--autocorrect).
|
82
|
+
# Configuration parameters: EnforcedStyle, EnforcedShorthandSyntax, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols.
|
83
|
+
# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys
|
84
|
+
# SupportedShorthandSyntax: always, never, either, consistent
|
85
|
+
Style/HashSyntax:
|
86
|
+
Exclude:
|
87
|
+
- 'lib/slack-ruby-bot-server/api/endpoints/teams_endpoint.rb'
|
88
|
+
- 'lib/slack-ruby-bot-server/models/team/methods.rb'
|
89
|
+
|
90
|
+
# Offense count: 1
|
91
|
+
# This cop supports unsafe autocorrection (--autocorrect-all).
|
92
|
+
Style/HashTransformKeys:
|
93
|
+
Exclude:
|
94
|
+
- 'lib/slack-ruby-bot-server/api/helpers/error_helpers.rb'
|
95
|
+
|
96
|
+
# Offense count: 1
|
97
|
+
# This cop supports unsafe autocorrection (--autocorrect-all).
|
98
|
+
Style/HashTransformValues:
|
99
|
+
Exclude:
|
100
|
+
- 'lib/slack-ruby-bot-server/api/helpers/error_helpers.rb'
|
101
|
+
|
51
102
|
# Offense count: 1
|
52
|
-
#
|
103
|
+
# This cop supports unsafe autocorrection (--autocorrect-all).
|
53
104
|
# Configuration parameters: EnforcedStyle, Autocorrect.
|
54
105
|
# SupportedStyles: module_function, extend_self, forbidden
|
55
106
|
Style/ModuleFunction:
|
56
107
|
Exclude:
|
57
108
|
- 'lib/slack-ruby-bot-server/config.rb'
|
58
109
|
|
110
|
+
# Offense count: 2
|
111
|
+
# This cop supports safe autocorrection (--autocorrect).
|
112
|
+
Style/MultilineWhenThen:
|
113
|
+
Exclude:
|
114
|
+
- 'Gemfile'
|
115
|
+
|
59
116
|
# Offense count: 1
|
60
|
-
#
|
61
|
-
# Configuration parameters:
|
117
|
+
# This cop supports unsafe autocorrection (--autocorrect-all).
|
118
|
+
# Configuration parameters: EnforcedStyle, AllowedMethods, AllowedPatterns.
|
62
119
|
# SupportedStyles: predicate, comparison
|
63
120
|
Style/NumericPredicate:
|
64
121
|
Exclude:
|
65
122
|
- 'spec/**/*'
|
66
123
|
- 'lib/slack-ruby-bot-server/service.rb'
|
124
|
+
|
125
|
+
# Offense count: 1
|
126
|
+
# This cop supports safe autocorrection (--autocorrect).
|
127
|
+
Style/RedundantAssignment:
|
128
|
+
Exclude:
|
129
|
+
- 'lib/slack-ruby-bot-server/api/helpers/sort_helpers.rb'
|
130
|
+
|
131
|
+
# Offense count: 3
|
132
|
+
# This cop supports safe autocorrection (--autocorrect).
|
133
|
+
Style/RedundantBegin:
|
134
|
+
Exclude:
|
135
|
+
- 'lib/slack-ruby-bot-server/models/team/activerecord.rb'
|
136
|
+
- 'lib/slack-ruby-bot-server/models/team/mongoid.rb'
|
137
|
+
- 'lib/slack-ruby-bot-server/service.rb'
|
138
|
+
|
139
|
+
# Offense count: 2
|
140
|
+
# This cop supports safe autocorrection (--autocorrect).
|
141
|
+
Style/RedundantFileExtensionInRequire:
|
142
|
+
Exclude:
|
143
|
+
- 'lib/slack-ruby-bot-server/config/database_adapters/activerecord.rb'
|
144
|
+
- 'lib/slack-ruby-bot-server/config/database_adapters/mongoid.rb'
|
145
|
+
|
146
|
+
# Offense count: 6
|
147
|
+
# This cop supports safe autocorrection (--autocorrect).
|
148
|
+
Style/RedundantRegexpEscape:
|
149
|
+
Exclude:
|
150
|
+
- 'Rakefile'
|
151
|
+
- 'lib/slack-ruby-bot-server/api/middleware.rb'
|
152
|
+
- 'spec/support/api/endpoints/it_behaves_like_a_cursor_api.rb'
|
153
|
+
|
154
|
+
# Offense count: 1
|
155
|
+
# This cop supports unsafe autocorrection (--autocorrect-all).
|
156
|
+
# Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods, MaxChainLength.
|
157
|
+
# AllowedMethods: present?, blank?, presence, try, try!
|
158
|
+
Style/SafeNavigation:
|
159
|
+
Exclude:
|
160
|
+
- 'lib/slack-ruby-bot-server/api/endpoints/teams_endpoint.rb'
|
161
|
+
|
162
|
+
# Offense count: 1
|
163
|
+
# This cop supports unsafe autocorrection (--autocorrect-all).
|
164
|
+
Style/SlicingWithRange:
|
165
|
+
Exclude:
|
166
|
+
- 'lib/slack-ruby-bot-server/api/helpers/sort_helpers.rb'
|
167
|
+
|
168
|
+
# Offense count: 1
|
169
|
+
# This cop supports unsafe autocorrection (--autocorrect-all).
|
170
|
+
# Configuration parameters: Mode.
|
171
|
+
Style/StringConcatenation:
|
172
|
+
Exclude:
|
173
|
+
- 'lib/slack-ruby-bot-server/api/helpers/error_helpers.rb'
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,25 @@
|
|
1
1
|
### Changelog
|
2
2
|
|
3
|
+
### 2.1.0 (2023/03/06)
|
4
|
+
|
5
|
+
* [#163](https://github.com/slack-ruby/slack-ruby-bot-server/pull/163): Updated releasing documentation - [@crazyoptimist](https://github.com/crazyoptimist).
|
6
|
+
* [#164](https://github.com/slack-ruby/slack-ruby-bot-server/pull/164): Added support for ActiveRecord 6.1 and 7.0 - [@maths22](https://github.com/maths22).
|
7
|
+
* [#165](https://github.com/slack-ruby/slack-ruby-bot-server/pull/165): Upgraded Rubocop to v1.47 - [@crazyoptimist](https://github.com/crazyoptimist).
|
8
|
+
* [#167](https://github.com/slack-ruby/slack-ruby-bot-server/pull/167): Added `once_and_every` timer - [@dblock](https://github.com/dblock).
|
9
|
+
* [#168](https://github.com/slack-ruby/slack-ruby-bot-server/pull/168): Added support for Ruby 3.2.1 - [@dblock](https://github.com/dblock).
|
10
|
+
|
11
|
+
#### 2.0.1 (2023/02/20)
|
12
|
+
|
13
|
+
* [#145](https://github.com/slack-ruby/slack-ruby-bot-server/pull/145): Added support for Ruby 3.1 - [@dblock](https://github.com/dblock).
|
14
|
+
* [#146](https://github.com/slack-ruby/slack-ruby-bot-server/pull/146): Added support for MongoDB 5.0 - [@dblock](https://github.com/dblock).
|
15
|
+
* [#147](https://github.com/slack-ruby/slack-ruby-bot-server/pull/147): Added support for PostgreSQL 14 - [@dblock](https://github.com/dblock).
|
16
|
+
* [#155](https://github.com/slack-ruby/slack-ruby-bot-server/pull/155): Enable mongoid to get connection URI from ENV for test - [@crazyoptimist](https://github.com/crazyoptimist).
|
17
|
+
* [#157](https://github.com/slack-ruby/slack-ruby-bot-server/pull/157): Added test env setup guide for linux users - [@crazyoptimist](https://github.com/crazyoptimist).
|
18
|
+
* [#158](https://github.com/slack-ruby/slack-ruby-bot-server/pull/158): Replace `cursor_pagination` with `pagy_cursor` - [@crazyoptimist](https://github.com/crazyoptimist).
|
19
|
+
* [#160](https://github.com/slack-ruby/slack-ruby-bot-server/pull/160): Document upgrading to 2.0.0 - [@crazyoptimist](https://github.com/crazyoptimist).
|
20
|
+
* [#161](https://github.com/slack-ruby/slack-ruby-bot-server/pull/161): Removed unused `ext` module - [@dblock](https://github.com/dblock).
|
21
|
+
* [#162](https://github.com/slack-ruby/slack-ruby-bot-server/pull/162): Fix: scopes are comma-separated - [@dblock](https://github.com/dblock).
|
22
|
+
|
3
23
|
#### 1.2.1 (2022/03/06)
|
4
24
|
|
5
25
|
* [#140](https://github.com/slack-ruby/slack-ruby-bot-server/pull/140): Fix: `NameError` for `Boolean` types with mongoid >= 7.3.0 - [@dblock](https://github.com/dblock).
|
data/CONTRIBUTING.md
CHANGED
@@ -35,6 +35,13 @@ bundle install
|
|
35
35
|
bundle exec rake
|
36
36
|
```
|
37
37
|
|
38
|
+
If you are a linux user, you will need to install [geckodriver](https://github.com/mozilla/geckodriver/releases), [firefox](https://download-installer.cdn.mozilla.net/pub/firefox/releases/), and `Xvfb`.
|
39
|
+
And, to get a display for the headless browser, run `Xvfb` manually. You can see more explanations [here](http://elementalselenium.com/tips/38-headless).
|
40
|
+
|
41
|
+
```
|
42
|
+
xvfb-run --auto-servernum bundle exec rake
|
43
|
+
```
|
44
|
+
|
38
45
|
## Write Tests
|
39
46
|
|
40
47
|
Try to write a test that reproduces the problem you're trying to fix or describes a feature that you want to build.
|
data/Gemfile
CHANGED
@@ -7,9 +7,9 @@ when 'mongoid' then
|
|
7
7
|
gem 'mongoid-scroll'
|
8
8
|
gem 'mongoid-shell'
|
9
9
|
when 'activerecord' then
|
10
|
-
gem 'activerecord', '~>
|
11
|
-
gem 'otr-activerecord'
|
12
|
-
gem '
|
10
|
+
gem 'activerecord', ENV['ACTIVERECORD_VERSION'] || '~> 6.0.0'
|
11
|
+
gem 'otr-activerecord'
|
12
|
+
gem 'pagy_cursor'
|
13
13
|
gem 'pg'
|
14
14
|
when nil
|
15
15
|
warn "Missing ENV['DATABASE_ADAPTER']."
|
@@ -22,18 +22,19 @@ gemspec
|
|
22
22
|
group :development, :test do
|
23
23
|
gem 'bundler'
|
24
24
|
gem 'byebug'
|
25
|
-
gem 'capybara', '~>
|
25
|
+
gem 'capybara', '~> 3.36.0'
|
26
26
|
gem 'database_cleaner', '~> 1.8.5'
|
27
27
|
gem 'fabrication'
|
28
28
|
gem 'faker'
|
29
29
|
gem 'faraday', '0.17.5'
|
30
30
|
gem 'hyperclient', '~> 0.9.3'
|
31
|
+
gem 'rack', '~> 2.2.3'
|
31
32
|
gem 'rack-server-pages'
|
32
33
|
gem 'rack-test'
|
33
34
|
gem 'rake'
|
34
35
|
gem 'rspec'
|
35
|
-
gem 'rubocop', '
|
36
|
-
gem 'selenium-webdriver', '~>
|
36
|
+
gem 'rubocop', '1.47'
|
37
|
+
gem 'selenium-webdriver', '~> 4.1.0'
|
37
38
|
gem 'vcr'
|
38
39
|
gem 'webmock'
|
39
40
|
gem 'webrick', '~> 1.6.1'
|
data/README.md
CHANGED
@@ -40,7 +40,7 @@ A library that contains a web server and a RESTful [Grape](http://github.com/rub
|
|
40
40
|
|
41
41
|
## Stable Release
|
42
42
|
|
43
|
-
You're reading the documentation for the **stable** release of slack-ruby-bot-server. See [UPGRADING](UPGRADING.md) when upgrading from an older version.
|
43
|
+
You're reading the documentation for the **stable** release of slack-ruby-bot-server, 2.1.0. See [UPGRADING](UPGRADING.md) when upgrading from an older version.
|
44
44
|
|
45
45
|
## Make Your Own
|
46
46
|
|
@@ -65,14 +65,15 @@ gem 'slack-ruby-bot-server'
|
|
65
65
|
|
66
66
|
#### ActiveRecord
|
67
67
|
|
68
|
-
Use ActiveRecord with, for example, PostgreSQL via [pg](https://github.com/ged/ruby-pg). Add the `activerecord`, `pg`, `otr-activerecord` and `
|
68
|
+
Use ActiveRecord with, for example, PostgreSQL via [pg](https://github.com/ged/ruby-pg). Add the `activerecord`, `pg`, `otr-activerecord` and `pagy_cursor` gems to your Gemfile.
|
69
|
+
Currently supports ActiveRecord/Rails major versions 6.0, 6.1 and 7.0.
|
69
70
|
|
70
71
|
```
|
71
72
|
gem 'pg'
|
72
73
|
gem 'activerecord', require: 'active_record'
|
73
74
|
gem 'slack-ruby-bot-server'
|
74
75
|
gem 'otr-activerecord'
|
75
|
-
gem '
|
76
|
+
gem 'pagy_cursor'
|
76
77
|
```
|
77
78
|
|
78
79
|
Configure the database connection in `config/postgresql.yml`.
|
@@ -237,9 +238,7 @@ end
|
|
237
238
|
|
238
239
|
##### Service Timers
|
239
240
|
|
240
|
-
You can introduce custom behavior into the service lifecycle on a timer. For example, check whether a team's trial has expired, or periodically
|
241
|
-
|
242
|
-
Note that unlike callbacks, timers are global for the entire service.
|
241
|
+
You can introduce custom behavior into the service lifecycle on a timer. For example, check whether a team's trial has expired, or periodically clean-up data. Timers can run once on start (`once_and_every`) and start running after a certain period (`every`).
|
243
242
|
|
244
243
|
```ruby
|
245
244
|
instance = SlackRubyBotServer::Service.instance
|
@@ -253,6 +252,10 @@ instance.every :hour do
|
|
253
252
|
end
|
254
253
|
end
|
255
254
|
|
255
|
+
instance.once_and_every :minute do
|
256
|
+
# called once on start, then every minute
|
257
|
+
end
|
258
|
+
|
256
259
|
instance.every :minute do
|
257
260
|
# called every minute
|
258
261
|
end
|
@@ -266,6 +269,8 @@ instance.every 30 do
|
|
266
269
|
end
|
267
270
|
```
|
268
271
|
|
272
|
+
Note that, unlike callbacks, timers are global for the entire service. Timers are independent, and a failing timer will not terminate other timers.
|
273
|
+
|
269
274
|
##### Extensions
|
270
275
|
|
271
276
|
A number of extensions use service manager callbacks and service timers to implement useful functionality.
|
data/RELEASING.md
CHANGED
@@ -11,12 +11,12 @@ bundle install
|
|
11
11
|
rake
|
12
12
|
```
|
13
13
|
|
14
|
-
Check that the last build succeeded in [
|
14
|
+
Check that the last build succeeded in [Github Actions](https://github.com/slack-ruby/slack-ruby-bot-server/actions) for all supported platforms.
|
15
15
|
|
16
16
|
Change "Next" in [CHANGELOG.md](CHANGELOG.md) to the current date.
|
17
17
|
|
18
18
|
```
|
19
|
-
### 0.
|
19
|
+
### 2.0.1 (2023/02/20)
|
20
20
|
```
|
21
21
|
|
22
22
|
Remove the line with "Your contribution here.", since there will be no more contributions to this release.
|
@@ -26,14 +26,14 @@ Change `**next**` in the "Stable Release" section in README that warns users tha
|
|
26
26
|
```
|
27
27
|
## Stable Release
|
28
28
|
|
29
|
-
You're reading the documentation for the **stable** release of slack-ruby-bot-server, 0.
|
29
|
+
You're reading the documentation for the **stable** release of slack-ruby-bot-server, 2.0.1. See [UPGRADING](UPGRADING.md) when upgrading from an older version.
|
30
30
|
```
|
31
31
|
|
32
32
|
Commit your changes.
|
33
33
|
|
34
34
|
```
|
35
35
|
git add README.md CHANGELOG.md
|
36
|
-
git commit -m "Preparing for release, 0.
|
36
|
+
git commit -m "Preparing for release, 2.0.1."
|
37
37
|
git push origin master
|
38
38
|
```
|
39
39
|
|
@@ -42,10 +42,10 @@ Release.
|
|
42
42
|
```
|
43
43
|
$ rake release
|
44
44
|
|
45
|
-
slack-ruby-bot-server 0.
|
46
|
-
Tagged
|
45
|
+
slack-ruby-bot-server 2.0.1 built to pkg/slack-ruby-bot-server-2.0.1.gem.
|
46
|
+
Tagged v2.0.1.
|
47
47
|
Pushed git commits and tags.
|
48
|
-
Pushed slack-ruby-bot-server 0.
|
48
|
+
Pushed slack-ruby-bot-server 2.0.1 to rubygems.org.
|
49
49
|
```
|
50
50
|
|
51
51
|
### Prepare for the Next Version
|
@@ -53,7 +53,7 @@ Pushed slack-ruby-bot-server 0.2.2 to rubygems.org.
|
|
53
53
|
Add the next release to [CHANGELOG.md](CHANGELOG.md).
|
54
54
|
|
55
55
|
```
|
56
|
-
### 0.2
|
56
|
+
### 2.0.2 (Next)
|
57
57
|
|
58
58
|
* Your contribution here.
|
59
59
|
```
|
@@ -65,13 +65,13 @@ Undo your change in README about the stable release.
|
|
65
65
|
```
|
66
66
|
## Stable Release
|
67
67
|
|
68
|
-
You're reading the documentation for the **next** release of slack-ruby-bot-server. Please see the documentation for the [last stable release,
|
68
|
+
You're reading the documentation for the **next** release of slack-ruby-bot-server. Please see the documentation for the [last stable release, v2.0.1](https://github.com/slack-ruby/slack-ruby-bot-server/blob/v2.0.1/README.md) unless you're integrating with HEAD. See [UPGRADING](UPGRADING.md) when upgrading from an older version. See [MIGRATING](MIGRATING.md) for help with migrating Legacy Slack Apps to Granular Scopes.
|
69
69
|
```
|
70
70
|
|
71
71
|
Commit your changes.
|
72
72
|
|
73
73
|
```
|
74
74
|
git add README.md CHANGELOG.md lib/slack-ruby-bot-server/version.rb
|
75
|
-
git commit -m "Preparing for next development iteration, 0.2.
|
75
|
+
git commit -m "Preparing for next development iteration, 2.0.2."
|
76
76
|
git push origin master
|
77
77
|
```
|
data/UPGRADING.md
CHANGED
@@ -1,6 +1,18 @@
|
|
1
1
|
Upgrading Slack-Ruby-Bot-Server
|
2
2
|
===============================
|
3
3
|
|
4
|
+
### Upgrading to >= 2.0.0
|
5
|
+
|
6
|
+
#### Replaced Pagination Gem for ActiveRecord
|
7
|
+
|
8
|
+
[`cursor_pagination`](https://github.com/Kukunin/cursor_pagination) is abandoned and no longer maintained. It is replaced with [`pagy_cursor`](https://github.com/Uysim/pagy-cursor).
|
9
|
+
|
10
|
+
If you're using ActiveRecord, replace `cursor_pagination` with `pagy_cursor` in the Gemfile.
|
11
|
+
|
12
|
+
```ruby
|
13
|
+
gem 'pagy_cursor'
|
14
|
+
```
|
15
|
+
|
4
16
|
### Upgrading to >= 1.2.0
|
5
17
|
|
6
18
|
#### New Team Fields
|
@@ -25,6 +25,8 @@ module SlackRubyBotServer
|
|
25
25
|
results
|
26
26
|
end
|
27
27
|
elsif SlackRubyBotServer::Config.activerecord?
|
28
|
+
include Pagy::Cursor::Backend
|
29
|
+
|
28
30
|
def paginate_by_cursor(coll, options)
|
29
31
|
raise 'Both cursor and offset parameters are present, these are mutually exclusive.' if params.key?(:offset) && params.key?(:cursor)
|
30
32
|
|
@@ -33,12 +35,16 @@ module SlackRubyBotServer
|
|
33
35
|
results[:total_count] = coll.count(:all) if params[:total_count]
|
34
36
|
coll = coll.offset(params[:offset].to_i) if params.key?(:offset)
|
35
37
|
sort_options = {}
|
38
|
+
cursor_direction = :after
|
36
39
|
sort_order(options).each do |order|
|
37
40
|
sort_options[order[:column]] = { reverse: true } if order[:direction] == :desc
|
41
|
+
cursor_direction = :before if order[:column] == coll.primary_key && order[:direction] == :desc
|
38
42
|
end
|
39
|
-
|
43
|
+
cursor_vars = { items: size }
|
44
|
+
cursor_vars[cursor_direction] = params[:cursor].to_i if params.key?(:cursor)
|
45
|
+
pagy_cursor, coll = pagy_cursor(coll, cursor_vars, { order: sort_options })
|
40
46
|
results[:results] = coll.to_a
|
41
|
-
results[:next] = coll.
|
47
|
+
results[:next] = coll.last[:id].to_s if pagy_cursor.has_more?
|
42
48
|
results
|
43
49
|
end
|
44
50
|
end
|
@@ -0,0 +1,236 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Pagy initializer file (6.0.0)
|
4
|
+
# Customize only what you really need and notice that the core Pagy works also without any of the following lines.
|
5
|
+
# Should you just cherry pick part of this file, please maintain the require-order of the extras
|
6
|
+
|
7
|
+
# Pagy DEFAULT Variables
|
8
|
+
# See https://ddnexus.github.io/pagy/docs/api/pagy#variables
|
9
|
+
# All the Pagy::DEFAULT are set for all the Pagy instances but can be overridden per instance by just passing them to
|
10
|
+
# Pagy.new|Pagy::Countless.new|Pagy::Calendar::*.new or any of the #pagy* controller methods
|
11
|
+
|
12
|
+
# Instance variables
|
13
|
+
# See https://ddnexus.github.io/pagy/docs/api/pagy#instance-variables
|
14
|
+
# Pagy::DEFAULT[:page] = 1 # default
|
15
|
+
# Pagy::DEFAULT[:items] = 20 # default
|
16
|
+
# Pagy::DEFAULT[:outset] = 0 # default
|
17
|
+
|
18
|
+
# Other Variables
|
19
|
+
# See https://ddnexus.github.io/pagy/docs/api/pagy#other-variables
|
20
|
+
# Pagy::DEFAULT[:size] = [1,4,4,1] # default
|
21
|
+
# Pagy::DEFAULT[:page_param] = :page # default
|
22
|
+
# The :params can be also set as a lambda e.g ->(params){ params.exclude('useless').merge!('custom' => 'useful') }
|
23
|
+
# Pagy::DEFAULT[:params] = {} # default
|
24
|
+
# Pagy::DEFAULT[:fragment] = '#fragment' # example
|
25
|
+
# Pagy::DEFAULT[:link_extra] = 'data-remote="true"' # example
|
26
|
+
# Pagy::DEFAULT[:i18n_key] = 'pagy.item_name' # default
|
27
|
+
# Pagy::DEFAULT[:cycle] = true # example
|
28
|
+
# Pagy::DEFAULT[:request_path] = "/foo" # example
|
29
|
+
|
30
|
+
# Extras
|
31
|
+
# See https://ddnexus.github.io/pagy/docs/extras
|
32
|
+
|
33
|
+
# Backend Extras
|
34
|
+
|
35
|
+
# Array extra: Paginate arrays efficiently, avoiding expensive array-wrapping and without overriding
|
36
|
+
# See https://ddnexus.github.io/pagy/docs/extras/array
|
37
|
+
# require 'pagy/extras/array'
|
38
|
+
|
39
|
+
# Calendar extra: Add pagination filtering by calendar time unit (year, quarter, month, week, day)
|
40
|
+
# See https://ddnexus.github.io/pagy/docs/extras/calendar
|
41
|
+
# require 'pagy/extras/calendar'
|
42
|
+
# Default for each unit
|
43
|
+
# Pagy::Calendar::Year::DEFAULT[:order] = :asc # Time direction of pagination
|
44
|
+
# Pagy::Calendar::Year::DEFAULT[:format] = '%Y' # strftime format
|
45
|
+
#
|
46
|
+
# Pagy::Calendar::Quarter::DEFAULT[:order] = :asc # Time direction of pagination
|
47
|
+
# Pagy::Calendar::Quarter::DEFAULT[:format] = '%Y-Q%q' # strftime format
|
48
|
+
#
|
49
|
+
# Pagy::Calendar::Month::DEFAULT[:order] = :asc # Time direction of pagination
|
50
|
+
# Pagy::Calendar::Month::DEFAULT[:format] = '%Y-%m' # strftime format
|
51
|
+
#
|
52
|
+
# Pagy::Calendar::Week::DEFAULT[:order] = :asc # Time direction of pagination
|
53
|
+
# Pagy::Calendar::Week::DEFAULT[:format] = '%Y-%W' # strftime format
|
54
|
+
#
|
55
|
+
# Pagy::Calendar::Day::DEFAULT[:order] = :asc # Time direction of pagination
|
56
|
+
# Pagy::Calendar::Day::DEFAULT[:format] = '%Y-%m-%d' # strftime format
|
57
|
+
#
|
58
|
+
# Uncomment the following lines, if you need calendar localization without using the I18n extra
|
59
|
+
# module LocalizePagyCalendar
|
60
|
+
# def localize(time, opts)
|
61
|
+
# ::I18n.l(time, **opts)
|
62
|
+
# end
|
63
|
+
# end
|
64
|
+
# Pagy::Calendar.prepend LocalizePagyCalendar
|
65
|
+
|
66
|
+
# Countless extra: Paginate without any count, saving one query per rendering
|
67
|
+
# See https://ddnexus.github.io/pagy/docs/extras/countless
|
68
|
+
# require 'pagy/extras/countless'
|
69
|
+
# Pagy::DEFAULT[:countless_minimal] = false # default (eager loading)
|
70
|
+
|
71
|
+
# Elasticsearch Rails extra: Paginate `ElasticsearchRails::Results` objects
|
72
|
+
# See https://ddnexus.github.io/pagy/docs/extras/elasticsearch_rails
|
73
|
+
# Default :pagy_search method: change only if you use also
|
74
|
+
# the searchkick or meilisearch extra that defines the same
|
75
|
+
# Pagy::DEFAULT[:elasticsearch_rails_pagy_search] = :pagy_search
|
76
|
+
# Default original :search method called internally to do the actual search
|
77
|
+
# Pagy::DEFAULT[:elasticsearch_rails_search] = :search
|
78
|
+
# require 'pagy/extras/elasticsearch_rails'
|
79
|
+
|
80
|
+
# Headers extra: http response headers (and other helpers) useful for API pagination
|
81
|
+
# See http://ddnexus.github.io/pagy/extras/headers
|
82
|
+
# require 'pagy/extras/headers'
|
83
|
+
# Pagy::DEFAULT[:headers] = { page: 'Current-Page',
|
84
|
+
# items: 'Page-Items',
|
85
|
+
# count: 'Total-Count',
|
86
|
+
# pages: 'Total-Pages' } # default
|
87
|
+
|
88
|
+
# Meilisearch extra: Paginate `Meilisearch` result objects
|
89
|
+
# See https://ddnexus.github.io/pagy/docs/extras/meilisearch
|
90
|
+
# Default :pagy_search method: change only if you use also
|
91
|
+
# the elasticsearch_rails or searchkick extra that define the same method
|
92
|
+
# Pagy::DEFAULT[:meilisearch_pagy_search] = :pagy_search
|
93
|
+
# Default original :search method called internally to do the actual search
|
94
|
+
# Pagy::DEFAULT[:meilisearch_search] = :ms_search
|
95
|
+
# require 'pagy/extras/meilisearch'
|
96
|
+
|
97
|
+
# Metadata extra: Provides the pagination metadata to Javascript frameworks like Vue.js, react.js, etc.
|
98
|
+
# See https://ddnexus.github.io/pagy/docs/extras/metadata
|
99
|
+
# you must require the frontend helpers internal extra (BEFORE the metadata extra) ONLY if you need also the :sequels
|
100
|
+
# require 'pagy/extras/frontend_helpers'
|
101
|
+
# require 'pagy/extras/metadata'
|
102
|
+
# For performance reasons, you should explicitly set ONLY the metadata you use in the frontend
|
103
|
+
# Pagy::DEFAULT[:metadata] = %i[scaffold_url page prev next last] # example
|
104
|
+
|
105
|
+
# Searchkick extra: Paginate `Searchkick::Results` objects
|
106
|
+
# See https://ddnexus.github.io/pagy/docs/extras/searchkick
|
107
|
+
# Default :pagy_search method: change only if you use also
|
108
|
+
# the elasticsearch_rails or meilisearch extra that defines the same
|
109
|
+
# DEFAULT[:searchkick_pagy_search] = :pagy_search
|
110
|
+
# Default original :search method called internally to do the actual search
|
111
|
+
# Pagy::DEFAULT[:searchkick_search] = :search
|
112
|
+
# require 'pagy/extras/searchkick'
|
113
|
+
# uncomment if you are going to use Searchkick.pagy_search
|
114
|
+
# Searchkick.extend Pagy::Searchkick
|
115
|
+
|
116
|
+
# Frontend Extras
|
117
|
+
|
118
|
+
# Bootstrap extra: Add nav, nav_js and combo_nav_js helpers and templates for Bootstrap pagination
|
119
|
+
# See https://ddnexus.github.io/pagy/docs/extras/bootstrap
|
120
|
+
# require 'pagy/extras/bootstrap'
|
121
|
+
|
122
|
+
# Bulma extra: Add nav, nav_js and combo_nav_js helpers and templates for Bulma pagination
|
123
|
+
# See https://ddnexus.github.io/pagy/docs/extras/bulma
|
124
|
+
# require 'pagy/extras/bulma'
|
125
|
+
|
126
|
+
# Foundation extra: Add nav, nav_js and combo_nav_js helpers and templates for Foundation pagination
|
127
|
+
# See https://ddnexus.github.io/pagy/docs/extras/foundation
|
128
|
+
# require 'pagy/extras/foundation'
|
129
|
+
|
130
|
+
# Materialize extra: Add nav, nav_js and combo_nav_js helpers for Materialize pagination
|
131
|
+
# See https://ddnexus.github.io/pagy/docs/extras/materialize
|
132
|
+
# require 'pagy/extras/materialize'
|
133
|
+
|
134
|
+
# Navs extra: Add nav_js and combo_nav_js javascript helpers
|
135
|
+
# Notice: the other frontend extras add their own framework-styled versions,
|
136
|
+
# so require this extra only if you need the unstyled version
|
137
|
+
# See https://ddnexus.github.io/pagy/docs/extras/navs
|
138
|
+
# require 'pagy/extras/navs'
|
139
|
+
|
140
|
+
# Semantic extra: Add nav, nav_js and combo_nav_js helpers for Semantic UI pagination
|
141
|
+
# See https://ddnexus.github.io/pagy/docs/extras/semantic
|
142
|
+
# require 'pagy/extras/semantic'
|
143
|
+
|
144
|
+
# UIkit extra: Add nav helper and templates for UIkit pagination
|
145
|
+
# See https://ddnexus.github.io/pagy/docs/extras/uikit
|
146
|
+
# require 'pagy/extras/uikit'
|
147
|
+
|
148
|
+
# Multi size var used by the *_nav_js helpers
|
149
|
+
# See https://ddnexus.github.io/pagy/docs/extras/navs#steps
|
150
|
+
# Pagy::DEFAULT[:steps] = { 0 => [2,3,3,2], 540 => [3,5,5,3], 720 => [5,7,7,5] } # example
|
151
|
+
|
152
|
+
# Feature Extras
|
153
|
+
|
154
|
+
# Gearbox extra: Automatically change the number of items per page depending on the page number
|
155
|
+
# See https://ddnexus.github.io/pagy/docs/extras/gearbox
|
156
|
+
# require 'pagy/extras/gearbox'
|
157
|
+
# set to false only if you want to make :gearbox_extra an opt-in variable
|
158
|
+
# Pagy::DEFAULT[:gearbox_extra] = false # default true
|
159
|
+
# Pagy::DEFAULT[:gearbox_items] = [15, 30, 60, 100] # default
|
160
|
+
|
161
|
+
# Items extra: Allow the client to request a custom number of items per page with an optional selector UI
|
162
|
+
# See https://ddnexus.github.io/pagy/docs/extras/items
|
163
|
+
# require 'pagy/extras/items'
|
164
|
+
# set to false only if you want to make :items_extra an opt-in variable
|
165
|
+
# Pagy::DEFAULT[:items_extra] = false # default true
|
166
|
+
# Pagy::DEFAULT[:items_param] = :items # default
|
167
|
+
# Pagy::DEFAULT[:max_items] = 100 # default
|
168
|
+
|
169
|
+
# Overflow extra: Allow for easy handling of overflowing pages
|
170
|
+
# See https://ddnexus.github.io/pagy/docs/extras/overflow
|
171
|
+
# require 'pagy/extras/overflow'
|
172
|
+
# Pagy::DEFAULT[:overflow] = :empty_page # default (other options: :last_page and :exception)
|
173
|
+
|
174
|
+
# Support extra: Extra support for features like: incremental, infinite, auto-scroll pagination
|
175
|
+
# See https://ddnexus.github.io/pagy/docs/extras/support
|
176
|
+
# require 'pagy/extras/support'
|
177
|
+
|
178
|
+
# Trim extra: Remove the page=1 param from links
|
179
|
+
# See https://ddnexus.github.io/pagy/docs/extras/trim
|
180
|
+
# require 'pagy/extras/trim'
|
181
|
+
# set to false only if you want to make :trim_extra an opt-in variable
|
182
|
+
# Pagy::DEFAULT[:trim_extra] = false # default true
|
183
|
+
|
184
|
+
# Standalone extra: Use pagy in non Rack environment/gem
|
185
|
+
# See https://ddnexus.github.io/pagy/docs/extras/standalone
|
186
|
+
# require 'pagy/extras/standalone'
|
187
|
+
# Pagy::DEFAULT[:url] = 'http://www.example.com/subdir' # optional default
|
188
|
+
|
189
|
+
# Rails
|
190
|
+
# Enable the .js file required by the helpers that use javascript
|
191
|
+
# (pagy*_nav_js, pagy*_combo_nav_js, and pagy_items_selector_js)
|
192
|
+
# See https://ddnexus.github.io/pagy/docs/extras#javascript
|
193
|
+
|
194
|
+
# With the asset pipeline
|
195
|
+
# Sprockets need to look into the pagy javascripts dir, so add it to the assets paths
|
196
|
+
# Rails.application.config.assets.paths << Pagy.root.join('javascripts')
|
197
|
+
|
198
|
+
# I18n
|
199
|
+
|
200
|
+
# Pagy internal I18n: ~18x faster using ~10x less memory than the i18n gem
|
201
|
+
# See https://ddnexus.github.io/pagy/docs/api/frontend#i18n
|
202
|
+
# Notice: No need to configure anything in this section if your app uses only "en"
|
203
|
+
# or if you use the i18n extra below
|
204
|
+
#
|
205
|
+
# Examples:
|
206
|
+
# load the "de" built-in locale:
|
207
|
+
# Pagy::I18n.load(locale: 'de')
|
208
|
+
#
|
209
|
+
# load the "de" locale defined in the custom file at :filepath:
|
210
|
+
# Pagy::I18n.load(locale: 'de', filepath: 'path/to/pagy-de.yml')
|
211
|
+
#
|
212
|
+
# load the "de", "en" and "es" built-in locales:
|
213
|
+
# (the first passed :locale will be used also as the default_locale)
|
214
|
+
# Pagy::I18n.load({ locale: 'de' },
|
215
|
+
# { locale: 'en' },
|
216
|
+
# { locale: 'es' })
|
217
|
+
#
|
218
|
+
# load the "en" built-in locale, a custom "es" locale,
|
219
|
+
# and a totally custom locale complete with a custom :pluralize proc:
|
220
|
+
# (the first passed :locale will be used also as the default_locale)
|
221
|
+
# Pagy::I18n.load({ locale: 'en' },
|
222
|
+
# { locale: 'es', filepath: 'path/to/pagy-es.yml' },
|
223
|
+
# { locale: 'xyz', # not built-in
|
224
|
+
# filepath: 'path/to/pagy-xyz.yml',
|
225
|
+
# pluralize: lambda{ |count| ... } )
|
226
|
+
|
227
|
+
# I18n extra: uses the standard i18n gem which is ~18x slower using ~10x more memory
|
228
|
+
# than the default pagy internal i18n (see above)
|
229
|
+
# See https://ddnexus.github.io/pagy/docs/extras/i18n
|
230
|
+
# require 'pagy/extras/i18n'
|
231
|
+
|
232
|
+
# Default i18n key
|
233
|
+
# Pagy::DEFAULT[:i18n_key] = 'pagy.item_name' # default
|
234
|
+
|
235
|
+
# When you are done setting your own default freeze it, so it will not get changed accidentally
|
236
|
+
Pagy::DEFAULT.freeze
|
@@ -1,12 +1,14 @@
|
|
1
1
|
# see https://groups.google.com/forum/#!msg/mongoid/MaXFVw7D_4s/T3sl6Flg428J
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
2
|
+
if defined?(:BSON)
|
3
|
+
module BSON
|
4
|
+
class ObjectId
|
5
|
+
def as_json(_options = {})
|
6
|
+
to_s
|
7
|
+
end
|
7
8
|
|
8
|
-
|
9
|
-
|
9
|
+
def to_bson_key(encoded = ''.force_encoding(BINARY))
|
10
|
+
to_s.to_bson_key(encoded)
|
11
|
+
end
|
10
12
|
end
|
11
13
|
end
|
12
14
|
end
|
@@ -1,3 +1,2 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
end
|
1
|
+
require_relative 'ext/bson/object_id'
|
2
|
+
require_relative 'ext/grape/sort_extension'
|
@@ -13,11 +13,11 @@ module Methods
|
|
13
13
|
validates_presence_of :team_id
|
14
14
|
|
15
15
|
def deactivate!
|
16
|
-
|
16
|
+
update!(active: false)
|
17
17
|
end
|
18
18
|
|
19
19
|
def activate!(token)
|
20
|
-
|
20
|
+
update!(active: true, token: token)
|
21
21
|
end
|
22
22
|
|
23
23
|
def to_s
|
@@ -24,19 +24,15 @@ module SlackRubyBotServer
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
-
def
|
27
|
+
def once_and_every(*intervals, &block)
|
28
28
|
Array(intervals).each do |interval|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
when :hour
|
33
|
-
interval = 60 * 60
|
34
|
-
when :day
|
35
|
-
interval = 60 * 60 * 24
|
36
|
-
end
|
37
|
-
raise "Invalid interval \"#{interval}\"." unless interval.is_a?(Integer) && interval > 0
|
29
|
+
@intervals[_validate_interval(interval)] << [block, { run_on_start: true }]
|
30
|
+
end
|
31
|
+
end
|
38
32
|
|
39
|
-
|
33
|
+
def every(*intervals, &block)
|
34
|
+
Array(intervals).each do |interval|
|
35
|
+
@intervals[_validate_interval(interval)] << [block, {}]
|
40
36
|
end
|
41
37
|
end
|
42
38
|
|
@@ -83,9 +79,12 @@ module SlackRubyBotServer
|
|
83
79
|
end
|
84
80
|
|
85
81
|
def start_intervals!
|
86
|
-
@intervals.each_pair do |period,
|
87
|
-
|
88
|
-
|
82
|
+
@intervals.each_pair do |period, calls_with_options|
|
83
|
+
calls_with_options.each do |call_with_options|
|
84
|
+
call, options = *call_with_options
|
85
|
+
_every period, options do
|
86
|
+
call.call
|
87
|
+
end
|
89
88
|
end
|
90
89
|
end
|
91
90
|
end
|
@@ -105,10 +104,28 @@ module SlackRubyBotServer
|
|
105
104
|
|
106
105
|
private
|
107
106
|
|
108
|
-
def
|
107
|
+
def _validate_interval(interval)
|
108
|
+
case interval
|
109
|
+
when :minute
|
110
|
+
interval = 60
|
111
|
+
when :hour
|
112
|
+
interval = 60 * 60
|
113
|
+
when :day
|
114
|
+
interval = 60 * 60 * 24
|
115
|
+
end
|
116
|
+
raise "Invalid interval \"#{interval}\"." unless interval.is_a?(Integer) && interval > 0
|
117
|
+
|
118
|
+
interval
|
119
|
+
end
|
120
|
+
|
121
|
+
def _every(tt, options = {}, &_block)
|
109
122
|
::Async::Reactor.run do |task|
|
110
123
|
loop do
|
111
124
|
begin
|
125
|
+
if options[:run_on_start]
|
126
|
+
options = {}
|
127
|
+
yield
|
128
|
+
end
|
112
129
|
task.sleep tt
|
113
130
|
yield
|
114
131
|
rescue StandardError => e
|
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:
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Doubrovkine
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-03-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: async
|
@@ -150,7 +150,7 @@ dependencies:
|
|
150
150
|
- - ">="
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: '0'
|
153
|
-
description:
|
153
|
+
description:
|
154
154
|
email:
|
155
155
|
- dblock@dblock.org
|
156
156
|
executables: []
|
@@ -202,10 +202,10 @@ files:
|
|
202
202
|
- lib/slack-ruby-bot-server/config.rb
|
203
203
|
- lib/slack-ruby-bot-server/config/database_adapters/activerecord.rb
|
204
204
|
- lib/slack-ruby-bot-server/config/database_adapters/mongoid.rb
|
205
|
+
- lib/slack-ruby-bot-server/config/pagy.rb
|
205
206
|
- lib/slack-ruby-bot-server/ext.rb
|
206
207
|
- lib/slack-ruby-bot-server/ext/bson/object_id.rb
|
207
208
|
- lib/slack-ruby-bot-server/ext/grape/sort_extension.rb
|
208
|
-
- lib/slack-ruby-bot-server/ext/mongoid/slack-ruby-bot/commands/base.rb
|
209
209
|
- lib/slack-ruby-bot-server/info.rb
|
210
210
|
- lib/slack-ruby-bot-server/loggable.rb
|
211
211
|
- lib/slack-ruby-bot-server/models/team/activerecord.rb
|
@@ -230,7 +230,7 @@ files:
|
|
230
230
|
homepage: https://github.com/slack-ruby/slack-ruby-bot-server
|
231
231
|
licenses: []
|
232
232
|
metadata: {}
|
233
|
-
post_install_message:
|
233
|
+
post_install_message:
|
234
234
|
rdoc_options: []
|
235
235
|
require_paths:
|
236
236
|
- lib
|
@@ -245,8 +245,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
245
245
|
- !ruby/object:Gem::Version
|
246
246
|
version: '0'
|
247
247
|
requirements: []
|
248
|
-
rubygems_version: 3.1.
|
249
|
-
signing_key:
|
248
|
+
rubygems_version: 3.1.6
|
249
|
+
signing_key:
|
250
250
|
specification_version: 4
|
251
251
|
summary: A Grape API serving a Slack bot to multiple teams.
|
252
252
|
test_files: []
|
@@ -1,22 +0,0 @@
|
|
1
|
-
module SlackRubyBot
|
2
|
-
module Commands
|
3
|
-
class Base
|
4
|
-
class << self
|
5
|
-
alias _invoke invoke
|
6
|
-
|
7
|
-
def invoke(client, data)
|
8
|
-
_invoke client, data
|
9
|
-
rescue Mongoid::Errors::Validations => e
|
10
|
-
logger.info "#{name.demodulize.upcase}: #{client.owner}, error - #{e.document.class}, #{e.document.errors.to_hash}"
|
11
|
-
client.say(channel: data.channel, text: e.document.errors.first[1])
|
12
|
-
true
|
13
|
-
rescue StandardError => e
|
14
|
-
logger.info "#{name.demodulize.upcase}: #{client.owner}, #{e.class}: #{e}"
|
15
|
-
logger.debug e.backtrace.join("\n")
|
16
|
-
client.say(channel: data.channel, text: e.message)
|
17
|
-
true
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|