Skip to content

Commit

Permalink
replaced ActiveSupport with Yajl
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremytregunna committed Mar 18, 2011
1 parent 96ce406 commit 5c50800
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
5 changes: 2 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ source "http://rubygems.org"

gem "eventmachine"
gem "daemons"
gem "activesupport", ">= 3.0.0"
gem "i18n" # active support whines without this
gem "yajl-ruby"

group :spec do
gem "rspec"
end
end
6 changes: 2 additions & 4 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
GEM
remote: http://rubygems.org/
specs:
activesupport (3.0.3)
daemons (1.0.10)
diff-lcs (1.1.2)
eventmachine (0.12.10)
i18n (0.5.0)
rspec (2.3.0)
rspec-core (~> 2.3.0)
rspec-expectations (~> 2.3.0)
Expand All @@ -14,13 +12,13 @@ GEM
rspec-expectations (2.3.0)
diff-lcs (~> 1.1.2)
rspec-mocks (2.3.0)
yajl-ruby (0.8.1)

PLATFORMS
ruby

DEPENDENCIES
activesupport (>= 3.0.0)
daemons
eventmachine
i18n
rspec
yajl-ruby
9 changes: 8 additions & 1 deletion README.textile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ h1. Apple Push Notification Server Toolkit

* http://github.com/bpoweski/apnserver

This is an independent fork of the above repository, to run with the Fracas web service. Some
changes have been made, notably the JSON encoding/decoding. I've pulled out the dependency on
ActiveSupport, and introduced a dependency on Yajl. As such, I've rewritten all JSON decoding
and encoding to use Yajl.

Other changes will be forthcoming.

h2. Description

apnserver is a server and set of command line programs to send push notifications to the iPhone.
Expand All @@ -20,7 +27,7 @@ h2. Issues Fixed
* second attempt at retry logic, SSL Errors close down sockets now
* apnsend --badge option correctly sends integer number rather than string of number for aps json payload
* connections are properly closed in Notification#push method now
* removed json gem in favor of ActiveSupport
* removed ActiveSupport in favor of Yajl
* Rails 3.x support
* drop the erroneous puts statements in favor a configurable logger
* moved to Rspec
Expand Down
7 changes: 3 additions & 4 deletions lib/apnserver/notification.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
require 'apnserver/payload'
require 'base64'
require 'active_support/ordered_hash'
require 'active_support/json'
require 'yajl'

module ApnServer
class Config
Expand All @@ -26,7 +25,7 @@ def payload
end

def json_payload
j = ActiveSupport::JSON.encode(payload)
j = Yajl::Encoder.encode(payload)
raise PayloadInvalid.new("The payload is larger than allowed: #{j.length}") if j.size > 256
j
end
Expand Down Expand Up @@ -77,7 +76,7 @@ def self.parse(p)
# parse json payload
payload_len = buffer.slice!(0, 2).unpack('CC')
j = buffer.slice!(0, payload_len.last)
result = ActiveSupport::JSON.decode(j)
result = Yajl::Parser.parse(j)

['alert', 'badge', 'sound'].each do |k|
notification.send("#{k}=", result['aps'][k]) if result['aps'] && result['aps'][k]
Expand Down

0 comments on commit 5c50800

Please sign in to comment.