slack-ruby-bot-server 2.0.1 → 2.1.0

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
  SHA256:
3
- metadata.gz: 6481784d4c29658a885d478d88734ff06e79ee6f9a30ec895e4c5872fecbd50b
4
- data.tar.gz: 28d14d45d3f338d9a002a8e7ab697cc3dd4c70e9103b8b68fd86382b7a7ac20b
3
+ metadata.gz: c2763c471bf4339d40cc6d190d695a0afdf82ae671d33580638fc52d857c4428
4
+ data.tar.gz: fd852824309f190ce382ed605e14e80e60215c5b1daf70969d30d9d78d100a09
5
5
  SHA512:
6
- metadata.gz: 71d5b984953b8137f3636f501d38fcac2023ebc4b9633a90b4d5dbd30ddec03a2ecfd661eb2c647c01e80e6f847eccd76e8f7b9d69918d3839573032628d633e
7
- data.tar.gz: b021b45e89ae3f85932e8fde979bf082a47d05fe527d27017edb4ea76717517fcb21c13a87c757fb988188d6435a4039d6433bbe5edc07bcc50e0cfc5acfe18e
6
+ metadata.gz: e6bd7d7fee1bb591d6991370292fe56304dfa92a580ea566e6077ddbdbd761c7aa748dbf32a5e4019425e9f66dd24c940833257eccd35a39c0b08968161d2267
7
+ data.tar.gz: d4255577b57693820a47cbffe0fac3bc659c63edb5c5a49023de6e2e757f056ef506a4c4a9e78bc2e6fa1803c19636cf7b69de9b595bfce46346a6a3d7de7014
@@ -1,16 +1,16 @@
1
1
  ---
2
- name: test
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@v2
9
+ - uses: actions/checkout@v3
10
10
  - name: Set up Ruby
11
11
  uses: ruby/setup-ruby@v1
12
12
  with:
13
- ruby-version: 2.7
13
+ ruby-version: '3.1'
14
14
  bundler-cache: true
15
15
  - name: Run RuboCop
16
16
  run: bundle exec rubocop
@@ -12,6 +12,7 @@ jobs:
12
12
  - { ruby: 2.6.2, mongoid: 7.3.0, mongodb: 4.4 }
13
13
  - { ruby: 3.1.1, mongoid: 7.3.0, mongodb: 4.4 }
14
14
  - { ruby: 3.1.1, mongoid: 7.3.0, mongodb: 5.0 }
15
+ - { ruby: 3.2.1, mongoid: 7.5.2, mongodb: 5.0 }
15
16
  name: test (ruby=${{ matrix.entry.ruby }}, mongoid=${{ matrix.entry.mongoid }}, mongodb=${{ matrix.entry.mongodb }})
16
17
  steps:
17
18
  - uses: actions/checkout@v2
@@ -7,10 +7,10 @@ jobs:
7
7
  strategy:
8
8
  matrix:
9
9
  entry:
10
- - { ruby: 2.6.2, postgresql: 11 }
11
- - { ruby: 3.1.1, postgresql: 11 }
12
- - { ruby: 3.1.1, postgresql: 14 }
13
- name: test (ruby=${{ matrix.entry.ruby }}, postgresql=${{ matrix.entry.postgresql }})
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 }})
14
14
  steps:
15
15
  - uses: actions/checkout@v2
16
16
  - uses: ruby/setup-ruby@v1
@@ -30,6 +30,7 @@ jobs:
30
30
  uses: GabrielBB/xvfb-action@v1
31
31
  env:
32
32
  DATABASE_ADAPTER: activerecord
33
+ ACTIVERECORD_VERSION: ${{ matrix.entry.active_record }}
33
34
  DATABASE_URL: postgres://test:password@localhost/slack_ruby_bot_server_test
34
35
  with:
35
36
  run: |
data/.rubocop.yml CHANGED
@@ -1,3 +1,7 @@
1
+ AllCops:
2
+ SuggestExtensions: false
3
+ TargetRubyVersion: 2.6
4
+
1
5
  Metrics:
2
6
  Enabled: false
3
7
 
@@ -12,4 +16,3 @@ Style/FrozenStringLiteralComment:
12
16
  Enabled: false
13
17
 
14
18
  inherit_from: .rubocop_todo.yml
15
-
data/.rubocop_todo.yml CHANGED
@@ -1,32 +1,46 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2020-11-16 09:56:54 -0500 using RuboCop version 0.81.0.
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
- # Cop supports --auto-correct.
11
- # Configuration parameters: EnforcedStyle.
12
- # SupportedStyles: squiggly, active_support, powerpack, unindent
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: 2
23
- # Cop supports --auto-correct.
24
- Lint/NonDeterministicRequireOrder:
34
+ # Offense count: 1
35
+ # Configuration parameters: AllowedMethods.
36
+ # AllowedMethods: enums
37
+ Lint/ConstantDefinitionInBlock:
25
38
  Exclude:
