rapns 2.0.5 → 3.0.0.beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. data/lib/generators/rapns_generator.rb +1 -0
  2. data/lib/generators/templates/add_gcm.rb +86 -0
  3. data/lib/generators/templates/create_rapns_notifications.rb +1 -1
  4. data/lib/rapns/apns/app.rb +8 -0
  5. data/lib/rapns/apns/binary_notification_validator.rb +12 -0
  6. data/lib/rapns/apns/device_token_format_validator.rb +12 -0
  7. data/lib/rapns/apns/feedback.rb +14 -0
  8. data/lib/rapns/apns/notification.rb +84 -0
  9. data/lib/rapns/app.rb +5 -6
  10. data/lib/rapns/{config.rb → configuration.rb} +5 -5
  11. data/lib/rapns/daemon/apns/app_runner.rb +36 -0
  12. data/lib/rapns/daemon/apns/connection.rb +113 -0
  13. data/lib/rapns/daemon/apns/delivery.rb +63 -0
  14. data/lib/rapns/daemon/apns/delivery_handler.rb +21 -0
  15. data/lib/rapns/daemon/apns/disconnection_error.rb +20 -0
  16. data/lib/rapns/daemon/apns/feedback_receiver.rb +74 -0
  17. data/lib/rapns/daemon/app_runner.rb +76 -77
  18. data/lib/rapns/daemon/database_reconnectable.rb +3 -3
  19. data/lib/rapns/daemon/delivery.rb +43 -0
  20. data/lib/rapns/daemon/delivery_error.rb +6 -2
  21. data/lib/rapns/daemon/delivery_handler.rb +13 -79
  22. data/lib/rapns/daemon/delivery_queue_18.rb +2 -2
  23. data/lib/rapns/daemon/delivery_queue_19.rb +3 -3
  24. data/lib/rapns/daemon/feeder.rb +5 -5
  25. data/lib/rapns/daemon/gcm/app_runner.rb +13 -0
  26. data/lib/rapns/daemon/gcm/delivery.rb +206 -0
  27. data/lib/rapns/daemon/gcm/delivery_handler.rb +20 -0
  28. data/lib/rapns/daemon.rb +31 -20
  29. data/lib/rapns/gcm/app.rb +7 -0
  30. data/lib/rapns/gcm/expiry_collapse_key_mutual_inclusion_validator.rb +11 -0
  31. data/lib/rapns/gcm/notification.rb +31 -0
  32. data/lib/rapns/gcm/payload_size_validator.rb +13 -0
  33. data/lib/rapns/multi_json_helper.rb +16 -0
  34. data/lib/rapns/notification.rb +28 -95
  35. data/lib/rapns/version.rb +1 -1
  36. data/lib/rapns.rb +14 -4
  37. data/lib/tasks/cane.rake +19 -0
  38. data/lib/tasks/test.rake +34 -0
  39. data/spec/acceptance/gcm_upgrade_spec.rb +34 -0
  40. data/spec/acceptance_spec_helper.rb +85 -0
  41. data/spec/support/simplecov_helper.rb +13 -0
  42. data/spec/support/simplecov_quality_formatter.rb +8 -0
  43. data/spec/unit/apns/app_spec.rb +15 -0
  44. data/spec/unit/apns/feedback_spec.rb +12 -0
  45. data/spec/{rapns → unit/apns}/notification_spec.rb +44 -72
  46. data/spec/unit/app_spec.rb +18 -0
  47. data/spec/unit/daemon/apns/app_runner_spec.rb +37 -0
  48. data/spec/{rapns/daemon → unit/daemon/apns}/connection_spec.rb +9 -9
  49. data/spec/unit/daemon/apns/delivery_handler_spec.rb +48 -0
  50. data/spec/unit/daemon/apns/delivery_spec.rb +154 -0
  51. data/spec/{rapns/daemon → unit/daemon/apns}/feedback_receiver_spec.rb +14 -14
  52. data/spec/unit/daemon/app_runner_shared.rb +66 -0
  53. data/spec/unit/daemon/app_runner_spec.rb +78 -0
  54. data/spec/{rapns → unit}/daemon/database_reconnectable_spec.rb +4 -5
  55. data/spec/{rapns → unit}/daemon/delivery_error_spec.rb +2 -2
  56. data/spec/unit/daemon/delivery_handler_shared.rb +19 -0
  57. data/spec/{rapns → unit}/daemon/delivery_queue_spec.rb +1 -1
  58. data/spec/{rapns → unit}/daemon/feeder_spec.rb +33 -33
  59. data/spec/unit/daemon/gcm/app_runner_spec.rb +15 -0
  60. data/spec/unit/daemon/gcm/delivery_handler_spec.rb +36 -0
  61. data/spec/unit/daemon/gcm/delivery_spec.rb +236 -0
  62. data/spec/{rapns → unit}/daemon/interruptible_sleep_spec.rb +1 -1
  63. data/spec/{rapns → unit}/daemon/logger_spec.rb +1 -1
  64. data/spec/{rapns → unit}/daemon_spec.rb +1 -1
  65. data/spec/unit/gcm/app_spec.rb +5 -0
  66. data/spec/unit/gcm/notification_spec.rb +55 -0
  67. data/spec/unit/notification_shared.rb +38 -0
  68. data/spec/unit/notification_spec.rb +6 -0
  69. data/spec/{rapns/app_spec.rb → unit_spec_helper.rb} +76 -16
  70. metadata +107 -45
  71. data/lib/rapns/binary_notification_validator.rb +0 -10
  72. data/lib/rapns/daemon/connection.rb +0 -114
  73. data/lib/rapns/daemon/delivery_handler_pool.rb +0 -18
  74. data/lib/rapns/daemon/disconnection_error.rb +0 -14
  75. data/lib/rapns/daemon/feedback_receiver.rb +0 -82
  76. data/lib/rapns/device_token_format_validator.rb +0 -10
  77. data/lib/rapns/feedback.rb +0 -12
  78. data/spec/rapns/daemon/app_runner_spec.rb +0 -193
  79. data/spec/rapns/daemon/delivery_handler_pool_spec.rb +0 -17
  80. data/spec/rapns/daemon/delivery_handler_spec.rb +0 -206
  81. data/spec/rapns/feedback_spec.rb +0 -12
  82. data/spec/spec_helper.rb +0 -78
