pubnub 6.2.0 → 6.2.1
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/.pubnub.yml +9 -4
- data/CHANGELOG.md +6 -0
- data/Gemfile.lock +1 -1
- data/README.md +157 -73
- data/VERSION +1 -1
- data/docs-snippets/access_manager.rb +49 -0
- data/lib/pubnub/client/paged_history.rb +2 -2
- data/lib/pubnub/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a790180f0c884132234cb47e28d9da09b35f649a2759a0d31e7577914b351f99
|
|
4
|
+
data.tar.gz: f9f12be27e3cb44f44ab616db1d399f2703b296c24ae1d4fcceb0c48c52751b3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1eedcea454e1b94e51a8befc4dcaf93c07161b1410fd34573cb37cc01befdcef6867ad8050abe22f3b83c8d35b793cbbc1371889eeb7d5ba0a15645a7714cb73
|
|
7
|
+
data.tar.gz: 2c47fb1b98cc5a0c0fe3b37845911c83a048be3c74d3a95dcb41cc361787985e920f7404095d38567e8633a03b66136699634176695f25b1822fbde419179327
|
data/.pubnub.yml
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
---
|
|
2
|
-
version: "6.2.
|
|
2
|
+
version: "6.2.1"
|
|
3
3
|
changelog:
|
|
4
|
+
- date: 2026-11-23
|
|
5
|
+
version: v6.2.1
|
|
6
|
+
changes:
|
|
7
|
+
- type: bug
|
|
8
|
+
text: "Preserve block callbacks in async history methods."
|
|
4
9
|
- date: 2026-10-21
|
|
5
10
|
version: v6.2.0
|
|
6
11
|
changes:
|
|
@@ -661,7 +666,7 @@ sdks:
|
|
|
661
666
|
- x86-64
|
|
662
667
|
- distribution-type: package
|
|
663
668
|
distribution-repository: RubyGems
|
|
664
|
-
package-name: pubnub-6.2.
|
|
669
|
+
package-name: pubnub-6.2.1.gem
|
|
665
670
|
location: https://rubygems.org/gems/pubnub
|
|
666
671
|
requires:
|
|
667
672
|
- name: addressable
|
|
@@ -766,8 +771,8 @@ sdks:
|
|
|
766
771
|
- x86-64
|
|
767
772
|
- distribution-type: library
|
|
768
773
|
distribution-repository: GitHub release
|
|
769
|
-
package-name: pubnub-6.2.
|
|
770
|
-
location: https://github.com/pubnub/ruby/releases/download/v6.2.
|
|
774
|
+
package-name: pubnub-6.2.1.gem
|
|
775
|
+
location: https://github.com/pubnub/ruby/releases/download/v6.2.1/pubnub-6.2.1.gem
|
|
771
776
|
requires:
|
|
772
777
|
- name: addressable
|
|
773
778
|
min-version: 2.0.0
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
## v6.2.1
|
|
2
|
+
November 23 2026
|
|
3
|
+
|
|
4
|
+
#### Fixed
|
|
5
|
+
- Preserve block callbacks in async history methods. Fixed the following issues reported by [@pcbeingused333](https://github.com/pcbeingused333): [#182](https://github.com/pubnub/ruby/issues/182).
|
|
6
|
+
|
|
1
7
|
## v6.2.0
|
|
2
8
|
October 21 2026
|
|
3
9
|
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
|
@@ -1,73 +1,157 @@
|
|
|
1
|
-
<img width="1920" height="600" alt="ruby-header" src="https://github.com/user-attachments/assets/ddf7134b-804c-48d6-aa74-cc67ee5aab94" />
|
|
2
|
-
|
|
3
|
-
# PubNub Ruby SDK
|
|
4
|
-
|
|
5
|
-
](https://rubygems.org/gems/pubnub)
|
|
6
|
+
|
|
7
|
+
PubNub provides global infrastructure for real-time, interactive applications.
|
|
8
|
+
|
|
9
|
+
Publish and receive messages in Ruby. Use this SDK for Ruby server, command-line, and backend applications.
|
|
10
|
+
|
|
11
|
+
[Documentation](https://www.pubnub.com/docs/sdks/ruby) · [API reference](https://www.pubnub.com/docs/sdks/ruby/api-reference/publish-and-subscribe) · [Changelog](https://www.pubnub.com/docs/sdks/ruby/changelog) · [Support](https://support.pubnub.com/)
|
|
12
|
+
|
|
13
|
+
## Requirements
|
|
14
|
+
|
|
15
|
+
| Requirement | Supported version or setup |
|
|
16
|
+
| --- | --- |
|
|
17
|
+
| Ruby | [Ruby 3.0.0 or later](https://github.com/pubnub/ruby/blob/master/pubnub.gemspec) |
|
|
18
|
+
| Dependency manager | RubyGems or Bundler. Install the `pubnub` gem directly or declare it in the application's Gemfile. |
|
|
19
|
+
|
|
20
|
+
## Installation
|
|
21
|
+
|
|
22
|
+
From the Ruby environment:
|
|
23
|
+
|
|
24
|
+
```sh
|
|
25
|
+
gem install pubnub
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
For other installation methods, see [environment setup](https://www.pubnub.com/docs/sdks/ruby).
|
|
29
|
+
|
|
30
|
+
## Quickstart
|
|
31
|
+
|
|
32
|
+
This example runs in a Ruby CLI application. It subscribes to `hello_world`, publishes one message, and prints the received text.
|
|
33
|
+
|
|
34
|
+
### Get your keys
|
|
35
|
+
|
|
36
|
+
1. Open the [PubNub Admin Portal](https://admin.pubnub.com/).
|
|
37
|
+
2. Create an app and a keyset for development, or select an existing development keyset.
|
|
38
|
+
3. Copy its publish key and subscribe key.
|
|
39
|
+
|
|
40
|
+
If Access Manager is enabled, obtain a token from your trusted backend and call `pubnub.set_token(token)`. Keep the secret key on the backend.
|
|
41
|
+
|
|
42
|
+
### Send and receive a message
|
|
43
|
+
|
|
44
|
+
Create `app.rb` in the project root and add:
|
|
45
|
+
|
|
46
|
+
Replace the key placeholders. Use a User ID that identifies the user or device in your app.
|
|
47
|
+
|
|
48
|
+
```ruby
|
|
49
|
+
require 'pubnub'
|
|
50
|
+
|
|
51
|
+
pubnub = Pubnub.new(
|
|
52
|
+
subscribe_key: 'YOUR_SUBSCRIBE_KEY',
|
|
53
|
+
publish_key: 'YOUR_PUBLISH_KEY',
|
|
54
|
+
user_id: 'hello-world-user'
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
received = Queue.new
|
|
58
|
+
published = false
|
|
59
|
+
|
|
60
|
+
callback = Pubnub::SubscribeCallback.new(
|
|
61
|
+
message: ->(envelope) do
|
|
62
|
+
puts envelope.result[:data][:message]
|
|
63
|
+
received << true
|
|
64
|
+
end,
|
|
65
|
+
|
|
66
|
+
status: ->(envelope) do
|
|
67
|
+
if !published && !envelope.error?
|
|
68
|
+
published = true
|
|
69
|
+
|
|
70
|
+
pubnub.publish(
|
|
71
|
+
channel: 'hello_world',
|
|
72
|
+
message: 'Hello world'
|
|
73
|
+
)
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
pubnub.add_listener(callback: callback)
|
|
79
|
+
|
|
80
|
+
pubnub.subscribe(
|
|
81
|
+
channels: ['hello_world']
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
received.pop
|
|
85
|
+
|
|
86
|
+
pubnub.unsubscribe(
|
|
87
|
+
channels: ['hello_world']
|
|
88
|
+
)
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Run the example
|
|
92
|
+
|
|
93
|
+
```sh
|
|
94
|
+
ruby app.rb
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
The terminal should show:
|
|
98
|
+
|
|
99
|
+
```
|
|
100
|
+
Hello world
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
The example unsubscribes from `hello_world` after receiving the message, and the script then exits.
|
|
104
|
+
|
|
105
|
+
For a complete application, see the [getting started guide](https://www.pubnub.com/docs/sdks/ruby).
|
|
106
|
+
|
|
107
|
+
## Next steps
|
|
108
|
+
|
|
109
|
+
| Task | Documentation |
|
|
110
|
+
| --- | --- |
|
|
111
|
+
| Configure the client | [Configuration](https://www.pubnub.com/docs/sdks/ruby/api-reference/configuration) |
|
|
112
|
+
| Work with subscriptions and messages | [Publish & Subscribe](https://www.pubnub.com/docs/sdks/ruby/api-reference/publish-and-subscribe) |
|
|
113
|
+
| Check channel occupancy | [Presence](https://www.pubnub.com/docs/sdks/ruby/api-reference/presence) |
|
|
114
|
+
| Read message history | [Message Persistence](https://www.pubnub.com/docs/sdks/ruby/api-reference/storage-and-playback) |
|
|
115
|
+
|
|
116
|
+
## Build with an AI coding assistant
|
|
117
|
+
|
|
118
|
+
The [PubNub MCP server](https://www.pubnub.com/docs/ai/pubnub-mcp-server) gives an AI coding assistant access to PubNub SDK documentation and PubNub APIs. Connect the assistant to the hosted server at `https://mcp.pubnub.com`, or run `npx @pubnub/mcp@latest` locally.
|
|
119
|
+
|
|
120
|
+
The [server repository](https://github.com/pubnub/pubnub-mcp-server) has setup steps for VS Code, Cursor, Claude Code, Claude Desktop, Codex, Gemini CLI, and OpenCode.
|
|
121
|
+
|
|
122
|
+
## Before production
|
|
123
|
+
|
|
124
|
+
Use [Access Manager](https://www.pubnub.com/docs/sdks/ruby/api-reference/access-manager) to grant each client the permissions it needs. Keep the secret key on your backend. Never include it in a distributed client.
|
|
125
|
+
|
|
126
|
+
Reuse the PubNub client for the owning service/application lifetime. Call `pubnub.unsubscribe(channels: [...])` for channel subscriptions that are no longer needed.
|
|
127
|
+
|
|
128
|
+
Live delivery through PubNub SDKs is at-most-once. A subscriber can miss messages while disconnected or if its buffer overflows. For longer-gap recovery, see [Message Persistence](https://www.pubnub.com/docs/sdks/ruby/api-reference/storage-and-playback).
|
|
129
|
+
|
|
130
|
+
## Troubleshooting
|
|
131
|
+
|
|
132
|
+
| Symptom | Check |
|
|
133
|
+
| --- | --- |
|
|
134
|
+
| Ruby loads a different PubNub gem version than the application expects | When using Bundler, declare `gem 'pubnub'` in the Gemfile and run the application with `bundle exec ruby app.rb`. See the [Ruby SDK guide](https://www.pubnub.com/docs/sdks/ruby). |
|
|
135
|
+
| A publish succeeds but no message appears | Check the message handler, subscription readiness, keyset, and channel name. |
|
|
136
|
+
| The process continues running after the owning workflow ends | Unsubscribe channels that are no longer needed with `pubnub.unsubscribe(channels: [...])`. See [Ruby troubleshooting](https://www.pubnub.com/docs/sdks/ruby/troubleshoot). |
|
|
137
|
+
| Extra clients or duplicate messages during development | For long-running Ruby servers/workers, create the PubNub client at application/service scope rather than on each request or code reload. |
|
|
138
|
+
|
|
139
|
+
For setup help, see [troubleshooting](https://www.pubnub.com/docs/sdks/ruby/troubleshoot). Check [network status](https://status.pubnub.com/) for service incidents.
|
|
140
|
+
|
|
141
|
+
## Releases
|
|
142
|
+
|
|
143
|
+
Read the [changelog](https://www.pubnub.com/docs/sdks/ruby/changelog) before upgrading.
|
|
144
|
+
|
|
145
|
+
For a major version change, review the [Ruby SDK changelog](https://www.pubnub.com/docs/sdks/ruby/changelog) for breaking changes before upgrading.
|
|
146
|
+
|
|
147
|
+
## Support and contributions
|
|
148
|
+
|
|
149
|
+
For setup or account help, contact [PubNub Support](https://support.pubnub.com/).
|
|
150
|
+
|
|
151
|
+
For a reproducible SDK bug, use [GitHub Issues](https://github.com/pubnub/ruby/issues). Include the SDK version, runtime, and a small reproduction with credentials removed.
|
|
152
|
+
|
|
153
|
+
Install the repository development dependencies, run the test suite, and include tests for behavioral changes before opening a pull request.
|
|
154
|
+
|
|
155
|
+
## License
|
|
156
|
+
|
|
157
|
+
See the [PubNub Software Development Kit License](https://github.com/pubnub/ruby/blob/master/LICENSE.txt).
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
6.2.
|
|
1
|
+
6.2.1
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
require 'pubnub'
|
|
2
|
+
|
|
3
|
+
pubnub = Pubnub.new(
|
|
4
|
+
subscribe_key: 'demo',
|
|
5
|
+
publish_key: 'demo',
|
|
6
|
+
secret_key: 'demo',
|
|
7
|
+
user_id: 'myUniqueUserId'
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
# snippet.grantTokenWithCategories
|
|
11
|
+
# Grants `my-authorized-user-id` permission to list all channel metadata and all uuid metadata.
|
|
12
|
+
# Category permissions support only the `get` operation.
|
|
13
|
+
envelope = pubnub.grant_token(
|
|
14
|
+
ttl: 15,
|
|
15
|
+
authorized_user_id: 'my-authorized-user-id',
|
|
16
|
+
categories: {
|
|
17
|
+
channels: Pubnub::Permissions.cat(get: true),
|
|
18
|
+
uuids: Pubnub::Permissions.cat(get: true)
|
|
19
|
+
},
|
|
20
|
+
http_sync: true
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
puts envelope.result[:data][:token]
|
|
24
|
+
# snippet.end
|
|
25
|
+
|
|
26
|
+
# snippet.parseTokenWithCategories
|
|
27
|
+
# Decodes a token that was granted with category permissions.
|
|
28
|
+
# The `cat` section holds the permission bitmask for each category: `chan` for channel
|
|
29
|
+
# metadata and `uuid` for uuid metadata. The `get` permission has the value 32.
|
|
30
|
+
parsed_token = pubnub.parse_token('use-token-string-generated-by-grant_token')
|
|
31
|
+
|
|
32
|
+
categories = parsed_token['cat']
|
|
33
|
+
puts "Channel metadata category: #{categories['chan']}"
|
|
34
|
+
puts "Uuid metadata category: #{categories['uuid']}"
|
|
35
|
+
# snippet.end
|
|
36
|
+
|
|
37
|
+
# snippet.grantWithCategories
|
|
38
|
+
# Grants the auth key permission to list all channel metadata and all uuid metadata.
|
|
39
|
+
# This legacy `grant` method requires the secret key to be set on the client.
|
|
40
|
+
envelope = pubnub.grant(
|
|
41
|
+
categories: %w[channels uuids],
|
|
42
|
+
auth_key: 'my-auth-key',
|
|
43
|
+
get: true,
|
|
44
|
+
ttl: 15,
|
|
45
|
+
http_sync: true
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
puts envelope.status
|
|
49
|
+
# snippet.end
|
|
@@ -25,7 +25,7 @@ module Pubnub
|
|
|
25
25
|
if options[:http_sync]
|
|
26
26
|
sync_all_history_messages(channel, include_token, page_size, reverse, maximum, callback, start: start_tt, end: end_tt)
|
|
27
27
|
else
|
|
28
|
-
async_all_history_messages(options)
|
|
28
|
+
async_all_history_messages(options.merge(callback: callback))
|
|
29
29
|
end
|
|
30
30
|
end
|
|
31
31
|
|
|
@@ -42,7 +42,7 @@ module Pubnub
|
|
|
42
42
|
if options[:http_sync]
|
|
43
43
|
sync_paged_history(channel, page, limit, include_token, callback, start: start_tt, end: end_tt)
|
|
44
44
|
else
|
|
45
|
-
async_paged_history(options)
|
|
45
|
+
async_paged_history(options.merge(callback: callback))
|
|
46
46
|
end
|
|
47
47
|
end
|
|
48
48
|
|
data/lib/pubnub/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: pubnub
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 6.2.
|
|
4
|
+
version: 6.2.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- PubNub
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-11-23 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: addressable
|
|
@@ -185,6 +185,7 @@ files:
|
|
|
185
185
|
- Rakefile
|
|
186
186
|
- VERSION
|
|
187
187
|
- config/cucumber.yml
|
|
188
|
+
- docs-snippets/access_manager.rb
|
|
188
189
|
- docs.md
|
|
189
190
|
- features/step_definitions/access_steps.rb
|
|
190
191
|
- features/step_definitions/crypto_steps.rb
|