rpush 2.3.2 → 2.4.0

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 (69) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +13 -0
  3. data/README.md +1 -1
  4. data/lib/generators/rpush_migration_generator.rb +21 -6
  5. data/lib/generators/templates/rpush.rb +5 -5
  6. data/lib/generators/templates/rpush_2_0_0_updates.rb +24 -0
  7. data/lib/rpush/client/active_model/apns/notification.rb +1 -1
  8. data/lib/rpush/client/mongoid.rb +31 -0
  9. data/lib/rpush/client/mongoid/adm/app.rb +14 -0
  10. data/lib/rpush/client/mongoid/adm/notification.rb +11 -0
  11. data/lib/rpush/client/mongoid/apns/app.rb +11 -0
  12. data/lib/rpush/client/mongoid/apns/feedback.rb +21 -0
  13. data/lib/rpush/client/mongoid/apns/notification.rb +15 -0
  14. data/lib/rpush/client/mongoid/app.rb +23 -0
  15. data/lib/rpush/client/mongoid/gcm/app.rb +11 -0
  16. data/lib/rpush/client/mongoid/gcm/notification.rb +11 -0
  17. data/lib/rpush/client/mongoid/notification.rb +43 -0
  18. data/lib/rpush/client/mongoid/wpns/app.rb +11 -0
  19. data/lib/rpush/client/mongoid/wpns/notification.rb +11 -0
  20. data/lib/rpush/client/redis.rb +2 -2
  21. data/lib/rpush/configuration.rb +48 -29
  22. data/lib/rpush/daemon/adm/delivery.rb +1 -1
  23. data/lib/rpush/daemon/apns.rb +1 -1
  24. data/lib/rpush/daemon/apns/feedback_receiver.rb +2 -3
  25. data/lib/rpush/daemon/dispatcher/apns_tcp.rb +2 -1
  26. data/lib/rpush/daemon/feeder.rb +4 -7
  27. data/lib/rpush/daemon/gcm/delivery.rb +1 -1
  28. data/lib/rpush/daemon/interruptible_sleep.rb +5 -50
  29. data/lib/rpush/daemon/proc_title.rb +2 -1
  30. data/lib/rpush/daemon/store/active_record.rb +4 -0
  31. data/lib/rpush/daemon/store/interface.rb +1 -1
  32. data/lib/rpush/daemon/store/mongoid.rb +157 -0
  33. data/lib/rpush/daemon/store/redis.rb +6 -2
  34. data/lib/rpush/deprecatable.rb +1 -2
  35. data/lib/rpush/deprecation.rb +6 -0
  36. data/lib/rpush/embed.rb +5 -0
  37. data/lib/rpush/logger.rb +5 -8
  38. data/lib/rpush/push.rb +5 -0
  39. data/lib/rpush/version.rb +1 -1
  40. data/lib/tasks/quality.rake +1 -1
  41. data/lib/tasks/test.rake +9 -4
  42. data/spec/functional/apns_spec.rb +2 -1
  43. data/spec/functional_spec_helper.rb +2 -2
  44. data/spec/spec_helper.rb +18 -7
  45. data/spec/support/config/mongoid.yml +69 -0
  46. data/spec/support/mongoid_setup.rb +10 -0
  47. data/spec/unit/client/active_record/adm/app_spec.rb +1 -1
  48. data/spec/unit/client/active_record/adm/notification_spec.rb +1 -1
  49. data/spec/unit/client/active_record/apns/app_spec.rb +1 -1
  50. data/spec/unit/client/active_record/apns/feedback_spec.rb +1 -1
  51. data/spec/unit/client/active_record/apns/notification_spec.rb +11 -11
  52. data/spec/unit/client/active_record/app_spec.rb +1 -1
  53. data/spec/unit/client/active_record/gcm/notification_spec.rb +1 -1
  54. data/spec/unit/client/active_record/notification_spec.rb +1 -1
  55. data/spec/unit/client/active_record/wpns/notification_spec.rb +1 -1
  56. data/spec/unit/configuration_spec.rb +7 -0
  57. data/spec/unit/daemon/apns/feedback_receiver_spec.rb +5 -5
  58. data/spec/unit/daemon/feeder_spec.rb +2 -2
  59. data/spec/unit/daemon/proc_title_spec.rb +11 -0
  60. data/spec/unit/daemon/store/active_record/reconnectable_spec.rb +1 -1
  61. data/spec/unit/daemon/store/active_record_spec.rb +21 -12
  62. data/spec/unit/daemon/store/mongoid_spec.rb +339 -0
  63. data/spec/unit/daemon/store/redis_spec.rb +365 -0
  64. data/spec/unit/embed_spec.rb +4 -2
  65. data/spec/unit/logger_spec.rb +14 -5
  66. data/spec/unit/notification_shared.rb +1 -1
  67. data/spec/unit/push_spec.rb +4 -2
  68. data/spec/unit_spec_helper.rb +3 -3
  69. metadata +25 -2
@@ -19,8 +19,10 @@ describe Rpush, 'embed' do
19
19
  end
20
20
 