@@ -0,0 +1,236 @@
1
+ require 'unit_spec_helper'
2
+
3
+ describe Rapns::Daemon::Gcm::Delivery do
4
+ let(:app) { Rapns::Gcm::App.new(:name => 'MyApp', :auth_key => 'abc123') }
5
+ let(:notification) { Rapns::Gcm::Notification.create!(:app => app, :registration_ids => ['xyz']) }
6
+ let(:logger) { stub(:error => nil, :info => nil, :warn => nil) }
7
+ let(:response) { stub(:code => 200, :header => {}) }
8
+ let(:http) { stub(:shutdown => nil, :request => response)}
9
+ let(:now) { Time.parse('2012-10-14 00:00:00') }
10
+
11
+ def perform
12
+ Rapns::Daemon::Gcm::Delivery.perform(app, http, notification)
13
+ end
14
+
15
+ before do
16
+ Time.stub(:now => now)
17
+ Rapns::Daemon.stub(:logger => logger)
18
+ end
19
+
20
+ describe 'an 200 response' do
21
+ before do
22
+ response.stub(:code => 200)
23
+ end
24
+
25
+ it 'marks the notification as delivered if delivered successfully to all devices' do
26
+ response.stub(:body => JSON.dump({ 'failure' => 0 }))
27
+ expect do
28
+ perform
29
+ end.to change(notification, :delivered).to(true)
30
+ end
31
+
32
+ it 'logs that the notification was delivered' do
33
+ response.stub(:body => JSON.dump({ 'failure' => 0 }))
34
+ logger.should_receive(:info).with("[MyApp] 1 sent to xyz")
35
+ perform
36
+ end
37
+
38
+ it 'marks a notification as failed if any deliveries failed that cannot be retried.' do
39
+ body = {
40
+ 'failure' => 1,
41
+ 'success' => 1,
42
+ 'results' => [
43
+ { 'message_id' => '1:000' },
44
+ { 'error' => 'NotRegistered' }
45
+ ]}
46
+ response.stub(:body => JSON.dump(body))
47
+ perform rescue Rapns::DeliveryError
48
+ notification.reload
49
+ notification.failed.should be_true
50
+ notification.error_code = nil
51
+ notification.error_description = "Weee"
52
+ end
53
+
54
+ describe 'all deliveries returned Unavailable or InternalServerError' do
55
+ let(:body) {{
56
+ 'failure' => 2,
57
+ 'success' => 0,
58
+ 'results' => [
59
+ { 'error' => 'Unavailable' },
60
+ { 'error' => 'Unavailable' }
61
+ ]}}
62
+
63
+ before { response.stub(:body => JSON.dump(body)) }
64
+
65
+ it 'retries the notification respecting the Retry-After header' do
66
+ response.stub(:header => { 'retry-after' => 10 })
67
+ perform
68
+ notification.reload
69
+ notification.retries.should == 1
70
+ notification.deliver_after.should == now + 10.seconds
71
+ end
72
+
73
+ it 'retries the notification using exponential back-off if the Retry-After header is not present' do
74
+ notification.update_attribute(:retries, 8)
75
+ perform
76
+ notification.reload
77
+ notification.retries.should == 9
78
+ notification.deliver_after.should == now + 2 ** 9
79
+ end
80
+
81
+ it 'does not mark the notification as failed' do
82
+ expect do
83
+ perform
84
+ notification.reload
85
+ end.to_not change(notification, :failed).to(true)
86
+ end
87
+
88
+ it 'logs that the notification will be retried' do
89
+ Rapns::Daemon.logger.should_receive(:warn).with("All recipients unavailable. Notification #{notification.id} will be retired after 2012-10-14 00:00:02 (retry 1).")
90
+ perform
91
+ end
92
+ end
93
+
94
+ shared_examples_for 'an notification with some delivery failures' do
95
+ let(:new_notification) { Rapns::Gcm::Notification.where('id != ?', notification.id).first }
96
+
97
+ before { response.stub(:body => JSON.dump(body)) }
98
+
99
+ it 'marks the original notification as failed' do
100
+ perform rescue Rapns::DeliveryError
101
+ notification.reload
102
+ notification.failed.should be_true
103
+ notification.failed_at = now
104
+ notification.error_code.should be_nil
105
+ notification.error_description.should == error_description
106
+ end
107
+
108
+ it 'creates a new notification for the unavailable devices' do
109
+ notification.update_attributes(:registration_ids => ['id_0', 'id_1', 'id_2'], :data => {'one' => 1}, :collapse_key => 'thing', :delay_while_idle => true)
110
+ perform rescue Rapns::DeliveryError
111
+ new_notification.registration_ids.should == ['id_0', 'id_2']
112
+ new_notification.data.should == {'one' => 1}
113
+ new_notification.collapse_key.should == 'thing'
114
+ new_notification.delay_while_idle.should be_true
115
+ end
116
+
117
+ it 'sets the delivery time on the new notification to respect the Retry-After header' do
118
+ response.stub(:header => { 'retry-after' => 10 })
119
+ perform rescue Rapns::DeliveryError
120
+ new_notification.deliver_after.should == now + 10.seconds
121
+ end
122
+
123
+ it 'raises a DeliveryError' do
124
+ expect { perform }.to raise_error(Rapns::DeliveryError)
125
+ end
126
+ end
127
+
128
+ describe 'all deliveries failed with some as Unavailable or InternalServerError' do
129
+ let(:body) {{
130
+ 'failure' => 3,
131
+ 'success' => 0,
132
+ 'results' => [
133
+ { 'error' => 'Unavailable' },
134
+ { 'error' => 'NotRegistered' },
135
+ { 'error' => 'Unavailable' }
136
+ ]}}
137
+ let(:error_description) { "Failed to deliver to recipients 0, 1, 2. Errors: Unavailable, NotRegistered, Unavailable. 0, 2 will be retried as notification 2." }
138
+ it_should_behave_like 'an notification with some delivery failures'
139
+ end
140
+ end
141
+
142
+ describe 'some deliveries failed with Unavailable or InternalServerError' do
143
+ let(:body) {{
144
+ 'failure' => 2,
145
+ 'success' => 1,
146
+ 'results' => [
147
+ { 'error' => 'Unavailable' },
148
+ { 'message_id' => '1:000' },
149
+ { 'error' => 'InternalServerError' }
150
+ ]}}
151
+ let(:error_description) { "Failed to deliver to recipients 0, 2. Errors: Unavailable, InternalServerError. 0, 2 will be retried as notification 2." }
152
+ it_should_behave_like 'an notification with some delivery failures'
153
+ end
154
+
155
+ describe 'an 503 response' do
156
+ before { response.stub(:code => 503) }
157
+
158
+ it 'logs a warning that the notification will be retried.' do
159
+ logger.should_receive(:warn).with("GCM responded with an Service Unavailable Error. Notification 1 will be retired after 2012-10-14 00:00:02 (retry 1).")
160
+ perform
161
+ end
162
+
163
+ it 'respects an integer Retry-After header' do
164
+ response.stub(:header => { 'retry-after' => 10 })
165
+ expect do
166
+ perform
167
+ end.to change(notification, :deliver_after).to(now + 10)
168
+ end
169
+
170
+ it 'respects a HTTP-date Retry-After header' do
171
+ response.stub(:header => { 'retry-after' => 'Wed, 03 Oct 2012 20:55:11 GMT' })
172
+ expect do
173
+ perform
174
+ end.to change(notification, :deliver_after).to(Time.parse('Wed, 03 Oct 2012 20:55:11 GMT'))
175
+ end
176
+
177
+ it 'defaults to exponential back-off if the Retry-After header is not present' do
178
+ expect do
179
+ perform
180
+ end.to change(notification, :deliver_after).to(now + 2 ** 1)
181
+ end
182
+ end
183
+
184
+ describe 'an 500 response' do
185
+ before do
186
+ notification.update_attribute(:retries, 2)
187
+ response.stub(:code => 500)
188
+ end
189
+
190
+ it 'logs a warning that the notification has been re-queued.' do
191
+ Rapns::Daemon.logger.should_receive(:warn).with("GCM responded with an Internal Error. Notification #{notification.id} will be retired after #{(now + 2 ** 3).strftime("%Y-%m-%d %H:%M:%S")} (retry 3).")
192
+ perform
193
+ end
194
+
195
+ it 'sets deliver_after on the notification in accordance with the exponential back-off strategy.' do
196
+ expect do
197
+ perform
198
+ notification.reload
199
+ end.to change(notification, :deliver_after).to(now + 2 ** 3)
200
+ end
201
+ end
202
+
203
+ describe 'an 401 response' do
204
+ before { response.stub(:code => 401) }
205
+
206
+ it 'raises an error' do
207
+ expect { perform }.to raise_error(Rapns::DeliveryError)
208
+ end
209
+ end
210
+
211
+ describe 'an 400 response' do
212
+ before { response.stub(:code => 400) }
213
+
214
+ it 'marks the notification as failed' do
215
+ perform rescue Rapns::DeliveryError
216
+ notification.reload
217
+ notification.failed.should be_true
218
+ notification.failed_at.should == now
219
+ notification.error_code.should == 400
220
+ notification.error_description.should == 'GCM failed to parse the JSON request. Possibly an rapns bug, please open an issue.'
221
+ end
222
+ end
223
+
224
+ describe 'an un-handled response' do
225
+ before { response.stub(:code => 418) }
226
+
227
+ it 'marks the notification as failed' do
228
+ perform rescue Rapns::DeliveryError
229
+ notification.reload
230
+ notification.failed.should be_true
231
+ notification.failed_at.should == now
232
+ notification.error_code.should == 418
233
+ notification.error_description.should == "I'm a Teapot"
234
+ end
235
+ end
236
+ end
@@ -1,4 +1,4 @@
1
- require "spec_helper"
1
+ require "unit_spec_helper"
2
2
 
