diff --git a/README.md b/README.md index 6f93306..654819e 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ This Gem provides a Ruby interface to [the Pusher HTTP API for Pusher Channels]( ## Supported Platforms -* Ruby - supports **Ruby 2.6 or greater**. +* Ruby - supports **Ruby 3.1 or greater**. ## Installation and Configuration diff --git a/lib/pusher/channel.rb b/lib/pusher/channel.rb index 0d214d6..57e88fc 100644 --- a/lib/pusher/channel.rb +++ b/lib/pusher/channel.rb @@ -8,7 +8,7 @@ class Channel INVALID_CHANNEL_REGEX = /[^A-Za-z0-9_\-=@,.;]/ def initialize(_, name, client = Pusher) - if Pusher::Channel::INVALID_CHANNEL_REGEX.match(name) + if Pusher::Channel::INVALID_CHANNEL_REGEX.match?(name) raise Pusher::Error, "Illegal channel name '#{name}'" elsif name.length > 200 raise Pusher::Error, "Channel name too long (limit 164 characters) '#{name}'" diff --git a/lib/pusher/client.rb b/lib/pusher/client.rb index 1a78a57..00194b2 100644 --- a/lib/pusher/client.rb +++ b/lib/pusher/client.rb @@ -347,7 +347,7 @@ def trigger_batch_async(*events) def authenticate(channel_name, socket_id, custom_data = nil) channel_instance = channel(channel_name) r = channel_instance.authenticate(socket_id, custom_data) - if channel_name.match(/^private-encrypted-/) + if channel_name.match?(/^private-encrypted-/) r[:shared_secret] = Base64.strict_encode64( channel_instance.shared_secret(encryption_master_key) ) @@ -430,7 +430,7 @@ def trigger_params(channels, event_name, data, params) channels = Array(channels).map(&:to_s) raise Pusher::Error, "Too many channels (#{channels.length}), max 100" if channels.length > 100 - encoded_data = if channels.any?{ |c| c.match(/^private-encrypted-/) } then + encoded_data = if channels.any?{ |c| c.match?(/^private-encrypted-/) } raise Pusher::Error, "Cannot trigger to multiple channels if any are encrypted" if channels.length > 1 encrypt(channels[0], encode_data(data)) else @@ -448,7 +448,7 @@ def trigger_batch_params(events) { batch: events.map do |event| event.dup.tap do |e| - e[:data] = if e[:channel].match(/^private-encrypted-/) then + e[:data] = if e[:channel].match?(/^private-encrypted-/) encrypt(e[:channel], encode_data(e[:data])) else encode_data(e[:data]) diff --git a/lib/pusher/utils.rb b/lib/pusher/utils.rb index 7fffffd..3bfd900 100644 --- a/lib/pusher/utils.rb +++ b/lib/pusher/utils.rb @@ -1,7 +1,7 @@ module Pusher module Utils def validate_socket_id(socket_id) - unless socket_id && /\A\d+\.\d+\z/.match(socket_id) + unless socket_id && /\A\d+\.\d+\z/.match?(socket_id) raise Pusher::Error, "Invalid socket ID #{socket_id.inspect}" end end