21
21
  it 'overrides the default config options with those given as a hash' do
22
- Rpush.config.push_poll = 4
23
- expect { Rpush.embed(push_poll: 2) }.to change(Rpush.config, :push_poll).to(2)
22
+ Rpush::Deprecation.muted do
23
+ Rpush.config.push_poll = 4
24
+ expect { Rpush.embed(push_poll: 2) }.to change(Rpush.config, :push_poll).to(2)
25
+ end
24
26
  end
25
27
  end
26
28
 
@@ -5,11 +5,11 @@ module Rails
5
5
  end
6
6
 
7
7
  describe Rpush::Logger do
8
- let(:log) { double(:sync= => true) }
8
+ let(:log) { double(:sync= => true, :level= => nil) }
9
9
 
10
10
  before do
11
11
  @logger_class = defined?(ActiveSupport::BufferedLogger) ? ActiveSupport::BufferedLogger : ActiveSupport::Logger
12
- @logger = double(@logger_class.name, info: nil, error: nil, level: 0, auto_flushing: true, :auto_flushing= => nil)
12
+ @logger = double(@logger_class.name, info: nil, error: nil, level: 0, :level= => nil, auto_flushing: true, :auto_flushing= => nil)
13
13
  allow(@logger_class).to receive(:new).and_return(@logger)
14
14
  allow(Rails).to receive_messages(logger: @logger)
15
15
  allow(File).to receive_messages(open: log)
@@ -41,7 +41,7 @@ describe Rpush::Logger do
41
41
  end
42
42
 
43
43
  it 'uses the user-defined logger' do
44
- my_logger = double
44
+ my_logger = double(:level= => nil)
45
45
  Rpush.config.logger = my_logger
46
46
  logger = Rpush::Logger.new
47
47
  expect(my_logger).to receive(:info)
@@ -51,7 +51,7 @@ describe Rpush::Logger do
51
51
 
52
52
  it 'uses ActiveSupport::BufferedLogger if a user-defined logger is not set' do
53
53
  if ActiveSupport.const_defined?('BufferedLogger')
54
- expect(ActiveSupport::BufferedLogger).to receive(:new).with(log, Rails.logger.level)
54
+ expect(ActiveSupport::BufferedLogger).to receive(:new).with(log)
55
55
  Rpush::Logger.new
56
56
  end
57
57
  end
@@ -59,7 +59,16 @@ describe Rpush::Logger do
59
59
  it 'uses ActiveSupport::Logger if BufferedLogger does not exist' do
60
60
  stub_const('ActiveSupport::Logger', double)
61
61
  allow(ActiveSupport).to receive_messages(:const_defined? => false)
62
- expect(ActiveSupport::Logger).to receive(:new).with(log, Rails.logger.level)
62
+ expect(ActiveSupport::Logger).to receive(:new).with(log).and_return(log)
63
+ Rpush::Logger.new
64
+ end
65
+
66
+ it 'sets the log level on the logger' do
67
+ stub_const('ActiveSupport::Logger', double)
68
+ allow(ActiveSupport).to receive_messages(:const_defined? => false)
69
+ expect(ActiveSupport::Logger).to receive(:new).with(log).and_return(log)
70
+ Rpush.config.log_level = ::Logger::Severity::ERROR
71
+ expect(log).to receive(:level=).with(::Logger::Severity::ERROR)
63
72
  Rpush::Logger.new
64
73
  end
65
74
 
@@ -18,7 +18,7 @@ shared_examples_for "an Notification subclass" do
18
18
 
19
19
  it "raises an ArgumentError if something other than a Hash is assigned" do
20
20
  expect do
21
- notification.data = Array.new
21
+ notification.data = []
22
22
  end.to raise_error(ArgumentError, "must be a Hash")
23
23
  end
24
24
 
@@ -33,7 +33,9 @@ describe Rpush, 'push' do
33
33
  end
34
34
 
35
35
  it 'overrides the default config options with those given as a hash' do
36
- Rpush.config.batch_size = 20
37
- expect { Rpush.push(batch_size: 10) }.to change(Rpush.config, :batch_size).to(10)
36
+ Rpush::Deprecation.muted do
37
+ Rpush.config.batch_size = 20
38
+ expect { Rpush.push(batch_size: 10) }.to change(Rpush.config, :batch_size).to(10)
39
+ end
38
40
  end
39
41
  end
@@ -13,9 +13,9 @@ RSpec.configure do |config|
13
13
  config.before(:each) do
14
14
  Modis.with_connection do |redis|
15
15
  redis.keys('rpush:*').each { |key| redis.del(key) }
16
- end
16
+ end if redis?
17
17
 
18
- if unit_example?(self.class.metadata)
18
+ if active_record? && unit_example?(self.class.metadata)
19
19
  connection = ActiveRecord::Base.connection
20
20
 
21
21
  if rails4?
@@ -29,7 +29,7 @@ RSpec.configure do |config|
29
29
  end
30
30
 
31
31
  config.after(:each) do
32
- if unit_example?(self.class.metadata)
32
+ if active_record? && unit_example?(self.class.metadata)
33
33
  connection = ActiveRecord::Base.connection