3
3
  describe Rapns::Daemon::InterruptibleSleep do
4
4
  class SleepTest
@@ -1,4 +1,4 @@
1
- require "spec_helper"
1
+ require "unit_spec_helper"
2
2
 
3
3
  module Rails
4
4
  def self.logger
@@ -1,4 +1,4 @@
1
- require "spec_helper"
1
+ require "unit_spec_helper"
2
2
 
3
3
  describe Rapns::Daemon, "when starting" do
4
4
  module Rails; end
@@ -0,0 +1,5 @@
1
+ require 'unit_spec_helper'
2
+
3
+ describe Rapns::Gcm::App do
4
+ it { should validate_presence_of(:auth_key) }
5
+ end
@@ -0,0 +1,55 @@
1
+ require 'unit_spec_helper'
2
+ require 'unit/notification_shared.rb'
3
+
4
+ describe Rapns::Gcm::Notification do
5
+ it_should_behave_like 'an Notification subclass'
6
+
7
+ let(:app) { Rapns::Gcm::App.create!(:name => 'test', :auth_key => 'abc') }
8
+ let(:notification_class) { Rapns::Gcm::Notification }
9
+ let(:notification) { notification_class.new }
10
+ let(:data_setter) { 'data=' }
11
+ let(:data_getter) { 'data' }
12
+
13
+ it { should validate_presence_of :registration_ids }
14
+
15
+ it 'has a payload limit of 4096 bytes' do
16
+ notification.data = { :key => "a" * 4096 }
17
+ notification.valid?.should be_false
18
+ notification.errors[:base].should == ["GCM notification payload cannot be larger than 4096 bytes."]
19
+ end
20
+
21
+ it 'allows assignment of many registration IDs' do
22
+ notification.app = app
23
+ notification.registration_ids = ['a', 'b']
24
+ notification.save!
25
+ reloaded_notification = notification_class.find(notification.id)
26
+ reloaded_notification.registration_ids.should == ['a', 'b']
27
+ end
28
+
29
+ it 'allows assignment of a single registration ID' do
30
+ notification.app = app
31
+ notification.registration_ids = 'a'
32
+ notification.save!
33
+ reloaded_notification = notification_class.find(notification.id)
34
+ reloaded_notification.registration_ids.should == ['a']
35
+ end
36
+
37
+ it 'validates expiry is present if collapse_key is set' do
38
+ notification.collapse_key = 'test'
39
+ notification.expiry = nil
40
+ notification.valid?.should be_false
41
+ notification.errors[:expiry].should == ['must be set when using a collapse_key']
42
+ end
43
+
44
+ it 'does not include time_to_live in the payload if collapse_key is not set' do
45
+ notification.expiry = 100
46
+ notification.collapse_key = nil
47
+ notification.as_json.key?('time_to_live').should be_false
48
+ end
49
+
50
+ it 'includes time_to_live in the payload if collapse_key is set' do
51
+ notification.expiry = 100
52
+ notification.collapse_key = 'sync'
53
+ notification.as_json['time_to_live'].should == 100
54
+ end
55
+ end
@@ -0,0 +1,38 @@
1
+ shared_examples_for "an Notification subclass" do
2
+ describe "when assigning data for the device" do
3
+ it "calls MultiJson.dump when multi_json responds to :dump" do
4
+ notification = notification_class.new
5
+ MultiJson.stub(:respond_to?).with(:dump).and_return(true)
6
+ MultiJson.should_receive(:dump).with(any_args())
7
+ notification.send(data_setter, { :pirates => 1 })
8
+ end
9
+
10
+ it "calls MultiJson.encode when multi_json does not respond to :dump" do
11
+ notification = notification_class.new
12
+ MultiJson.stub(:respond_to?).with(:dump).and_return(false)
13
+ MultiJson.should_receive(:encode).with(any_args())
14
+ notification.send(data_setter, { :ninjas => 1 })
15
+ end
16
+
17
+ it "raises an ArgumentError if something other than a Hash is assigned" do
18
+ expect do
19
+ notification.send(data_setter, Array.new)
20
+ end.to raise_error(ArgumentError, "must be a Hash")
21
+ end
22
+
23
+ it "encodes the given Hash as JSON" do
24
+ notification.send(data_setter, { :hi => "mom" })
25
+ notification.read_attribute(:data).should == "{\"hi\":\"mom\"}"
26
+ end
27
+
28
+ it "decodes the JSON when using the reader method" do
29
+ notification.send(data_setter, { :hi => "mom" })
30
+ notification.send(data_getter).should == {"hi" => "mom"}
31
+ end
32
+
33
+ it 'warns if attributes_for_device is assigned via mass-assignment' do
34
+ ActiveSupport::Deprecation.should_receive(:warn)
35
+ notification_class.new(:attributes_for_device => {:hi => 'mom'})
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,6 @@
1
+ require "unit_spec_helper"
2
+
3
+ describe Rapns::Notification do
4
+ it { should validate_numericality_of(:expiry) }
5
+ it { should validate_presence_of(:app) }
6
+ end
@@ -1,5 +1,80 @@
1
- require "spec_helper"
1
+ ENV['RAILS_ENV'] = 'test'
2
2
 