26
- - 'spec/spec_helper.rb'
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: (?-mix:(^|\s)(EO[A-Z]{1}|END)(\s|$))
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: io, id, to, by, on, in, at, ip, db, os, pp
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
- # Cop supports --auto-correct.
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
- # Cop supports --auto-correct.
61
- # Configuration parameters: AutoCorrect, EnforcedStyle, IgnoredMethods.
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,6 +1,14 @@
1
1
  ### Changelog
2
2
 
3
- #### 2.0.0 (2023/02/20)
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)
4
12
 
5
13
  * [#145](https://github.com/slack-ruby/slack-ruby-bot-server/pull/145): Added support for Ruby 3.1 - [@dblock](https://github.com/dblock).
6
14
  * [#146](https://github.com/slack-ruby/slack-ruby-bot-server/pull/146): Added support for MongoDB 5.0 - [@dblock](https://github.com/dblock).
data/Gemfile CHANGED
@@ -7,7 +7,7 @@ when 'mongoid' then
7
7
  gem 'mongoid-scroll'
8
8
  gem 'mongoid-shell'
9
9
  when 'activerecord' then
10
- gem 'activerecord', '~> 6.0.0'
10
+ gem 'activerecord', ENV['ACTIVERECORD_VERSION'] || '~> 6.0.0'
11
11
  gem 'otr-activerecord'
12
12
  gem 'pagy_cursor'
13
13
  gem 'pg'
@@ -33,7 +33,7 @@ group :development, :test do
33
33
  gem 'rack-test'
34
34
  gem 'rake'
35
35
  gem 'rspec'
36
- gem 'rubocop', '0.81.0'
36
+ gem 'rubocop', '1.47'
37
37
  gem 'selenium-webdriver', '~> 4.1.0'
38
38
  gem 'vcr'
39
39
  gem 'webmock'
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, 2.0.0. See [UPGRADING](UPGRADING.md) when upgrading from an older version. See [MIGRATING](MIGRATING.md) for help with migrating Legacy Slack Apps to Granular Scopes.
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
 
@@ -66,6 +66,7 @@ gem 'slack-ruby-bot-server'
66
66
  #### ActiveRecord
67
67
 
68
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'
@@ -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 cleanup data.
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 [Travis CI](https://travis-ci.org/slack-ruby/slack-ruby-bot-server) for all supported platforms.
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.2.2 (7/10/2015)
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.2.2. See [UPGRADING](UPGRADING.md) when upgrading from an older version.
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.2.2."
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.2.2 built to pkg/slack-ruby-bot-server-0.2.2.gem.
46
- Tagged v0.2.2.
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.2.2 to rubygems.org.
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.3 (Next)
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, v0.2.2](https://github.com/slack-ruby/slack-ruby-bot-server/blob/v0.2.2/README.md) unless you're integrating with HEAD. See [UPGRADING](UPGRADING.md) when upgrading from an older version.
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.3."
75
+ git commit -m "Preparing for next development iteration, 2.0.2."
76
76
  git push origin master
77
77
  ```
data/UPGRADING.md CHANGED
@@ -5,7 +5,7 @@ Upgrading Slack-Ruby-Bot-Server
5
5
 
6
6
  #### Replaced Pagination Gem for ActiveRecord
7
7
 
8
- [`cursor_pagination`](https://github.com/Kukunin/cursor_pagination) is abandoned and no longer maintained. It is repaced with [`pagy_cursor`](https://github.com/Uysim/pagy-cursor).
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
9
 
10
10
  If you're using ActiveRecord, replace `cursor_pagination` with `pagy_cursor` in the Gemfile.
11
11
 
@@ -84,7 +84,7 @@ module SlackRubyBotServer
84
84
  if team
85
85
  team.ping_if_active!
86
86
 
87
- team.update_attributes!(
87
+ team.update!(
88
88
  oauth_version: oauth_version,
89
89
  oauth_scope: oauth_scope,
90
90
  activated_user_id: user_id,
@@ -13,11 +13,11 @@ module Methods
13
13
  validates_presence_of :team_id
14
14
 
15
15
  def deactivate!
16
- update_attributes!(active: false)
16
+ update!(active: false)
17
17
  end
18
18
 
19
19
  def activate!(token)
20
- update_attributes!(active: true, token: token)
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 every(*intervals, &block)
27
+ def once_and_every(*intervals, &block)
28
28
  Array(intervals).each do |interval|
29
- case interval
30
- when :minute
31
- interval = 60
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
- @intervals[interval] << block
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, calls|
87
- _every period do
88
- calls.each(&:call)
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 _every(tt, &_block)
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
@@ -1,3 +1,3 @@
1
1
  module SlackRubyBotServer
2
- VERSION = '2.0.1'.freeze
2
+ VERSION = '2.1.0'.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: 2.0.1
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Doubrovkine
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-02-20 00:00:00.000000000 Z
11
+ date: 2023-03-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: async
@@ -245,7 +245,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
245
245
  - !ruby/object:Gem::Version
246
246
  version: '0'
247
247
  requirements: []
248
- rubygems_version: 3.3.26
248
+ rubygems_version: 3.1.6
249
249
  signing_key:
250
250
  specification_version: 4
251
251
  summary: A Grape API serving a Slack bot to multiple teams.