34
34
 
35
35
  if rails4?
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rpush
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.2
4
+ version: 2.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ian Leitch
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-31 00:00:00.000000000 Z
11
+ date: 2015-02-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json
@@ -159,6 +159,18 @@ files:
159
159
  - lib/rpush/client/active_record/notification.rb
160
160
  - lib/rpush/client/active_record/wpns/app.rb
161
161
  - lib/rpush/client/active_record/wpns/notification.rb
162
+ - lib/rpush/client/mongoid.rb
163
+ - lib/rpush/client/mongoid/adm/app.rb
164
+ - lib/rpush/client/mongoid/adm/notification.rb
165
+ - lib/rpush/client/mongoid/apns/app.rb
166
+ - lib/rpush/client/mongoid/apns/feedback.rb
167
+ - lib/rpush/client/mongoid/apns/notification.rb
168
+ - lib/rpush/client/mongoid/app.rb
169
+ - lib/rpush/client/mongoid/gcm/app.rb
170
+ - lib/rpush/client/mongoid/gcm/notification.rb
171
+ - lib/rpush/client/mongoid/notification.rb
172
+ - lib/rpush/client/mongoid/wpns/app.rb
173
+ - lib/rpush/client/mongoid/wpns/notification.rb
162
174
  - lib/rpush/client/redis.rb
163
175
  - lib/rpush/client/redis/adm/app.rb
164
176
  - lib/rpush/client/redis/adm/notification.rb
@@ -203,6 +215,7 @@ files:
203
215
  - lib/rpush/daemon/store/active_record.rb
204
216
  - lib/rpush/daemon/store/active_record/reconnectable.rb
205
217
  - lib/rpush/daemon/store/interface.rb
218
+ - lib/rpush/daemon/store/mongoid.rb
206
219
  - lib/rpush/daemon/store/redis.rb
207
220
  - lib/rpush/daemon/string_helpers.rb
208
221
  - lib/rpush/daemon/synchronizer.rb
@@ -237,6 +250,8 @@ files:
237
250
  - spec/support/cert_with_password.pem
238
251
  - spec/support/cert_without_password.pem
239
252
  - spec/support/config/database.yml
253
+ - spec/support/config/mongoid.yml
254
+ - spec/support/mongoid_setup.rb
240
255
  - spec/support/simplecov_helper.rb
241
256
  - spec/support/simplecov_quality_formatter.rb
242
257
  - spec/tmp/.gitkeep
@@ -266,11 +281,14 @@ files:
266
281
  - spec/unit/daemon/dispatcher_loop_spec.rb
267
282
  - spec/unit/daemon/feeder_spec.rb
268
283
  - spec/unit/daemon/gcm/delivery_spec.rb
284
+ - spec/unit/daemon/proc_title_spec.rb
269
285
  - spec/unit/daemon/retryable_error_spec.rb
270
286
  - spec/unit/daemon/service_config_methods_spec.rb
271
287
  - spec/unit/daemon/signal_handler_spec.rb
272
288
  - spec/unit/daemon/store/active_record/reconnectable_spec.rb
273
289
  - spec/unit/daemon/store/active_record_spec.rb
290
+ - spec/unit/daemon/store/mongoid_spec.rb
291
+ - spec/unit/daemon/store/redis_spec.rb
274
292
  - spec/unit/daemon/tcp_connection_spec.rb
275
293
  - spec/unit/daemon/wpns/delivery_spec.rb
276
294
  - spec/unit/daemon_spec.rb
@@ -325,6 +343,8 @@ test_files:
325
343
  - spec/support/cert_with_password.pem
326
344
  - spec/support/cert_without_password.pem
327
345
  - spec/support/config/database.yml
346
+ - spec/support/config/mongoid.yml
347
+ - spec/support/mongoid_setup.rb
328
348
  - spec/support/simplecov_helper.rb
329
349
  - spec/support/simplecov_quality_formatter.rb
330
350
  - spec/tmp/.gitkeep
@@ -354,11 +374,14 @@ test_files:
354
374
  - spec/unit/daemon/dispatcher_loop_spec.rb
355
375
  - spec/unit/daemon/feeder_spec.rb
356
376
  - spec/unit/daemon/gcm/delivery_spec.rb
377
+ - spec/unit/daemon/proc_title_spec.rb
357
378
  - spec/unit/daemon/retryable_error_spec.rb
358
379
  - spec/unit/daemon/service_config_methods_spec.rb
359
380
  - spec/unit/daemon/signal_handler_spec.rb
360
381
  - spec/unit/daemon/store/active_record/reconnectable_spec.rb
361
382
  - spec/unit/daemon/store/active_record_spec.rb
383
+ - spec/unit/daemon/store/mongoid_spec.rb
384
+ - spec/unit/daemon/store/redis_spec.rb
362
385
  - spec/unit/daemon/tcp_connection_spec.rb
363
386
  - spec/unit/daemon/wpns/delivery_spec.rb
364
387
  - spec/unit/daemon_spec.rb