3
+ begin
4
+ require './spec/support/simplecov_helper'
5
+ include SimpleCovHelper
6
+ start_simple_cov('unit')
7
+ rescue LoadError
8
+ puts "Coverage disabled."
9
+ end
10
+
11
+ require 'active_record'
12
+
13
+ jruby = defined?(RUBY_ENGINE) && RUBY_ENGINE == 'jruby'
14
+
15
+ $adapter = ENV['ADAPTER'] ||
16
+ if jruby
17
+ 'jdbcpostgresql'
18
+ else
19
+ 'postgresql'
20
+ end
21
+
22
+ DATABASE_CONFIG = YAML.load_file(File.expand_path("../config/database.yml", File.dirname(__FILE__)))
23
+
24
+ if DATABASE_CONFIG[$adapter].nil?
25
+ puts "No such adapter '#{$adapter}'. Valid adapters are #{DATABASE_CONFIG.keys.join(', ')}."
26
+ exit 1
27
+ end
28
+
29
+ if ENV['TRAVIS']
30
+ DATABASE_CONFIG[$adapter]['username'] = 'postgres'
31
+ else
32
+ require 'etc'
33
+ DATABASE_CONFIG[$adapter]['username'] = Etc.getlogin
34
+ end
35
+
36
+ puts "Using #{$adapter} adapter."
37
+
38
+ ActiveRecord::Base.establish_connection(DATABASE_CONFIG[$adapter])
39
+
40
+ require 'generators/templates/create_rapns_notifications'
41
+ require 'generators/templates/create_rapns_feedback'
42
+ require 'generators/templates/add_alert_is_json_to_rapns_notifications'
43
+ require 'generators/templates/add_app_to_rapns'
44
+ require 'generators/templates/create_rapns_apps'
45
+ require 'generators/templates/add_gcm'
46
+
47
+ [CreateRapnsNotifications, CreateRapnsFeedback,
48
+ AddAlertIsJsonToRapnsNotifications, AddAppToRapns, CreateRapnsApps, AddGcm].each do |migration|
49
+ migration.down rescue ActiveRecord::StatementInvalid
50
+ migration.up
51
+ end
52
+
53
+ require 'bundler'
54
+ Bundler.require(:default)
55
+
56
+ require 'shoulda'
57
+ require 'database_cleaner'
58
+
59
+ DatabaseCleaner.strategy = :truncation
60
+
61
+ require 'rapns'
62
+ require 'rapns/daemon'
63
+
64
+ Rapns::Notification.reset_column_information
65
+ Rapns::App.reset_column_information
66
+ Rapns::Apns::Feedback.reset_column_information
67
+
68
+ RSpec.configure do |config|
69
+ # config.before :suite do
70
+ # PerfTools::CpuProfiler.start('/tmp/rapns_profile')
71
+ # end
72
+ # config.after :suite do
73
+ # PerfTools::CpuProfiler.stop
74
+ # end
75
+
76
+ config.before(:each) { DatabaseCleaner.clean }
77
+ end
3
78
 
