Skip to content
This repository has been archived by the owner on Jul 23, 2023. It is now read-only.

Commit

Permalink
change ~ to \A in regexes
Browse files Browse the repository at this point in the history
  • Loading branch information
markburns committed May 14, 2015
1 parent 1fa82f5 commit 2d2fcd1
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions lib/slanger/channel.rb
Expand Up @@ -17,7 +17,7 @@ class Channel

class << self
def from channel_id
klass = channel_id[/^presence-/] ? PresenceChannel : Channel
klass = channel_id[/\Apresence-/] ? PresenceChannel : Channel

klass.lookup(channel_id) || klass.create(channel_id: channel_id)
end
Expand Down Expand Up @@ -81,11 +81,11 @@ def send_client_message(message)
# Send an event received from Redis to the EventMachine channel
# which will send it to subscribed clients.
def dispatch(message, channel)
push(message.to_json) unless channel =~ /^slanger:/
push(message.to_json) unless channel =~ /\Aslanger:/
end

def authenticated?
channel_id =~ /^private-/ || channel_id =~ /^presence-/
channel_id =~ /\Aprivate-/ || channel_id =~ /\Apresence-/
end
end
end
6 changes: 3 additions & 3 deletions lib/slanger/handler.rb
Expand Up @@ -28,9 +28,9 @@ def onmessage(msg)

msg['data'] = JSON.parse(msg['data']) if msg['data'].is_a? String

event = msg['event'].gsub(/^pusher:/, 'pusher_')
event = msg['event'].gsub(/\Apusher:/, 'pusher_')

if event =~ /^client-/
if event =~ /\Aclient-/
msg['socket_id'] = connection.socket_id
Channel.send_client_message msg
elsif respond_to? event, true
Expand Down Expand Up @@ -106,7 +106,7 @@ def valid_app_key? app_key
end

def subscription_klass channel_id
klass = channel_id.match(/^(private|presence)-/) do |match|
klass = channel_id.match(/\A(private|presence)-/) do |match|
Slanger.const_get "#{match[1]}_subscription".classify
end

Expand Down
2 changes: 1 addition & 1 deletion lib/slanger/presence_channel.rb
Expand Up @@ -15,7 +15,7 @@ class PresenceChannel < Channel

# Send an event received from Redis to the EventMachine channel
def dispatch(message, channel)
if channel =~ /^slanger:/
if channel =~ /\Aslanger:/
# Messages received from the Redis channel slanger:* carry info on
# subscriptions. Update our subscribers accordingly.
update_subscribers message
Expand Down

0 comments on commit 2d2fcd1

Please sign in to comment.