Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

change Marshal serialization to JSON

  • Loading branch information...
commit 3e36d8b7c80e4e32204455a8d0baad41d401e812 1 parent ec21216
Paweł Smoczyk smoku authored
2  lib/rapnd.rb
@@ -7,7 +7,7 @@ module Rapnd
7 7 extend self
8 8
9 9 def queue(queue_name, message)
10   - self.redis.lpush(queue_name, Marshal.dump(message))
  10 + self.redis.lpush(queue_name, message.to_json)
11 11 end
12 12
13 13 def redis
2  lib/rapnd/daemon.rb
@@ -54,7 +54,7 @@ def run!
54 54 begin
55 55 message = @redis.blpop(self.queue, 1)
56 56 if message
57   - notification = Rapnd::Notification.new(Marshal.load(message.last))
  57 + notification = Rapnd::Notification.new(JSON(message.last).symbolize_keys)
58 58 self.connect! unless self.connected
59 59 @logger.info "Sending #{notification.device_token}: #{notification.json_payload}"
60 60 self.apple.write(notification.to_bytes)
2  spec/rapnd_spec.rb
@@ -14,7 +14,7 @@
14 14 Rapnd.queue('test_queue', {:alert => 'Hi!'})
15 15
16 16 @redis.llen('test_queue').should == 1
17   - Marshal.load(@redis.lpop('test_queue')).should == {:alert => 'Hi!'}
  17 + JSON(@redis.lpop('test_queue')).symbolize_keys.should == {:alert => 'Hi!'}
18 18 end
19 19
20 20 it 'gets a redis connection' do

0 comments on commit 3e36d8b

Please sign in to comment.
Something went wrong with that request. Please try again.