rapns 3.0.0 → 3.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## 3.0.1 (Sun 16, 2012)
2
+ * Fix compatibility with Rails 3.0.x. Fixes #89.
3
+
4
+ ## 3.0.0 (Sat 15, 2012)
5
+ * Add support for Google Cloud Messaging.
6
+ * Fix Heroku logging issue.
7
+
1
8
  ## 2.0.5 (Nov 4, 2012) ##
2
9
  * Support content-available (#68).
3
10
  * Append to log files.
data/README.md CHANGED
@@ -10,6 +10,8 @@
10
10
  * Works with MRI, JRuby, Rubinius 1.8 and 1.9.
11
11
  * [Airbrake](http://airbrakeapp.com/) integration.
12
12
 
13
+ #### 2.x users please read [upgrading from 2.x to 3.0](rapns/wiki/Upgrading-from-version-2.x-to-3.0)
14
+
13
15
  ### Who uses Rapns?
14
16
 
15
17
  [GateGuru](http://gateguruapp.com) and [Desk.com](http://desk.com), among others!
@@ -22,12 +24,12 @@ Add Rapns to your Gemfile:
22
24
 
23
25
  gem 'rapns'
24
26
 
25
- Generate the migration, rapns.yml and migrate:
27
+ Generate the migrations, rapns.yml and migrate:
26
28
 
27
29
  rails g rapns
28
30
  rake db:migrate
29
31
 
30
- ## Generating Certificates
32
+ ## Generating Certificates (APNs only)
31
33
 
32
34
  1. Open up Keychain Access and select the `Certificates` category in the sidebar.
33
35
  2. Expand the disclosure arrow next to the iOS Push Services certificate you want to export.
@@ -87,7 +89,7 @@ n.save!
87
89
  cd /path/to/rails/app
88
90
  rapns <Rails environment> [options]
89
91
 
90
- See [Configuration](wiki/Configuration) for a list of options, or run `rapns --help`.
92
+ See [Configuration](rapns/wiki/Configuration) for a list of options, or run `rapns --help`.
91
93
 
92
94
  ## Updating Rapns
93
95
 
@@ -96,16 +98,16 @@ After updating you should run `rails g rapns` to check for any new migrations.
96
98
  ## Wiki
97
99
 
98
100
  ### General
99
- * [Configuration](wiki/Configuration)
100
- * [Upgrading from 2.x to 3.0](wiki/Upgrading-from-version-2.x-to-3.0)
101
- * [Deploying to Heroku](wiki/Heroku)
102
- * [Hot App Updates](wiki/Hot-App-Updates)
101
+ * [Configuration](rapns/wiki/Configuration)
102
+ * [Upgrading from 2.x to 3.0](rapns/wiki/Upgrading-from-version-2.x-to-3.0)
103
+ * [Deploying to Heroku](rapns/wiki/Heroku)
104
+ * [Hot App Updates](rapns/wiki/Hot-App-Updates)
103
105
 
104
106
  ### APNs
105
- * [Advanced APNs Features](wiki/Advanced-APNs-Features)
106
- * [APNs Delivery Failure Handling](wiki/APNs-Delivery-Failure-Handling)
107
- * [Why open multiple connections to the APNs?](wiki/Why-open-multiple-connections-to-the-APNs%3F)
108
- * [Silent failures might be dropped connections](wiki/Dropped-connections)
107
+ * [Advanced APNs Features](rapns/wiki/Advanced-APNs-Features)
108
+ * [APNs Delivery Failure Handling](rapns/wiki/APNs-Delivery-Failure-Handling)
109
+ * [Why open multiple connections to the APNs?](rapns/wiki/Why-open-multiple-connections-to-the-APNs%3F)
110
+ * [Silent failures might be dropped connections](rapns/wiki/Dropped-connections)
109
111
 
110
112
  ### GCM
111
113
 
@@ -0,0 +1,23 @@
1
+ module Rapns
2
+ module Deprecatable
3
+ def self.included(base)
4
+ base.extend ClassMethods
5
+ end
6
+
7
+ module ClassMethods
8
+ def deprecated(method_name, version, msg=nil)
9
+ instance_eval do
10
+ alias_method "#{method_name}_without_warning", method_name
11
+ end
12
+ warning = "#{method_name} is deprecated and will be removed from Rapns #{version}."
13
+ warning << " #{msg}" if msg
14
+ class_eval(<<-RUBY, __FILE__, __LINE__)
15
+ def #{method_name}(*args, &blk)
16
+ Rapns::Deprecation.warn(#{warning.inspect})
17
+ #{method_name}_without_warning(*args, &blk)
18
+ end
19
+ RUBY
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,22 @@
1
+ module Rapns
2
+ class Deprecation
3
+ def self.silenced
4
+ begin
5
+ Thread.current[:rapns_silence_deprecations] = true
6
+ yield
7
+ ensure
8
+ Thread.current[:rapns_silence_deprecations] = false
9
+ end
10
+ end
11
+
12
+ def self.silenced?
13
+ Thread.current[:rapns_silence_deprecations]
14
+ end
15
+
16
+ def self.warn(msg)
17
+ unless Rapns::Deprecation.silenced?
18
+ STDERR.puts "DEPRECATION WARNING: #{msg}"
19
+ end
20
+ end
21
+ end
22
+ end
@@ -25,10 +25,11 @@ module Rapns
25
25
  where(:app_id => apps.map(&:id))
26
26
  }
27
27
 
28
- def initialize(attributes = nil, options = {})
28
+ def initialize(*args)
29
+ attributes = args.first
29
30
  if attributes.is_a?(Hash) && attributes.keys.include?(:attributes_for_device)
30
31
  msg = ":attributes_for_device via mass-assignment is deprecated. Use :data or the attributes_for_device= instance method."
31
- ActiveSupport::Deprecation.warn(msg, caller(1))
32
+ Rapns::Deprecation.warn(msg)
32
33
  end
33
34
  super
34
35
  end
data/lib/rapns/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Rapns
2
- VERSION = '3.0.0'
2
+ VERSION = '3.0.1'
3
3
  end
data/lib/rapns.rb CHANGED
@@ -2,6 +2,8 @@ require 'active_record'
2
2
  require 'multi_json'
3
3
 
4
4
  require 'rapns/version'
5
+ require 'rapns/deprecation'
6
+ require 'rapns/deprecatable'
5
7
  require 'rapns/multi_json_helper'
6
8
  require 'rapns/notification'
7
9
  require 'rapns/app'
@@ -0,0 +1,32 @@
1
+ require 'unit_spec_helper'
2
+
3
+ describe Rapns::Deprecatable do
4
+ class HasDeprecatedMethod
5
+ include Rapns::Deprecatable
6
+
7
+ def original_called?
8
+ @called == true
9
+ end
10
+
11
+ def deprecated_method
12
+ @called = true
13
+ end
14
+ deprecated(:deprecated_method, '4.0')
15
+ end
16
+
17
+ let(:klass) { HasDeprecatedMethod.new }
18
+
19
+ before do
20
+ Rapns::Deprecation.stub(:warn)
21
+ end
22
+
23
+ it 'warns the method is deprecated when called' do
24
+ Rapns::Deprecation.should_receive(:warn).with("deprecated_method is deprecated and will be removed from Rapns 4.0.")
25
+ klass.deprecated_method
26
+ end
27
+
28
+ it 'calls the original method' do
29
+ klass.deprecated_method
30
+ klass.original_called?.should be_true
31
+ end
32
+ end
@@ -0,0 +1,15 @@
1
+ require 'unit_spec_helper'
2
+
3
+ describe Rapns::Deprecation do
4
+ it 'prints a warning' do
5
+ STDERR.should_receive(:puts).with("DEPRECATION WARNING: msg")
6
+ Rapns::Deprecation.warn("msg")
7
+ end
8
+
9
+ it 'does not print a warning when silenced' do
10
+ STDERR.should_not_receive(:puts)
11
+ Rapns::Deprecation.silenced do
12
+ Rapns::Deprecation.warn("msg")
13
+ end
14
+ end
15
+ end
@@ -31,7 +31,7 @@ shared_examples_for "an Notification subclass" do
31
31
  end
32
32
 
33
33
  it 'warns if attributes_for_device is assigned via mass-assignment' do
34
- ActiveSupport::Deprecation.should_receive(:warn)
34
+ Rapns::Deprecation.should_receive(:warn)
35
35
  notification_class.new(:attributes_for_device => {:hi => 'mom'})
36
36
  end
37
37
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rapns
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-15 00:00:00.000000000 Z
12
+ date: 2012-12-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: multi_json
@@ -92,6 +92,8 @@ files:
92
92
  - lib/rapns/daemon/gcm/delivery_handler.rb
93
93
  - lib/rapns/daemon/interruptible_sleep.rb
94
94
  - lib/rapns/daemon/logger.rb
95
+ - lib/rapns/deprecatable.rb
96
+ - lib/rapns/deprecation.rb
95
97
  - lib/rapns/gcm/app.rb
96
98
  - lib/rapns/gcm/expiry_collapse_key_mutual_inclusion_validator.rb
97
99
  - lib/rapns/gcm/notification.rb
@@ -133,6 +135,8 @@ files:
133
135
  - spec/unit/daemon/interruptible_sleep_spec.rb
134
136
  - spec/unit/daemon/logger_spec.rb
135
137
  - spec/unit/daemon_spec.rb
138
+ - spec/unit/deprecatable_spec.rb
139
+ - spec/unit/deprecation_spec.rb
136
140
  - spec/unit/gcm/app_spec.rb
137
141
  - spec/unit/gcm/notification_spec.rb
138
142
  - spec/unit/notification_shared.rb
@@ -193,6 +197,8 @@ test_files:
193
197
  - spec/unit/daemon/interruptible_sleep_spec.rb
194
198
  - spec/unit/daemon/logger_spec.rb
195
199
  - spec/unit/daemon_spec.rb
200
+ - spec/unit/deprecatable_spec.rb
201
+ - spec/unit/deprecation_spec.rb
196
202
  - spec/unit/gcm/app_spec.rb
197
203
  - spec/unit/gcm/notification_spec.rb
198
204
  - spec/unit/notification_shared.rb