4
79
  # a test certificate that contains both an X509 certificate and
5
80
  # a private key, similar to those used for connecting to Apple
@@ -72,18 +147,3 @@ jxWqQiPAdJtb3xKryJSCMtFPH9azedoCrSgaMflJ1QgoXgpiKZyoEXWraVUggh/0
72
147
  CEavgZcTZ6SvMuayqJdGGB+zb1V8XwXMtCjApR/kTm47DjxO4DmpOPs=
73
148
  -----END RSA PRIVATE KEY-----
74
149
  EOF
75
-
76
-
77
- describe Rapns::App do
78
-
79
- it "does not validate an app with an invalid certificate" do
80
- @app = Rapns::App.new :key => 'test', :environment => 'development', :certificate => 'foo'
81
- @app.should_not be_valid
82
- @app.errors.should include(:certificate)
83
- end
84
-
85
- it "does validate a real certificate" do
86
- @app = Rapns::App.new :key => 'test', :environment => 'development', :certificate => TEST_CERT
87
- @app.should be_valid
88
- end
89
- end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rapns
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.5
5
- prerelease:
4
+ version: 3.0.0.beta.1
5
+ prerelease: 6
6
6
  platform: ruby
7
7
  authors:
8
8
  - Ian Leitch
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-04 00:00:00.000000000 Z
12
+ date: 2012-12-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: multi_json
@@ -27,6 +27,22 @@ dependencies:
27
27
  - - ~>
