cent 2.2.0 → 4.0.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/CHANGELOG.md +5 -0
- data/Gemfile +7 -9
- data/README.md +165 -186
- data/cent.gemspec +14 -15
- data/lib/cent/client.rb +215 -228
- data/lib/cent/error.rb +41 -4
- data/lib/cent/notary.rb +68 -59
- data/lib/cent/version.rb +1 -1
- data/lib/cent.rb +1 -1
- metadata +24 -46
- data/.github/workflows/main.yml +0 -18
- data/.github/workflows/release.yml +0 -34
- data/.gitignore +0 -20
- data/.rspec +0 -3
- data/.rubocop.yml +0 -13
- data/lib/cent/http.rb +0 -47
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f449834c3edc1adb0db5f29e528a679b72068fcf0d68740afd236d7bc988452f
|
|
4
|
+
data.tar.gz: 671dc83face9f06c846a60de599b71fa73801a7b2626da5d22c96da1fa2a0b21
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a50ca9b8b2e0bdcecbc48a105d662f52c3085429bc6d20aa1d930e4ea8a399a0cc0d2ee1613f5fe4b8791b247d52bba4a4d6f7bc6a6afc7d735331720ce54233
|
|
7
|
+
data.tar.gz: 34d65c5a21618d19901352fa08c833e91746107cf00c79a874716f51acf964dfd0ebeab205cf07a09bb464830aff28a589736592eeed8211948887529637a2b6
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
|
@@ -5,13 +5,11 @@ source 'https://rubygems.org'
|
|
|
5
5
|
# Specify your gem's dependencies in cent.gemspec
|
|
6
6
|
gemspec
|
|
7
7
|
|
|
8
|
-
gem '
|
|
9
|
-
|
|
10
|
-
gem 'rspec', '~> 3.0'
|
|
11
|
-
gem 'webmock', '~> 3.7.5'
|
|
12
|
-
|
|
13
|
-
gem 'rubocop', '~> 1.7'
|
|
14
|
-
gem 'rubocop-rake'
|
|
15
|
-
gem 'rubocop-rspec'
|
|
16
|
-
|
|
8
|
+
gem 'appraisal', '~> 2.5'
|
|
17
9
|
gem 'pry'
|
|
10
|
+
gem 'rake', '~> 13.0'
|
|
11
|
+
gem 'rspec', '~> 3.12'
|
|
12
|
+
gem 'rubocop', '~> 1.60'
|
|
13
|
+
gem 'rubocop-rake', '~> 0.6'
|
|
14
|
+
gem 'rubocop-rspec', '~> 3.0'
|
|
15
|
+
gem 'webmock', '~> 3.19'
|
data/README.md
CHANGED
|
@@ -1,281 +1,260 @@
|
|
|
1
|
-
|
|
1
|
+
# cent
|
|
2
|
+
|
|
2
3
|