28
28
  - !ruby/object:Gem::Version
29
29
  version: '1.0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: net-http-persistent
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
30
46
  description: Easy to use, full featured APNs daemon for Rails 3
31
47
  email:
32
48
  - port001@gmail.com
@@ -41,52 +57,83 @@ files:
41
57
  - lib/generators/rapns_generator.rb
42
58
  - lib/generators/templates/add_alert_is_json_to_rapns_notifications.rb
43
59
  - lib/generators/templates/add_app_to_rapns.rb
60
+ - lib/generators/templates/add_gcm.rb
44
61
  - lib/generators/templates/create_rapns_apps.rb
45
62
  - lib/generators/templates/create_rapns_feedback.rb
46
63
  - lib/generators/templates/create_rapns_notifications.rb
47
64
  - lib/rapns.rb
65
+ - lib/rapns/apns/app.rb
66
+ - lib/rapns/apns/binary_notification_validator.rb
67
+ - lib/rapns/apns/device_token_format_validator.rb
68
+ - lib/rapns/apns/feedback.rb
69
+ - lib/rapns/apns/notification.rb
48
70
  - lib/rapns/app.rb
49
- - lib/rapns/binary_notification_validator.rb
50
- - lib/rapns/config.rb
71
+ - lib/rapns/configuration.rb
51
72
  - lib/rapns/daemon.rb