|
|
3
4
|
|
|
4
|
-
[Centrifugo
|
|
5
|
+
Ruby client for the [Centrifugo](https://centrifugal.dev) server HTTP API.
|
|
5
6
|
|
|
6
|
-
|
|
7
|
+
- `Cent::Client` — call server API methods (publish, broadcast, presence, history, …).
|
|
8
|
+
- `Cent::Notary` — issue connection and subscription JWTs.
|
|
7
9
|
|
|
8
|
-
|
|
10
|
+
Works with Centrifugo **v4 and newer** (tested against v6.7.1). Ruby 3.0+.
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
9
13
|
|
|
10
14
|
```ruby
|
|
11
|
-
gem 'cent'
|
|
15
|
+
gem 'cent', '~> 4.0'
|
|
12
16
|
```
|
|
13
17
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
Or install it yourself as:
|
|
18
|
+
```sh
|
|
19
|
+
$ bundle install
|
|
20
|
+
```
|
|
19
21
|
|
|
20
|
-
|
|
22
|
+
## API client
|
|
21
23
|
|
|
22
|
-
|
|
24
|
+
```ruby
|
|
25
|
+
client = Cent::Client.new(api_key: 'your-api-key')
|
|
26
|
+
# Or pointing at a remote Centrifugo:
|
|
27
|
+
client = Cent::Client.new(
|
|
28
|
+
api_key: 'your-api-key',
|
|
29
|
+
endpoint: 'https://centrifugo.example.com/api',
|
|
30
|
+
timeout: 5
|
|
31
|
+
)
|
|
32
|
+
```
|
|
23
33
|
|
|
24
|
-
|
|
25
|
-
- `Cent::Client` to call API methods
|
|
26
|
-
- `Cent::Notary` to generate tokens
|
|
34
|
+
Every method returns the parsed response body from Centrifugo:
|
|
27
35
|
|
|
28
|
-
|
|
36
|
+
- On success the body has a `"result"` key: `{ "result" => { ... } }`.
|
|
37
|
+
- On an API-level failure (e.g. unknown channel, namespace not found) `Cent::ResponseError` is raised with Centrifugo's numeric `code` and `message`.
|
|
38
|
+
- On a transport problem (network failure, timeout, non-2xx HTTP, malformed JSON) a `Cent::Error` subclass is raised.
|
|
29
39
|
|
|
30
|
-
|
|
31
|
-
notary = Cent::Notary.new(secret: 'secret')
|
|
32
|
-
```
|
|
40
|
+
`batch` and `broadcast` are different — see their sections below.
|
|
33
41
|
|
|
34
|
-
|
|
42
|
+
### Customizing the connection
|
|
35
43
|
|
|
36
|
-
|
|
44
|
+
The initializer yields the underlying [`Faraday::Connection`](https://lostisland.github.io/faraday/) so you can adjust headers, timeouts, adapter, etc.
|
|
37
45
|
|
|
38
46
|
```ruby
|
|
39
|
-
|
|
40
|
-
|
|
47
|
+
Cent::Client.new(api_key: 'k') do |conn|
|
|
48
|
+
conn.headers['User-Agent'] = 'my-app/1.0'
|
|
49
|
+
conn.options.open_timeout = 3
|
|
50
|
+
conn.options.timeout = 7
|
|
51
|
+
conn.adapter :typhoeus
|
|
52
|
+
end
|
|
41
53
|
```
|
|
42
54
|
|
|
43
|
-
|
|
55
|
+
### Publishing
|
|
44
56
|
|
|
45
57
|
```ruby
|
|
46
|
-
|
|
47
|
-
|
|
58
|
+
client.publish(channel: 'chat', data: { text: 'hello' })
|
|
59
|
+
# => {"result" => {"offset" => 1, "epoch" => "xyz"}}
|
|
60
|
+
|
|
61
|
+
client.publish(
|
|
62
|
+
channel: 'chat',
|
|
63
|
+
data: { text: 'hello' },
|
|
64
|
+
skip_history: false,
|
|
65
|
+
tags: { 'author' => '42' },
|
|
66
|
+
idempotency_key: 'my-idempotency-key',
|
|
67
|
+
delta: true
|
|
68
|
+
)
|
|
48
69
|
```
|
|
49
70
|
|
|
50
|
-
|
|
71
|
+
See [publish](https://centrifugal.dev/docs/server/server_api#publish).
|
|
51
72
|
|
|
52
|
-
|
|
73
|
+
### Broadcast
|
|
53
74
|
|
|
54
75
|
```ruby
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
#=> "eyJhbGciOiJIUzI1NiJ9..."
|
|
76
|
+
response = client.broadcast(channels: %w[chat:1 chat:2], data: { text: 'hi' })
|
|
77
|
+
# response => { "result" => { "responses" => [ {"result" => {...}}, {"result" => {...}} ] } }
|
|
58
78
|
```
|
|
59
79
|
|
|
60
|
-
`
|
|
80
|
+
The outer call only raises `Cent::ResponseError` if the whole broadcast is rejected (e.g. malformed request). Per-channel failures are delivered as individual entries in `response["result"]["responses"]`, each of which may contain an `"error"` key — **these are not raised**. Walk the array to check them:
|
|
61
81
|
|
|
62
82
|
```ruby
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
83
|
+
response['result']['responses'].each_with_index do |r, i|
|
|
84
|
+
warn "channel #{i} failed: #{r['error']['message']}" if r['error']
|
|
85
|
+
end
|
|
66
86
|
```
|
|
67
87
|
|
|
68
|
-
###
|
|
69
|
-
|
|
70
|
-
All channels starting with $ considered private and require a **channel token** to subscribe.
|
|
71
|
-
Private channel subscription token is also JWT([see the claims](https://centrifugal.github.io/centrifugo/server/private_channels/))
|
|
88
|
+
### Subscribe / Unsubscribe
|
|
72
89
|
|
|
73
90
|
```ruby
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
#=> "eyJhbGciOiJIUzI1NiJ9..."
|
|
91
|
+
client.subscribe(user: '42', channel: 'chat')
|
|
92
|
+
client.unsubscribe(user: '42', channel: 'chat')
|
|
77
93
|
```
|
|
78
|
-
|
|
79
|
-
### API Client
|
|
80
94
|
|
|
81
|
-
|
|
95
|
+
### Disconnect / Refresh
|
|
82
96
|
|
|
83
97
|
```ruby
|
|
84
|
-
client
|
|
98
|
+
client.disconnect(user: '42')
|
|
99
|
+
client.disconnect(user: '42', whitelist: %w[keep-this-client-id])
|
|
100
|
+
|
|
101
|
+
client.refresh(user: '42', expired: true)
|
|
85
102
|
```
|
|
86
103
|
|
|
87
|
-
|
|
104
|
+
### Presence / Presence stats
|
|
88
105
|
|
|
89
106
|
```ruby
|
|
90
|
-
client
|
|
91
|
-
|
|
92
|
-
connection.options.open_timeout = 3
|
|
93
|
-
connection.options.timeout = 7
|
|
94
|
-
connection.adapter :typhoeus
|
|
95
|
-
end
|
|
107
|
+
client.presence(channel: 'chat')
|
|
108
|
+
client.presence_stats(channel: 'chat')
|
|
96
109
|
```
|
|
97
110
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
Send data to the channel.
|
|
101
|
-
|
|
102
|
-
[publish](https://centrifugal.dev/docs/server/server_api#publish)
|
|
111
|
+
### History
|
|
103
112
|
|
|
104
113
|
```ruby
|
|
105
|
-
client.
|
|
114
|
+
client.history(channel: 'chat', limit: 10)
|
|
115
|
+
client.history(channel: 'chat', limit: 10, reverse: true)
|
|
116
|
+
client.history(channel: 'chat', limit: 10, since: { 'offset' => 5, 'epoch' => 'xyz' })
|
|
117
|
+
client.history_remove(channel: 'chat')
|
|
106
118
|
```
|
|
107
119
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
Sends data to multiple channels.
|
|
111
|
-
|
|
112
|
-
[broadcast](https://centrifugal.dev/docs/server/server_api#broadcast)
|
|
120
|
+
### Channels
|
|
113
121
|
|
|
114
122
|
```ruby
|
|
115
|
-
client.
|
|
123
|
+
client.channels
|
|
124
|
+
client.channels(pattern: 'chat:*')
|
|
116
125
|
```
|
|
117
126
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
Unsubscribe user from channel. Receives to arguments: channel and user (user ID you want to unsubscribe)
|
|
121
|
-
|
|
122
|
-
[unsubscribe](https://centrifugal.dev/docs/server/server_api#unsubscribe)
|
|
127
|
+
### Info
|
|
123
128
|
|
|
124
129
|
```ruby
|
|
125
|
-
client.
|
|
130
|
+
client.info
|
|
126
131
|
```
|
|
127
132
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
Allows to disconnect user by it's ID. Receives user ID as an argument.
|
|
133
|
+
### Batch
|
|
131
134
|
|
|
132
|
-
|
|
135
|
+
Send many commands in one HTTP request — Centrifugo processes them sequentially (or in parallel with `parallel: true`) and returns one reply per command in the same order.
|
|
133
136
|
|
|
134
137
|
```ruby
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
+
response = client.batch(commands: [
|
|
139
|
+
{ 'publish' => { 'channel' => 'a', 'data' => { 'x' => 1 } } },
|
|
140
|
+
{ 'publish' => { 'channel' => 'b', 'data' => { 'x' => 2 } } },
|
|
141
|
+
{ 'presence_stats' => { 'channel' => 'a' } }
|
|
142
|
+
])
|
|
143
|
+
# => { "replies" => [ {"publish" => {...}}, {"publish" => {...}}, {"presence_stats" => {...}} ] }
|
|
138
144
|
```
|
|
139
145
|
|
|
140
|
-
|
|
146
|
+
Two things about batch are different from every other method:
|
|
141
147
|
|
|
142
|
-
|
|
148
|
+
1. **No `result` wrapper.** The response is `{ "replies" => [...] }` at the top level. This matches Centrifugo's wire format.
|
|
149
|
+
2. **Per-command errors are not raised.** Each entry in `replies` may instead be `{ "error" => { "code" => ..., "message" => ... } }`. Raising on the first would make partial-success responses impossible to inspect — so the caller is expected to walk the array:
|
|
143
150
|
|
|
144
|
-
|
|
151
|
+
```ruby
|
|
152
|
+
response['replies'].each_with_index do |reply, i|
|
|
153
|
+
if reply['error']
|
|
154
|
+
warn "command #{i} failed: #{reply['error']['code']} #{reply['error']['message']}"
|
|
155
|
+
end
|
|
156
|
+
end
|
|
157
|
+
```
|
|
145
158
|
|
|
146
|
-
|
|
147
|
-
client.presence(channel: 'chat')
|
|
148
|
-
|
|
149
|
-
# {
|
|
150
|
-
# 'result' => {
|
|
151
|
-
# 'presence' => {
|
|
152
|
-
# 'c54313b2-0442-499a-a70c-051f8588020f' => {
|
|
153
|
-
# 'client' => 'c54313b2-0442-499a-a70c-051f8588020f',
|
|
154
|
-
# 'user' => '42'
|
|
155
|
-
# },
|
|
156
|
-
# 'adad13b1-0442-499a-a70c-051f858802da' => {
|
|
157
|
-
# 'client' => 'adad13b1-0442-499a-a70c-051f858802da',
|
|
158
|
-
# 'user' => '42'
|
|
159
|
-
# }
|
|
160
|
-
# }
|
|
161
|
-
# }
|
|
162
|
-
# }
|
|
163
|
-
```
|
|
164
|
-
|
|
165
|
-
#### Presence stats
|
|
166
|
-
|
|
167
|
-
Get short channel presence information.
|
|
168
|
-
|
|
169
|
-
[presence_stats](https://centrifugal.dev/docs/server/server_api#presence_stats)
|
|
159
|
+
`Cent::ResponseError` is still raised if Centrifugo rejects the batch request as a whole (e.g. malformed top-level body).
|
|
170
160
|
|
|
171
|
-
|
|
172
|
-
client.presence_stats(channel: 'chat')
|
|
161
|
+
### Error handling
|
|
173
162
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
#
|
|
179
|
-
# }
|
|
163
|
+
```ruby
|
|
164
|
+
begin
|
|
165
|
+
response = client.publish(channel: 'chat', data: 'hi')
|
|
166
|
+
rescue Cent::ResponseError => e
|
|
167
|
+
# Centrifugo rejected the request (e.g. unknown channel, namespace not found).
|
|
168
|
+
puts "Centrifugo error #{e.code}: #{e.message}"
|
|
169
|
+
rescue Cent::TimeoutError
|
|
170
|
+
# request timed out
|
|
171
|
+
rescue Cent::NetworkError
|
|
172
|
+
# connection refused / DNS failure / etc.
|
|
173
|
+
rescue Cent::UnauthorizedError => e
|
|
174
|
+
# HTTP 401 — API key is wrong
|
|
175
|
+
rescue Cent::TransportError => e
|
|
176
|
+
# other 4xx/5xx — e.status has the HTTP code
|
|
177
|
+
rescue Cent::DecodeError
|
|
178
|
+
# response body wasn't valid JSON
|
|
179
|
+
end
|
|
180
180
|
```
|
|
181
181
|
|
|
182
|
-
|
|
182
|
+
All of the above inherit from `Cent::Error`, so you can rescue that single class if you don't need to discriminate.
|
|
183
183
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
[history](https://centrifugal.dev/docs/server/server_api#history)
|
|
184
|
+
## Token generation
|
|
187
185
|
|
|
188
186
|
```ruby
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
#
|
|
192
|
-
# 'result' => {
|
|
193
|
-
# 'publications' => [
|
|
194
|
-
# {
|
|
195
|
-
# 'data' => {
|
|
196
|
-
# 'text' => 'hello'
|
|
197
|
-
# }
|
|
198
|
-
# },
|
|
199
|
-
# {
|
|
200
|
-
# 'data' => {
|
|
201
|
-
# 'text' => 'hi!'
|
|
202
|
-
# }
|
|
203
|
-
# }
|
|
204
|
-
# ]
|
|
205
|
-
# }
|
|
206
|
-
# }
|
|
187
|
+
notary = Cent::Notary.new(secret: 'hmac-secret') # HS256
|
|
188
|
+
notary = Cent::Notary.new(secret: rsa_private_key, algorithm: 'RS256') # RSA
|
|
189
|
+
notary = Cent::Notary.new(secret: ec_private_key, algorithm: 'ES256') # ECDSA
|
|
207
190
|
```
|
|
208
191
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
Get list of active(with one or more subscribers) channels.
|
|
192
|
+
### Connection token
|
|
212
193
|
|
|
213
|
-
[
|
|
194
|
+
Used by clients to establish a real-time connection. See [authentication](https://centrifugal.dev/docs/server/authentication).
|
|
214
195
|
|
|
215
196
|
```ruby
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
#
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
197
|
+
notary.issue_connection_token(sub: '42')
|
|
198
|
+
notary.issue_connection_token(sub: '42', exp: Time.now.to_i + 600, info: { name: 'Alex' })
|
|
199
|
+
|
|
200
|
+
# With any of the standard/Centrifugo claims:
|
|
201
|
+
notary.issue_connection_token(
|
|
202
|
+
sub: '42', exp: 1735689600, iat: 1735686000, jti: SecureRandom.uuid,
|
|
203
|
+
aud: 'centrifugo', iss: 'my-app',
|
|
204
|
+
info: { role: 'admin' }, meta: { tenant: 'acme' },
|
|
205
|
+
channels: %w[user:42 news],
|
|
206
|
+
subs: { 'room:1' => { 'data' => { 'welcome' => true } } }
|
|
207
|
+
)
|
|
225
208
|
```
|
|
226
209
|
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
Get running Centrifugo nodes information.
|
|
210
|
+
### Subscription token
|
|
230
211
|
|
|
231
|
-
[
|
|
212
|
+
Used by clients to subscribe to a channel that requires token authorization. See [channel token auth](https://centrifugal.dev/docs/server/channel_token_auth).
|
|
232
213
|
|
|
233
214
|
```ruby
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
# 'name' => 'Alexanders-MacBook-Pro.local_8000',
|
|
241
|
-
# 'num_channels' => 0,
|
|
242
|
-
# 'num_clients' => 0,
|
|
243
|
-
# 'num_users' => 0,
|
|
244
|
-
# 'uid' => 'f844a2ed-5edf-4815-b83c-271974003db9',
|
|
245
|
-
# 'uptime' => 0,
|
|
246
|
-
# 'version' => ''
|
|
247
|
-
# }
|
|
248
|
-
# ]
|
|
249
|
-
# }
|
|
250
|
-
# }
|
|
215
|
+
notary.issue_channel_token(sub: '42', channel: 'private-chat', exp: 1735689600)
|
|
216
|
+
notary.issue_channel_token(
|
|
217
|
+
sub: '42', channel: 'private-chat',
|
|
218
|
+
info: { role: 'writer' },
|
|
219
|
+
override: { 'presence' => { 'value' => true } }
|
|
220
|
+
)
|
|
251
221
|
```
|
|
252
222
|
|
|
253
|
-
|
|
223
|
+
## Migrating from v3
|
|
254
224
|
|
|
255
|
-
|
|
225
|
+
v4 changes some aspects of the library. We expect smooth migration for happy path though.
|
|
256
226
|
|
|
257
|
-
|
|
227
|
+
- **Centrifugo v5+ is required.** v3 of this gem spoke the legacy `POST /api` JSON-RPC-style protocol; v4 uses the current per-method endpoints (`POST /api/publish`, `POST /api/broadcast`, …) and sends the API key as `X-API-Key` instead of `Authorization: apikey <key>`.
|
|
228
|
+
- **Error handling is unchanged for the common case.** `Cent::ResponseError` still exists and is still raised when Centrifugo returns a top-level API error. Existing `rescue Cent::ResponseError => e` blocks using `e.code` / `e.message` keep working. The new additions are typed transport errors — `Cent::TimeoutError`, `Cent::NetworkError`, `Cent::TransportError`, `Cent::UnauthorizedError`, `Cent::DecodeError` — all subclassed under `Cent::Error`.
|
|
229
|
+
- **Keyword arg rename**: `Cent::Notary#issue_channel_token(client:)` → `issue_channel_token(sub:)` to match Centrifugo's standard `sub` JWT claim.
|
|
230
|
+
- **Ruby 3.0+** is required (was 2.5+).
|
|
231
|
+
- **New methods** added for common Centrifugo operations: `subscribe`, `refresh`, `history_remove`, `batch`.
|
|
232
|
+
- **Richer kwargs** on existing methods (e.g. `publish` now accepts `tags`, `skip_history`, `idempotency_key`, `delta`, `version`, `version_epoch`, `b64data`; `history` accepts `limit`, `since`, `reverse`; `channels` accepts `pattern`).
|
|
258
233
|
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
ex.message # => "Invalid format"
|
|
266
|
-
end
|
|
234
|
+
## Development
|
|
235
|
+
|
|
236
|
+
```sh
|
|
237
|
+
$ bin/setup # install dependencies
|
|
238
|
+
$ bundle exec rspec # run unit tests
|
|
239
|
+
$ bundle exec rubocop # lint
|
|
267
240
|
```
|
|
268
241
|
|
|
269
|
-
|
|
242
|
+
### Running integration tests
|
|
270
243
|
|
|
271
|
-
|
|
244
|
+
Integration tests under `spec/integration/` exercise a real Centrifugo server. They're skipped unless `CENTRIFUGO_API_URL` is set.
|
|
272
245
|
|
|
273
|
-
|
|
246
|
+
```sh
|
|
247
|
+
$ docker compose up -d
|
|
248
|
+
$ CENTRIFUGO_API_URL=http://localhost:8000/api CENTRIFUGO_API_KEY=api_key bundle exec rspec spec/integration
|
|
249
|
+
```
|
|
274
250
|
|
|
275
|
-
|
|
251
|
+
### Testing across Faraday / JWT versions
|
|
276
252
|
|
|
277
|
-
|
|
253
|
+
```sh
|
|
254
|
+
$ bundle exec appraisal install # generate gemfiles/*.gemfile.lock
|
|
255
|
+
$ bundle exec appraisal rspec # run the full matrix locally
|
|
256
|
+
```
|
|
278
257
|
|
|
279
258
|
## License
|
|
280
259
|
|
|
281
|
-
|
|
260
|
+
MIT — see [LICENSE.txt](LICENSE.txt).
|
data/cent.gemspec
CHANGED
|
@@ -5,33 +5,32 @@ require_relative 'lib/cent/version'
|
|
|
5
5
|
Gem::Specification.new do |spec|
|
|
6
6
|
spec.name = 'cent'
|
|
7
7
|
spec.version = Cent::VERSION
|
|
8
|
-
spec.authors = ['Sergey Prikhodko']
|
|
8
|
+
spec.authors = ['Sergey Prikhodko', 'Centrifugal Labs']
|
|
9
9
|
spec.email = ['prikha@gmail.com']
|
|
10
10
|
|
|
11
|
-
spec.summary = 'Centrifugo API
|
|
11
|
+
spec.summary = 'Centrifugo server API client for Ruby'
|
|
12
12
|
spec.description = <<~DESC
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
`Client::Notary` is a simple JWT wrapper to generate authorization tokens for the frontend
|
|
13
|
+
Ruby client for Centrifugo server HTTP API. Provides Cent::Client to call
|
|
14
|
+
Centrifugo server methods (publish, broadcast, subscribe, presence, history, ...)
|
|
15
|
+
and Cent::Notary to issue JWT connection and subscription tokens.
|
|
17
16
|
DESC
|
|
18
17
|
spec.homepage = 'https://github.com/centrifugal/rubycent'
|
|
19
18
|
spec.license = 'MIT'
|
|
20
|
-
spec.required_ruby_version = Gem::Requirement.new('>=
|
|
19
|
+
spec.required_ruby_version = Gem::Requirement.new('>= 3.0')
|
|
21
20
|
|
|
22
|
-
spec.metadata['homepage_uri'] = spec.homepage
|
|
23
21
|
spec.metadata['source_code_uri'] = 'https://github.com/centrifugal/rubycent'
|
|
22
|
+
spec.metadata['changelog_uri'] = 'https://github.com/centrifugal/rubycent/releases'
|
|
23
|
+
spec.metadata['bug_tracker_uri'] = 'https://github.com/centrifugal/rubycent/issues'
|
|
24
24
|
|
|
25
|
-
# Specify which files should be added to the gem when it is released.
|
|
26
|
-
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
|
27
25
|
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
|
28
|
-
`git ls-files -z`.split("\x0").reject
|
|
26
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
|
27
|
+
f.match(%r{\A(?:spec|benchmarks|gemfiles|\.github)/}) ||
|
|
28
|
+
f.match(/\A(?:docker-compose\.yml|Appraisals|\.rubocop\.yml|\.rspec|\.gitignore)\z/)
|
|
29
|
+
end
|
|
29
30
|
end
|
|
30
31
|
|
|
31
32
|
spec.require_paths = ['lib']
|
|
32
33
|
|
|
33
|
-
spec.add_dependency 'faraday', '
|
|
34
|
-
|
|
35
|
-
spec.add_dependency 'faraday_middleware', '<2.0.0', '~> 1.0'
|
|
36
|
-
spec.add_dependency 'jwt', '~> 2.2'
|
|
34
|
+
spec.add_dependency 'faraday', '>= 2.0', '< 4'
|
|
35
|
+
spec.add_dependency 'jwt', '>= 2.2', '< 4'
|
|
37
36
|
end
|