73
+ - lib/rapns/daemon/apns/app_runner.rb
74
+ - lib/rapns/daemon/apns/connection.rb
75
+ - lib/rapns/daemon/apns/delivery.rb
76
+ - lib/rapns/daemon/apns/delivery_handler.rb
77
+ - lib/rapns/daemon/apns/disconnection_error.rb
78
+ - lib/rapns/daemon/apns/feedback_receiver.rb
52
79
  - lib/rapns/daemon/app_runner.rb
53
- - lib/rapns/daemon/connection.rb
54
80
  - lib/rapns/daemon/database_reconnectable.rb
81
+ - lib/rapns/daemon/delivery.rb
55
82
  - lib/rapns/daemon/delivery_error.rb
56
83
  - lib/rapns/daemon/delivery_handler.rb
57
- - lib/rapns/daemon/delivery_handler_pool.rb
58
84
  - lib/rapns/daemon/delivery_queue.rb
59
85
  - lib/rapns/daemon/delivery_queue_18.rb
60
86
  - lib/rapns/daemon/delivery_queue_19.rb
61
- - lib/rapns/daemon/disconnection_error.rb
62
- - lib/rapns/daemon/feedback_receiver.rb
63
87
  - lib/rapns/daemon/feeder.rb
88
+ - lib/rapns/daemon/gcm/app_runner.rb
89
+ - lib/rapns/daemon/gcm/delivery.rb
90
+ - lib/rapns/daemon/gcm/delivery_handler.rb
64
91
  - lib/rapns/daemon/interruptible_sleep.rb
65
92
  - lib/rapns/daemon/logger.rb
66
- - lib/rapns/device_token_format_validator.rb
67
- - lib/rapns/feedback.rb
93
+ - lib/rapns/gcm/app.rb
94
+ - lib/rapns/gcm/expiry_collapse_key_mutual_inclusion_validator.rb
95
+ - lib/rapns/gcm/notification.rb
96
+ - lib/rapns/gcm/payload_size_validator.rb
97
+ - lib/rapns/multi_json_helper.rb
68
98
  - lib/rapns/notification.rb
69
99
  - lib/rapns/patches.rb
70
100
  - lib/rapns/patches/rails/3.1.0/postgresql_adapter.rb
71
101
  - lib/rapns/patches/rails/3.1.1/postgresql_adapter.rb
72
102
  - lib/rapns/version.rb
103
+ - lib/tasks/cane.rake
104
+ - lib/tasks/test.rake
73
105
  - config/database.yml
74
- - spec/rapns/app_spec.rb
75
- - spec/rapns/daemon/app_runner_spec.rb
76
- - spec/rapns/daemon/connection_spec.rb
77
- - spec/rapns/daemon/database_reconnectable_spec.rb
78
- - spec/rapns/daemon/delivery_error_spec.rb
79
- - spec/rapns/daemon/delivery_handler_pool_spec.rb
80
- - spec/rapns/daemon/delivery_handler_spec.rb
81
- - spec/rapns/daemon/delivery_queue_spec.rb
82
- - spec/rapns/daemon/feedback_receiver_spec.rb
83
- - spec/rapns/daemon/feeder_spec.rb
84
- - spec/rapns/daemon/interruptible_sleep_spec.rb
85
- - spec/rapns/daemon/logger_spec.rb
86
- - spec/rapns/daemon_spec.rb
87
- - spec/rapns/feedback_spec.rb
88
- - spec/rapns/notification_spec.rb
89
- - spec/spec_helper.rb
106
+ - spec/acceptance/gcm_upgrade_spec.rb
107
+ - spec/acceptance_spec_helper.rb
108
+ - spec/support/simplecov_helper.rb
109
+ - spec/support/simplecov_quality_formatter.rb
110
+ - spec/unit/apns/app_spec.rb
111
+ - spec/unit/apns/feedback_spec.rb
112
+ - spec/unit/apns/notification_spec.rb
113
+ - spec/unit/app_spec.rb
114
+ - spec/unit/daemon/apns/app_runner_spec.rb
115
+ - spec/unit/daemon/apns/connection_spec.rb
116
+ - spec/unit/daemon/apns/delivery_handler_spec.rb
117
+ - spec/unit/daemon/apns/delivery_spec.rb
118
+ - spec/unit/daemon/apns/feedback_receiver_spec.rb
119
+ - spec/unit/daemon/app_runner_shared.rb
120
+ - spec/unit/daemon/app_runner_spec.rb
121
+ - spec/unit/daemon/database_reconnectable_spec.rb
122
+ - spec/unit/daemon/delivery_error_spec.rb
123
+ - spec/unit/daemon/delivery_handler_shared.rb
124
+ - spec/unit/daemon/delivery_queue_spec.rb
125
+ - spec/unit/daemon/feeder_spec.rb
126
+ - spec/unit/daemon/gcm/app_runner_spec.rb
127
+ - spec/unit/daemon/gcm/delivery_handler_spec.rb
128
+ - spec/unit/daemon/gcm/delivery_spec.rb
129
+ - spec/unit/daemon/interruptible_sleep_spec.rb
130
+ - spec/unit/daemon/logger_spec.rb
131
+ - spec/unit/daemon_spec.rb
132
+ - spec/unit/gcm/app_spec.rb
133
+ - spec/unit/gcm/notification_spec.rb
134
+ - spec/unit/notification_shared.rb
135
+ - spec/unit/notification_spec.rb
136
+ - spec/unit_spec_helper.rb
90
137
  - bin/rapns
91
138
  homepage: https://github.com/ileitch/rapns
92
139
  licenses: []
@@ -103,9 +150,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
103
150
  required_rubygems_version: !ruby/object:Gem::Requirement
104
151
  none: false
105
152
  requirements:
106
- - - ! '>='
153
+ - - ! '>'
107
154
  - !ruby/object:Gem::Version
108
- version: '0'
155
+ version: 1.3.1
109
156
  requirements: []
110
157
  rubyforge_project:
111
158
  rubygems_version: 1.8.23
@@ -114,19 +161,34 @@ specification_version: 3
114
161
  summary: Easy to use, full featured APNs daemon for Rails 3
115
162
  test_files:
116
163
  - config/database.yml
117
- - spec/rapns/app_spec.rb
118
- - spec/rapns/daemon/app_runner_spec.rb
119
- - spec/rapns/daemon/connection_spec.rb
120
- - spec/rapns/daemon/database_reconnectable_spec.rb
121
- - spec/rapns/daemon/delivery_error_spec.rb
122
- - spec/rapns/daemon/delivery_handler_pool_spec.rb
123
- - spec/rapns/daemon/delivery_handler_spec.rb
124
- - spec/rapns/daemon/delivery_queue_spec.rb
125
- - spec/rapns/daemon/feedback_receiver_spec.rb
126
- - spec/rapns/daemon/feeder_spec.rb
127
- - spec/rapns/daemon/interruptible_sleep_spec.rb
128
- - spec/rapns/daemon/logger_spec.rb
129
- - spec/rapns/daemon_spec.rb
130
- - spec/rapns/feedback_spec.rb
131
- - spec/rapns/notification_spec.rb
132
- - spec/spec_helper.rb
164
+ - spec/acceptance/gcm_upgrade_spec.rb
165
+ - spec/acceptance_spec_helper.rb
166
+ - spec/support/simplecov_helper.rb
167
+ - spec/support/simplecov_quality_formatter.rb
168
+ - spec/unit/apns/app_spec.rb
169
+ - spec/unit/apns/feedback_spec.rb
170
+ - spec/unit/apns/notification_spec.rb
171
+ - spec/unit/app_spec.rb
172
+ - spec/unit/daemon/apns/app_runner_spec.rb
173
+ - spec/unit/daemon/apns/connection_spec.rb
174
+ - spec/unit/daemon/apns/delivery_handler_spec.rb
175
+ - spec/unit/daemon/apns/delivery_spec.rb
176
+ - spec/unit/daemon/apns/feedback_receiver_spec.rb
177
+ - spec/unit/daemon/app_runner_shared.rb
178
+ - spec/unit/daemon/app_runner_spec.rb
179
+ - spec/unit/daemon/database_reconnectable_spec.rb
180
+ - spec/unit/daemon/delivery_error_spec.rb
181
+ - spec/unit/daemon/delivery_handler_shared.rb
182
+ - spec/unit/daemon/delivery_queue_spec.rb
183
+ - spec/unit/daemon/feeder_spec.rb
184
+ - spec/unit/daemon/gcm/app_runner_spec.rb
185
+ - spec/unit/daemon/gcm/delivery_handler_spec.rb
186
+ - spec/unit/daemon/gcm/delivery_spec.rb
187
+ - spec/unit/daemon/interruptible_sleep_spec.rb
188
+ - spec/unit/daemon/logger_spec.rb
189
+ - spec/unit/daemon_spec.rb
190
+ - spec/unit/gcm/app_spec.rb
191
+ - spec/unit/gcm/notification_spec.rb
192
+ - spec/unit/notification_shared.rb
193
+ - spec/unit/notification_spec.rb
194
+ - spec/unit_spec_helper.rb