rpush 1.0.0 → 2.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (193) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +13 -0
  3. data/README.md +12 -14
  4. data/bin/rpush +11 -2
  5. data/lib/generators/rpush_generator.rb +2 -0
  6. data/lib/generators/templates/add_adm.rb +5 -5
  7. data/lib/generators/templates/add_alert_is_json_to_rapns_notifications.rb +1 -1
  8. data/lib/generators/templates/add_app_to_rapns.rb +2 -2
  9. data/lib/generators/templates/add_fail_after_to_rpush_notifications.rb +1 -1
  10. data/lib/generators/templates/add_gcm.rb +32 -32
  11. data/lib/generators/templates/add_rpush.rb +67 -67
  12. data/lib/generators/templates/add_wpns.rb +2 -2
  13. data/lib/generators/templates/create_rapns_apps.rb +5 -5
  14. data/lib/generators/templates/create_rapns_feedback.rb +2 -2
  15. data/lib/generators/templates/create_rapns_notifications.rb +15 -15
  16. data/lib/generators/templates/rpush.rb +10 -7
  17. data/lib/generators/templates/rpush_2_0_0_updates.rb +23 -0
  18. data/lib/rpush.rb +4 -28
  19. data/lib/rpush/client/active_model.rb +21 -0
  20. data/lib/rpush/client/active_model/adm/app.rb +23 -0
  21. data/lib/rpush/client/active_model/adm/data_validator.rb +14 -0
  22. data/lib/rpush/client/active_model/adm/notification.rb +28 -0
  23. data/lib/rpush/client/active_model/apns/app.rb +37 -0
  24. data/lib/rpush/client/active_model/apns/binary_notification_validator.rb +16 -0
  25. data/lib/rpush/client/active_model/apns/device_token_format_validator.rb +14 -0
  26. data/lib/rpush/client/active_model/apns/notification.rb +90 -0
  27. data/lib/rpush/client/active_model/gcm/app.rb +19 -0
  28. data/lib/rpush/client/active_model/gcm/expiry_collapse_key_mutual_inclusion_validator.rb +14 -0
  29. data/lib/rpush/client/active_model/gcm/notification.rb +31 -0
  30. data/lib/rpush/client/active_model/notification.rb +26 -0
  31. data/lib/rpush/client/active_model/payload_data_size_validator.rb +13 -0
  32. data/lib/rpush/client/active_model/registration_ids_count_validator.rb +13 -0
  33. data/lib/rpush/client/active_model/wpns/app.rb +13 -0
  34. data/lib/rpush/client/active_model/wpns/notification.rb +17 -0
  35. data/lib/rpush/client/active_record.rb +19 -0
  36. data/lib/rpush/client/active_record/adm/app.rb +11 -0
  37. data/lib/rpush/client/active_record/adm/notification.rb +11 -0
  38. data/lib/rpush/client/active_record/apns/app.rb +11 -0
  39. data/lib/rpush/client/active_record/apns/feedback.rb +20 -0
  40. data/lib/rpush/client/active_record/apns/notification.rb +46 -0
  41. data/lib/rpush/client/active_record/app.rb +17 -0
  42. data/lib/rpush/client/active_record/gcm/app.rb +11 -0
  43. data/lib/rpush/client/active_record/gcm/notification.rb +11 -0
  44. data/lib/rpush/client/active_record/notification.rb +38 -0
  45. data/lib/rpush/client/active_record/wpns/app.rb +11 -0
  46. data/lib/rpush/client/active_record/wpns/notification.rb +11 -0
  47. data/lib/rpush/client/redis.rb +35 -0
  48. data/lib/rpush/client/redis/adm/app.rb +14 -0
  49. data/lib/rpush/client/redis/adm/notification.rb +11 -0
  50. data/lib/rpush/client/redis/apns/app.rb +11 -0
  51. data/lib/rpush/client/redis/apns/feedback.rb +20 -0
  52. data/lib/rpush/client/redis/apns/notification.rb +11 -0
  53. data/lib/rpush/client/redis/app.rb +22 -0
  54. data/lib/rpush/client/redis/gcm/app.rb +11 -0
  55. data/lib/rpush/client/redis/gcm/notification.rb +11 -0
  56. data/lib/rpush/client/redis/notification.rb +68 -0
  57. data/lib/rpush/client/redis/wpns/app.rb +11 -0
  58. data/lib/rpush/client/redis/wpns/notification.rb +11 -0
  59. data/lib/rpush/configuration.rb +27 -6
  60. data/lib/rpush/daemon.rb +36 -56
  61. data/lib/rpush/daemon/adm/delivery.rb +50 -52
  62. data/lib/rpush/daemon/apns.rb +6 -5
  63. data/lib/rpush/daemon/apns/delivery.rb +20 -44
  64. data/lib/rpush/daemon/apns/feedback_receiver.rb +11 -8
  65. data/lib/rpush/daemon/app_runner.rb +67 -60
  66. data/lib/rpush/daemon/batch.rb +54 -40
  67. data/lib/rpush/daemon/delivery.rb +13 -3
  68. data/lib/rpush/daemon/delivery_error.rb +10 -2
  69. data/lib/rpush/daemon/dispatcher/apns_tcp.rb +106 -0
  70. data/lib/rpush/daemon/dispatcher/http.rb +3 -3
  71. data/lib/rpush/daemon/dispatcher/tcp.rb +3 -3
  72. data/lib/rpush/daemon/dispatcher_loop.rb +15 -6
  73. data/lib/rpush/daemon/errors.rb +18 -0
  74. data/lib/rpush/daemon/feeder.rb +28 -39
  75. data/lib/rpush/daemon/gcm/delivery.rb +19 -20
  76. data/lib/rpush/daemon/interruptible_sleep.rb +26 -45
  77. data/lib/rpush/daemon/loggable.rb +2 -4
  78. data/lib/rpush/daemon/proc_title.rb +16 -0
  79. data/lib/rpush/daemon/queue_payload.rb +12 -0
  80. data/lib/rpush/daemon/reflectable.rb +3 -5
  81. data/lib/rpush/daemon/retry_header_parser.rb +6 -6
  82. data/lib/rpush/daemon/ring_buffer.rb +16 -0
  83. data/lib/rpush/daemon/service_config_methods.rb +23 -7
  84. data/lib/rpush/daemon/signal_handler.rb +51 -0
  85. data/lib/rpush/daemon/store/active_record.rb +71 -38
  86. data/lib/rpush/daemon/store/active_record/reconnectable.rb +15 -15
  87. data/lib/rpush/daemon/store/interface.rb +19 -0
  88. data/lib/rpush/daemon/store/redis.rb +149 -0
  89. data/lib/rpush/daemon/tcp_connection.rb +6 -11
  90. data/lib/rpush/daemon/wpns/delivery.rb +21 -30
  91. data/lib/rpush/deprecatable.rb +4 -3
  92. data/lib/rpush/deprecation.rb +7 -10
  93. data/lib/rpush/embed.rb +7 -2
  94. data/lib/rpush/logger.rb +11 -15
  95. data/lib/rpush/push.rb +0 -1
  96. data/lib/rpush/reflection.rb +6 -12
  97. data/lib/rpush/version.rb +1 -1
  98. data/lib/tasks/quality.rake +34 -0
  99. data/spec/.rubocop.yml +4 -0
  100. data/spec/functional/adm_spec.rb +3 -6
  101. data/spec/functional/apns_spec.rb +118 -24
  102. data/spec/functional/embed_spec.rb +22 -20
  103. data/spec/functional/gcm_spec.rb +4 -7
  104. data/spec/functional/new_app_spec.rb +61 -0
  105. data/spec/functional/retry_spec.rb +46 -0
  106. data/spec/functional/wpns_spec.rb +3 -6
  107. data/spec/functional_spec_helper.rb +26 -0
  108. data/spec/integration/rpush_spec.rb +13 -0
  109. data/spec/integration/support/gcm_success_response.json +1 -0
  110. data/spec/spec_helper.rb +60 -0
  111. data/spec/support/active_record_setup.rb +48 -0
  112. data/{config → spec/support/config}/database.yml +0 -0
  113. data/spec/support/install.sh +43 -7
  114. data/spec/support/simplecov_helper.rb +9 -5
  115. data/spec/support/simplecov_quality_formatter.rb +10 -6
  116. data/spec/unit/apns_feedback_spec.rb +3 -3
  117. data/spec/unit/{adm → client/active_record/adm}/app_spec.rb +3 -3
  118. data/spec/unit/{adm → client/active_record/adm}/notification_spec.rb +5 -7
  119. data/spec/unit/client/active_record/apns/app_spec.rb +29 -0
  120. data/spec/unit/client/active_record/apns/feedback_spec.rb +9 -0
  121. data/spec/unit/client/active_record/apns/notification_spec.rb +231 -0
  122. data/spec/unit/client/active_record/app_spec.rb +30 -0
  123. data/spec/unit/client/active_record/gcm/app_spec.rb +4 -0
  124. data/spec/unit/{gcm → client/active_record/gcm}/notification_spec.rb +5 -7
  125. data/spec/unit/client/active_record/notification_spec.rb +15 -0
  126. data/spec/unit/client/active_record/wpns/app_spec.rb +4 -0
  127. data/spec/unit/client/active_record/wpns/notification_spec.rb +21 -0
  128. data/spec/unit/configuration_spec.rb +12 -5
  129. data/spec/unit/daemon/adm/delivery_spec.rb +57 -54
  130. data/spec/unit/daemon/apns/certificate_expired_error_spec.rb +3 -3
  131. data/spec/unit/daemon/apns/delivery_spec.rb +90 -83
  132. data/spec/unit/daemon/apns/feedback_receiver_spec.rb +24 -17
  133. data/spec/unit/daemon/app_runner_spec.rb +66 -123
  134. data/spec/unit/daemon/batch_spec.rb +52 -115
  135. data/spec/unit/daemon/delivery_spec.rb +15 -1
  136. data/spec/unit/daemon/dispatcher/http_spec.rb +3 -2
  137. data/spec/unit/daemon/dispatcher/tcp_spec.rb +10 -9
  138. data/spec/unit/daemon/dispatcher_loop_spec.rb +7 -12
  139. data/spec/unit/daemon/feeder_spec.rb +40 -39
  140. data/spec/unit/daemon/gcm/delivery_spec.rb +108 -89
  141. data/spec/unit/daemon/reflectable_spec.rb +2 -2
  142. data/spec/unit/daemon/retryable_error_spec.rb +1 -1
  143. data/spec/unit/daemon/service_config_methods_spec.rb +6 -3
  144. data/spec/unit/daemon/signal_handler_spec.rb +72 -0
  145. data/spec/unit/daemon/store/active_record/reconnectable_spec.rb +9 -9
  146. data/spec/unit/daemon/store/active_record_spec.rb +38 -47
  147. data/spec/unit/daemon/tcp_connection_spec.rb +22 -34
  148. data/spec/unit/daemon/too_many_requests_error_spec.rb +1 -1
  149. data/spec/unit/daemon/wpns/delivery_spec.rb +61 -50
  150. data/spec/unit/daemon_spec.rb +46 -81
  151. data/spec/unit/embed_spec.rb +4 -2
  152. data/spec/unit/logger_spec.rb +30 -40
  153. data/spec/unit/notification_shared.rb +9 -79
  154. data/spec/unit/push_spec.rb +3 -8
  155. data/spec/unit/reflection_spec.rb +25 -25
  156. data/spec/unit/rpush_spec.rb +1 -2
  157. data/spec/unit_spec_helper.rb +33 -88
  158. metadata +119 -67
  159. data/lib/rpush/TODO +0 -3
  160. data/lib/rpush/adm/app.rb +0 -15
  161. data/lib/rpush/adm/data_validator.rb +0 -11
  162. data/lib/rpush/adm/notification.rb +0 -29
  163. data/lib/rpush/apns/app.rb +0 -29
  164. data/lib/rpush/apns/binary_notification_validator.rb +0 -12
  165. data/lib/rpush/apns/device_token_format_validator.rb +0 -12
  166. data/lib/rpush/apns/feedback.rb +0 -16
  167. data/lib/rpush/apns/notification.rb +0 -84
  168. data/lib/rpush/app.rb +0 -18
  169. data/lib/rpush/daemon/apns/certificate_expired_error.rb +0 -20
  170. data/lib/rpush/daemon/apns/disconnection_error.rb +0 -20
  171. data/lib/rpush/gcm/app.rb +0 -11
  172. data/lib/rpush/gcm/expiry_collapse_key_mutual_inclusion_validator.rb +0 -11
  173. data/lib/rpush/gcm/notification.rb +0 -30
  174. data/lib/rpush/notification.rb +0 -69
  175. data/lib/rpush/notifier.rb +0 -52
  176. data/lib/rpush/payload_data_size_validator.rb +0 -10
  177. data/lib/rpush/railtie.rb +0 -11
  178. data/lib/rpush/registration_ids_count_validator.rb +0 -10
  179. data/lib/rpush/wpns/app.rb +0 -9
  180. data/lib/rpush/wpns/notification.rb +0 -26
  181. data/lib/tasks/cane.rake +0 -18
  182. data/lib/tasks/rpush.rake +0 -16
  183. data/spec/unit/apns/app_spec.rb +0 -29
  184. data/spec/unit/apns/feedback_spec.rb +0 -9
  185. data/spec/unit/apns/notification_spec.rb +0 -208
  186. data/spec/unit/app_spec.rb +0 -30
  187. data/spec/unit/daemon/apns/disconnection_error_spec.rb +0 -18
  188. data/spec/unit/daemon/interruptible_sleep_spec.rb +0 -68
  189. data/spec/unit/gcm/app_spec.rb +0 -4
  190. data/spec/unit/notification_spec.rb +0 -15
  191. data/spec/unit/notifier_spec.rb +0 -49
  192. data/spec/unit/wpns/app_spec.rb +0 -4
  193. data/spec/unit/wpns/notification_spec.rb +0 -30
@@ -5,101 +5,31 @@ shared_examples_for "an Notification subclass" do
5
5
  it "calls MultiJson.dump when multi_json responds to :dump" do
6
6
  notification = notification_class.new
7
7
  MultiJson.stub(:respond_to?).with(:dump).and_return(true)
8
- MultiJson.should_receive(:dump).with(any_args())
9
- notification.send(data_setter, { :pirates => 1 })
8
+ MultiJson.should_receive(:dump).with(any_args)
9
+ notification.data = { pirates: 1 }
10
10
  end
11
11
 
12
12
  it "calls MultiJson.encode when multi_json does not respond to :dump" do
13
13
  notification = notification_class.new
14
14
  MultiJson.stub(:respond_to?).with(:dump).and_return(false)
15
- MultiJson.should_receive(:encode).with(any_args())
16
- notification.send(data_setter, { :ninjas => 1 })
15
+ MultiJson.should_receive(:encode).with(any_args)
16
+ notification.data = { ninjas: 1 }
17
17
  end
18
18
 
19
19
  it "raises an ArgumentError if something other than a Hash is assigned" do
20
20
  expect do
21
- notification.send(data_setter, Array.new)
21
+ notification.data = Array.new
22
22
  end.to raise_error(ArgumentError, "must be a Hash")
23
23
  end
24
24
 
25
25
  it "encodes the given Hash as JSON" do
26
- notification.send(data_setter, { :hi => "mom" })
27
- notification.read_attribute(:data).should eq "{\"hi\":\"mom\"}"
26
+ notification.data = { hi: "mom" }
27
+ notification.read_attribute(:data).should eq("{\"hi\":\"mom\"}")
28
28
  end
29
29
 
30
30
  it "decodes the JSON when using the reader method" do
31
- notification.send(data_setter, { :hi => "mom" })
32
- notification.send(data_getter).should eq ({"hi" => "mom"})
33
- end
34
-
35
- describe 'scopes' do
36
- before do
37
- Timecop.freeze(Time.now)
38
-
39
- (@delivered_notification = notification_class.new(:app => app, :delivered => true, :failed => false)).save!(:validate => false)
40
- (@failed_notification = notification_class.new(:app => app, :delivered => false, :failed => true)).save!(:validate => false)
41
- (@new_notification = notification_class.new(:app => app, :delivered => false, :failed => false)).save!(:validate => false)
42
- end
43
-
44
- after do
45
- Timecop.return
46
- end
47
-
48
- describe '.completed' do
49
- it 'should return notifications that have been delivered or failed' do
50
- completed_notification_ids = Rpush::Notification.completed.map(&:id)
51
-
52
- completed_notification_ids.size.should eq 2
53
- completed_notification_ids.should include(@delivered_notification.id, @failed_notification.id)
54
- completed_notification_ids.should_not include(@new_notification.id)
55
- end
56
- end
57
-
58
- describe '.created_before' do
59
- it 'should return notifications that were created before the specified date' do
60
- @delivered_notification.created_at = Time.now - 30.days - 1.second
61
- @delivered_notification.save!(:validate => false)
62
-
63
- notification_ids = Rpush::Notification.created_before(Time.now - 30.days).map(&:id)
64
-
65
- notification_ids.size.should eq 1
66
- notification_ids.should include(@delivered_notification.id)
67
- end
68
- end
69
-
70
- describe '.completed_and_older_than' do
71
- before do
72
- @delivered_notification.created_at = Time.now - 30.days - 1.second
73
- @delivered_notification.save!(:validate => false)
74
-
75
- @failed_notification.created_at = Time.now - 20.days - 1.second
76
- @failed_notification.save!(:validate => false)
77
-
78
- @new_notification.created_at = Time.now - 30.days - 1.second
79
- @new_notification.save!(:validate => false)
80
- end
81
-
82
- it 'should only include completed notifications' do
83
- notification_ids = Rpush::Notification.completed_and_older_than(Time.now - 30.days).map(&:id)
84
-
85
- notification_ids.size.should eq 1
86
- notification_ids.should include(@delivered_notification.id)
87
- end
88
-
89
- it 'should not include completed notifications if not older than specified date' do
90
- notification_ids = Rpush::Notification.completed_and_older_than(Time.now - 30.days).map(&:id)
91
-
92
- notification_ids.size.should eq 1
93
- notification_ids.should_not include(@failed_notification.id)
94
- end
95
-
96
- it 'should return notifications that are completed and created before the specified date' do
97
- notification_ids = Rpush::Notification.completed_and_older_than(Time.now - 20.days).map(&:id)
98
-
99
- notification_ids.size.should eq 2
100
- notification_ids.should include(@delivered_notification.id, @failed_notification.id)
101
- end
102
- end
31
+ notification.data = { hi: "mom" }
32
+ notification.data.should eq("hi" => "mom")
103
33
  end
104
34
  end
105
35
  end
@@ -2,8 +2,8 @@ require 'unit_spec_helper'
2
2
 
3
3
  describe Rpush, 'push' do
4
4
  before do
5
- Rpush::Daemon::AppRunner.stub(:sync => nil, :wait => nil)
6
- Rpush::Daemon::Feeder.stub(:start => nil)
5
+ Rpush::Daemon::AppRunner.stub(sync: nil, wait: nil)
6
+ Rpush::Daemon::Feeder.stub(start: nil)
7
7
  end
8
8
 
9
9
  it 'sets the push config option to true' do
@@ -26,11 +26,6 @@ describe Rpush, 'push' do
26
26
  Rpush.push
27
27
  end
28
28
 
29
- it 'waits on the app runner' do
30
- Rpush::Daemon::AppRunner.should_receive(:wait)
31
- Rpush.push
32
- end
33
-
34
29
  it 'stops on the app runner' do
35
30
  Rpush::Daemon::AppRunner.should_receive(:stop)
36
31
  Rpush.push
@@ -38,6 +33,6 @@ describe Rpush, 'push' do
38
33
 
39
34
  it 'overrides the default config options with those given as a hash' do
40
35
  Rpush.config.batch_size = 20
41
- expect { Rpush.push(:batch_size => 10) }.to change(Rpush.config, :batch_size).to(10)
36
+ expect { Rpush.push(batch_size: 10) }.to change(Rpush.config, :batch_size).to(10)
42
37
  end
43
38
  end
@@ -1,30 +1,30 @@
1
1
  require 'unit_spec_helper'
2
2
 
3
- describe Rpush do
4
- it 'yields reflections for configuration' do
5
- did_yield = false
6
- Rpush.reflect { |on| did_yield = true }
7
- did_yield.should be_true
8
- end
3
+ describe Rpush do
4
+ it 'yields reflections for configuration' do
5
+ did_yield = false
6
+ Rpush.reflect { did_yield = true }
7
+ did_yield.should be_true
8
+ end
9
9
 
10
- it 'returns all reflections' do
11
- Rpush.reflections.should be_kind_of(Rpush::Reflections)
12
- end
13
- end
10
+ it 'returns all reflections' do
11
+ Rpush.reflections.should be_kind_of(Rpush::Reflections)
12
+ end
13
+ end
14
14
 
15
- describe Rpush::Reflections do
16
- it 'dispatches the given reflection' do
17
- did_yield = false
18
- Rpush.reflect do |on|
19
- on.error { did_yield = true }
20
- end
21
- Rpush.reflections.__dispatch(:error)
22
- did_yield.should be_true
23
- end
15
+ describe Rpush::Reflections do
16
+ it 'dispatches the given reflection' do
17
+ did_yield = false
18
+ Rpush.reflect do |on|
19
+ on.error { did_yield = true }
20
+ end
21
+ Rpush.reflections.__dispatch(:error)
22
+ did_yield.should be_true
23
+ end
24
24
 
25
- it 'raises an error when trying to dispatch and unknown reflection' do
26
- expect do
27
- Rpush.reflections.__dispatch(:unknown)
28
- end.to raise_error(Rpush::Reflections::NoSuchReflectionError)
29
- end
30
- end
25
+ it 'raises an error when trying to dispatch and unknown reflection' do
26
+ expect do
27
+ Rpush.reflections.__dispatch(:unknown)
28
+ end.to raise_error(Rpush::Reflections::NoSuchReflectionError)
29
+ end
30
+ end
@@ -2,8 +2,7 @@ require 'unit_spec_helper'
2
2
 
3
3
  describe Rpush do
4
4
  it "lazy initializes the logger" do
5
- Rpush.config.stub(:foreground => true)
6
- Rpush::Logger.should_receive(:new).with(:foreground => true)
5
+ Rpush::Logger.should_receive(:new)
7
6
  Rpush.logger
8
7
  end
9
8
  end
@@ -1,101 +1,46 @@
1
- ENV['RAILS_ENV'] = 'test'
1
+ require 'spec_helper'
2
+ require 'rails'
2
3
 
3
- require 'bundler'
4
- Bundler.require(:default)
5
-
6
- require 'active_record'
7
-
8
- unless ENV['TRAVIS'] && ENV['QUALITY'] == 'false'
9
- begin
10
- require './spec/support/simplecov_helper'
11
- include SimpleCovHelper
12
- start_simple_cov("unit-#{RUBY_VERSION}")
13
- rescue LoadError
14
- puts "Coverage disabled."
15
- end
4
+ def unit_example?(example)
5
+ path = example.metadata[:example_group][:file_path]
6
+ path =~ /spec\/unit/
16
7
  end
17
8
 
18
- jruby = defined?(RUBY_ENGINE) && RUBY_ENGINE == 'jruby'
19
-
20
- $adapter = ENV['ADAPTER'] || 'postgresql'
21
- $adapter = 'jdbc' + $adapter if jruby
22
-
23
- DATABASE_CONFIG = YAML.load_file(File.expand_path("../config/database.yml", File.dirname(__FILE__)))
24
-
25
- if DATABASE_CONFIG[$adapter].nil?
26
- puts "No such adapter '#{$adapter}'. Valid adapters are #{DATABASE_CONFIG.keys.join(', ')}."
27
- exit 1
28
- end
29
-
30
- if ENV['TRAVIS']
31
- DATABASE_CONFIG[$adapter]['username'] = 'postgres'
32
- else
33
- require 'etc'
34
- username = $adapter =~ /mysql/ ? 'root' : Etc.getlogin
35
- DATABASE_CONFIG[$adapter]['username'] = username
36
- end
37
-
38
- puts "Using #{$adapter} adapter."
39
-
40
- ActiveRecord::Base.configurations = {"test" => DATABASE_CONFIG[$adapter]}
41
- ActiveRecord::Base.establish_connection(DATABASE_CONFIG[$adapter])
42
-
43
- require 'generators/templates/add_rpush'
44
-
45
- migrations = [AddRpush]
46
-
47
- migrations.reverse.each do |m|
48
- begin
49
- m.down
50
- rescue ActiveRecord::StatementInvalid => e
51
- p e
52
- end
9
+ def rails4?
10
+ ::Rails::VERSION::STRING >= '4'
53
11
  end
54
12
 
55
- migrations.each(&:up)
56
-
57
- require 'database_cleaner'
58
- DatabaseCleaner.strategy = :truncation
59
-
60
- require 'rpush'
61
- require 'rpush/daemon'
62
-
63
- Rpush::Daemon.initialize_store
64
- Rpush::Notification.reset_column_information
65
- Rpush::App.reset_column_information
66
- Rpush::Apns::Feedback.reset_column_information
67
-
68
13
  RSpec.configure do |config|
69
- # config.before :suite do
70
- # PerfTools::CpuProfiler.start('/tmp/rpush_profile')
71
- # end
72
- # config.after :suite do
73
- # PerfTools::CpuProfiler.stop
74
- # end
75
-
76
14
  config.before(:each) do
77
- DatabaseCleaner.clean
15
+ Modis.with_connection do |redis|
16
+ redis.keys('rpush:*').each { |key| redis.del(key) }
17
+ end
18
+
19
+ if unit_example?(example)
20
+ connection = ActiveRecord::Base.connection
21
+
22
+ if rails4?
23
+ connection.begin_transaction joinable: false
24
+ else
25
+ connection.increment_open_transactions
26
+ connection.transaction_joinable = false
27
+ connection.begin_db_transaction
28
+ end
29
+ end
78
30
  end
79
31
 
80
32
  config.after(:each) do
81
- Rpush.logger = nil
82
- Rpush::Daemon.store = nil
83
- Rpush::Deprecation.muted do
84
- Rpush.config.set_defaults if Rpush.config.kind_of?(Rpush::Configuration)
33
+ if unit_example?(example)
34
+ connection = ActiveRecord::Base.connection
35
+
36
+ if rails4?
37
+ connection.rollback_transaction if connection.transaction_open?
38
+ else
39
+ if connection.open_transactions != 0
40
+ connection.rollback_db_transaction
41
+ connection.decrement_open_transactions
42
+ end
43
+ end
85
44
  end
86
45
  end
87
46
  end
88
-
89
- # a test certificate that contains both an X509 certificate and
90
- # a private key, similar to those used for connecting to Apple
91
- # push notification servers.
92
- #
93
- # Note that we cannot validate the certificate and private key
94
- # because we are missing the certificate chain used to validate
95
- # the certificate, and this is private to Apple. So if the app
96
- # has a certificate and a private key in it, the only way to find
97
- # out if it really is valid is to connect to Apple's servers.
98
-
99
- path = File.join(File.dirname(__FILE__), 'support')
100
- TEST_CERT = File.read(File.join(path, 'cert_without_password.pem'))
101
- TEST_CERT_WITH_PASSWORD = File.read(File.join(path, 'cert_with_password.pem'))
metadata CHANGED
@@ -1,44 +1,58 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rpush
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 2.0.0.beta1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ian Leitch
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-09 00:00:00.000000000 Z
11
+ date: 2014-07-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: net-http-persistent
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
- description: Professional grade APNs and GCM for Ruby
41
+ - !ruby/object:Gem::Dependency
42
+ name: activesupport
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: The push notification service for Ruby.
42
56
  email:
43
57
  - port001@gmail.com
44
58
  executables:
@@ -49,6 +63,7 @@ files:
49
63
  - CHANGELOG.md
50
64
  - LICENSE
51
65
  - README.md
66
+ - bin/rpush
52
67
  - lib/generators/rpush_generator.rb
53
68
  - lib/generators/templates/add_adm.rb
54
69
  - lib/generators/templates/add_alert_is_json_to_rapns_notifications.rb
@@ -62,47 +77,84 @@ files:
62
77
  - lib/generators/templates/create_rapns_notifications.rb
63
78
  - lib/generators/templates/rename_rapns_to_rpush.rb
64
79
  - lib/generators/templates/rpush.rb
80
+ - lib/generators/templates/rpush_2_0_0_updates.rb
65
81
  - lib/rpush.rb
66
- - lib/rpush/TODO
67
- - lib/rpush/adm/app.rb
68
- - lib/rpush/adm/data_validator.rb
69
- - lib/rpush/adm/notification.rb
70
- - lib/rpush/apns/app.rb
71
- - lib/rpush/apns/binary_notification_validator.rb
72
- - lib/rpush/apns/device_token_format_validator.rb
73
- - lib/rpush/apns/feedback.rb
74
- - lib/rpush/apns/notification.rb
75
82
  - lib/rpush/apns_feedback.rb
76
- - lib/rpush/app.rb
83
+ - lib/rpush/client/active_model.rb
84
+ - lib/rpush/client/active_model/adm/app.rb
85
+ - lib/rpush/client/active_model/adm/data_validator.rb
86
+ - lib/rpush/client/active_model/adm/notification.rb
87
+ - lib/rpush/client/active_model/apns/app.rb
88
+ - lib/rpush/client/active_model/apns/binary_notification_validator.rb
89
+ - lib/rpush/client/active_model/apns/device_token_format_validator.rb
90
+ - lib/rpush/client/active_model/apns/notification.rb
91
+ - lib/rpush/client/active_model/gcm/app.rb
92
+ - lib/rpush/client/active_model/gcm/expiry_collapse_key_mutual_inclusion_validator.rb
93
+ - lib/rpush/client/active_model/gcm/notification.rb
94
+ - lib/rpush/client/active_model/notification.rb
95
+ - lib/rpush/client/active_model/payload_data_size_validator.rb
96
+ - lib/rpush/client/active_model/registration_ids_count_validator.rb
97
+ - lib/rpush/client/active_model/wpns/app.rb
98
+ - lib/rpush/client/active_model/wpns/notification.rb
99
+ - lib/rpush/client/active_record.rb
100
+ - lib/rpush/client/active_record/adm/app.rb
101
+ - lib/rpush/client/active_record/adm/notification.rb
102
+ - lib/rpush/client/active_record/apns/app.rb
103
+ - lib/rpush/client/active_record/apns/feedback.rb
104
+ - lib/rpush/client/active_record/apns/notification.rb
105
+ - lib/rpush/client/active_record/app.rb
106
+ - lib/rpush/client/active_record/gcm/app.rb
107
+ - lib/rpush/client/active_record/gcm/notification.rb
108
+ - lib/rpush/client/active_record/notification.rb
109
+ - lib/rpush/client/active_record/wpns/app.rb
110
+ - lib/rpush/client/active_record/wpns/notification.rb
111
+ - lib/rpush/client/redis.rb
112
+ - lib/rpush/client/redis/adm/app.rb
113
+ - lib/rpush/client/redis/adm/notification.rb
114
+ - lib/rpush/client/redis/apns/app.rb
115
+ - lib/rpush/client/redis/apns/feedback.rb
116
+ - lib/rpush/client/redis/apns/notification.rb
117
+ - lib/rpush/client/redis/app.rb
118
+ - lib/rpush/client/redis/gcm/app.rb
119
+ - lib/rpush/client/redis/gcm/notification.rb
120
+ - lib/rpush/client/redis/notification.rb
121
+ - lib/rpush/client/redis/wpns/app.rb
122
+ - lib/rpush/client/redis/wpns/notification.rb
77
123
  - lib/rpush/configuration.rb
78
124
  - lib/rpush/daemon.rb
79
125
  - lib/rpush/daemon/adm.rb
80
126
  - lib/rpush/daemon/adm/delivery.rb
81
127
  - lib/rpush/daemon/apns.rb
82
- - lib/rpush/daemon/apns/certificate_expired_error.rb
83
128
  - lib/rpush/daemon/apns/delivery.rb
84
- - lib/rpush/daemon/apns/disconnection_error.rb
85
129
  - lib/rpush/daemon/apns/feedback_receiver.rb
86
130
  - lib/rpush/daemon/app_runner.rb
87
131
  - lib/rpush/daemon/batch.rb
88
132
  - lib/rpush/daemon/constants.rb
89
133
  - lib/rpush/daemon/delivery.rb
90
134
  - lib/rpush/daemon/delivery_error.rb
135
+ - lib/rpush/daemon/dispatcher/apns_tcp.rb
91
136
  - lib/rpush/daemon/dispatcher/http.rb
92
137
  - lib/rpush/daemon/dispatcher/tcp.rb
93
138
  - lib/rpush/daemon/dispatcher_loop.rb
94
139
  - lib/rpush/daemon/dispatcher_loop_collection.rb
140
+ - lib/rpush/daemon/errors.rb
95
141
  - lib/rpush/daemon/feeder.rb
96
142
  - lib/rpush/daemon/gcm.rb
97
143
  - lib/rpush/daemon/gcm/delivery.rb
98
144
  - lib/rpush/daemon/interruptible_sleep.rb
99
145
  - lib/rpush/daemon/loggable.rb
146
+ - lib/rpush/daemon/proc_title.rb
147
+ - lib/rpush/daemon/queue_payload.rb
100
148
  - lib/rpush/daemon/reflectable.rb
101
149
  - lib/rpush/daemon/retry_header_parser.rb
102
150
  - lib/rpush/daemon/retryable_error.rb
151
+ - lib/rpush/daemon/ring_buffer.rb
103
152
  - lib/rpush/daemon/service_config_methods.rb
153
+ - lib/rpush/daemon/signal_handler.rb
104
154
  - lib/rpush/daemon/store/active_record.rb
105
155
  - lib/rpush/daemon/store/active_record/reconnectable.rb
156
+ - lib/rpush/daemon/store/interface.rb
157
+ - lib/rpush/daemon/store/redis.rb
106
158
  - lib/rpush/daemon/tcp_connection.rb
107
159
  - lib/rpush/daemon/too_many_requests_error.rb
108
160
  - lib/rpush/daemon/wpns.rb
@@ -110,48 +162,49 @@ files:
110
162
  - lib/rpush/deprecatable.rb
111
163
  - lib/rpush/deprecation.rb
112
164
  - lib/rpush/embed.rb
113
- - lib/rpush/gcm/app.rb
114
- - lib/rpush/gcm/expiry_collapse_key_mutual_inclusion_validator.rb
115
- - lib/rpush/gcm/notification.rb
116
165
  - lib/rpush/logger.rb
117
166
  - lib/rpush/multi_json_helper.rb
118
- - lib/rpush/notification.rb
119
- - lib/rpush/notifier.rb
120
- - lib/rpush/payload_data_size_validator.rb
121
167
  - lib/rpush/push.rb
122
- - lib/rpush/railtie.rb
123
168
  - lib/rpush/reflection.rb
124
- - lib/rpush/registration_ids_count_validator.rb
125
169
  - lib/rpush/version.rb
126
- - lib/rpush/wpns/app.rb
127
- - lib/rpush/wpns/notification.rb
128
- - lib/tasks/cane.rake
129
- - lib/tasks/rpush.rake
170
+ - lib/tasks/quality.rake
130
171
  - lib/tasks/test.rake
131
- - config/database.yml
172
+ - spec/.rubocop.yml
132
173
  - spec/functional/adm_spec.rb
133
174
  - spec/functional/apns_spec.rb
134
175
  - spec/functional/embed_spec.rb
135
176
  - spec/functional/gcm_spec.rb
177
+ - spec/functional/new_app_spec.rb
178
+ - spec/functional/retry_spec.rb
136
179
  - spec/functional/wpns_spec.rb
180
+ - spec/functional_spec_helper.rb
181
+ - spec/integration/rpush_spec.rb
182
+ - spec/integration/support/gcm_success_response.json
183
+ - spec/spec_helper.rb
184
+ - spec/support/active_record_setup.rb
137
185
  - spec/support/cert_with_password.pem
138
186
  - spec/support/cert_without_password.pem
187
+ - spec/support/config/database.yml
139
188
  - spec/support/install.sh
140
189
  - spec/support/simplecov_helper.rb
141
190
  - spec/support/simplecov_quality_formatter.rb
142
191
  - spec/tmp/.gitkeep
143
- - spec/unit/adm/app_spec.rb
144
- - spec/unit/adm/notification_spec.rb
145
- - spec/unit/apns/app_spec.rb
146
- - spec/unit/apns/feedback_spec.rb
147
- - spec/unit/apns/notification_spec.rb
148
192
  - spec/unit/apns_feedback_spec.rb
149
- - spec/unit/app_spec.rb
193
+ - spec/unit/client/active_record/adm/app_spec.rb
194
+ - spec/unit/client/active_record/adm/notification_spec.rb
195
+ - spec/unit/client/active_record/apns/app_spec.rb
196
+ - spec/unit/client/active_record/apns/feedback_spec.rb
197
+ - spec/unit/client/active_record/apns/notification_spec.rb
198
+ - spec/unit/client/active_record/app_spec.rb
199
+ - spec/unit/client/active_record/gcm/app_spec.rb
200
+ - spec/unit/client/active_record/gcm/notification_spec.rb
201
+ - spec/unit/client/active_record/notification_spec.rb
202
+ - spec/unit/client/active_record/wpns/app_spec.rb
203
+ - spec/unit/client/active_record/wpns/notification_spec.rb
150
204
  - spec/unit/configuration_spec.rb
151
205
  - spec/unit/daemon/adm/delivery_spec.rb
152
206
  - spec/unit/daemon/apns/certificate_expired_error_spec.rb
153
207
  - spec/unit/daemon/apns/delivery_spec.rb
154
- - spec/unit/daemon/apns/disconnection_error_spec.rb
155
208
  - spec/unit/daemon/apns/feedback_receiver_spec.rb
156
209
  - spec/unit/daemon/app_runner_spec.rb
157
210
  - spec/unit/daemon/batch_spec.rb
@@ -163,10 +216,10 @@ files:
163
216
  - spec/unit/daemon/dispatcher_loop_spec.rb
164
217
  - spec/unit/daemon/feeder_spec.rb
165
218
  - spec/unit/daemon/gcm/delivery_spec.rb
166
- - spec/unit/daemon/interruptible_sleep_spec.rb
167
219
  - spec/unit/daemon/reflectable_spec.rb
168
220
  - spec/unit/daemon/retryable_error_spec.rb
169
221
  - spec/unit/daemon/service_config_methods_spec.rb
222
+ - spec/unit/daemon/signal_handler_spec.rb
170
223
  - spec/unit/daemon/store/active_record/reconnectable_spec.rb
171
224
  - spec/unit/daemon/store/active_record_spec.rb
172
225
  - spec/unit/daemon/tcp_connection_spec.rb
@@ -176,19 +229,12 @@ files:
176
229
  - spec/unit/deprecatable_spec.rb
177
230
  - spec/unit/deprecation_spec.rb
178
231
  - spec/unit/embed_spec.rb
179
- - spec/unit/gcm/app_spec.rb
180
- - spec/unit/gcm/notification_spec.rb
181
232
  - spec/unit/logger_spec.rb
182
233
  - spec/unit/notification_shared.rb
183
- - spec/unit/notification_spec.rb
184
- - spec/unit/notifier_spec.rb
185
234
  - spec/unit/push_spec.rb
186
235
  - spec/unit/reflection_spec.rb
187
236
  - spec/unit/rpush_spec.rb
188
- - spec/unit/wpns/app_spec.rb
189
- - spec/unit/wpns/notification_spec.rb
190
237
  - spec/unit_spec_helper.rb
191
- - bin/rpush
192
238
  homepage: https://github.com/rpush/rpush
193
239
  licenses:
194
240
  - MIT
@@ -199,45 +245,57 @@ require_paths:
199
245
  - lib
200
246
  required_ruby_version: !ruby/object:Gem::Requirement
201
247
  requirements:
202
- - - '>='
248
+ - - ">="
203
249
  - !ruby/object:Gem::Version
204
250
  version: '0'
205
251
  required_rubygems_version: !ruby/object:Gem::Requirement
206
252
  requirements:
207
- - - '>='
253
+ - - ">"
208
254
  - !ruby/object:Gem::Version
209
- version: '0'
255
+ version: 1.3.1
210
256
  requirements: []
211
257
  rubyforge_project:
212
- rubygems_version: 2.1.11
258
+ rubygems_version: 2.2.2
213
259
  signing_key:
214
260
  specification_version: 4
215
- summary: Professional grade APNs and GCM for Ruby
261
+ summary: The push notification service for Ruby.
216
262
  test_files:
217
- - config/database.yml
263
+ - spec/.rubocop.yml
218
264
  - spec/functional/adm_spec.rb
219
265
  - spec/functional/apns_spec.rb
220
266
  - spec/functional/embed_spec.rb
221
267
  - spec/functional/gcm_spec.rb
268
+ - spec/functional/new_app_spec.rb
269
+ - spec/functional/retry_spec.rb
222
270
  - spec/functional/wpns_spec.rb
271
+ - spec/functional_spec_helper.rb
272
+ - spec/integration/rpush_spec.rb
273
+ - spec/integration/support/gcm_success_response.json
274
+ - spec/spec_helper.rb
275
+ - spec/support/active_record_setup.rb
223
276
  - spec/support/cert_with_password.pem
224
277
  - spec/support/cert_without_password.pem
278
+ - spec/support/config/database.yml
225
279
  - spec/support/install.sh
226
280
  - spec/support/simplecov_helper.rb
227
281
  - spec/support/simplecov_quality_formatter.rb
228
282
  - spec/tmp/.gitkeep
229
- - spec/unit/adm/app_spec.rb
230
- - spec/unit/adm/notification_spec.rb
231
- - spec/unit/apns/app_spec.rb
232
- - spec/unit/apns/feedback_spec.rb
233
- - spec/unit/apns/notification_spec.rb
234
283
  - spec/unit/apns_feedback_spec.rb
235
- - spec/unit/app_spec.rb
284
+ - spec/unit/client/active_record/adm/app_spec.rb
285
+ - spec/unit/client/active_record/adm/notification_spec.rb
286
+ - spec/unit/client/active_record/apns/app_spec.rb
287
+ - spec/unit/client/active_record/apns/feedback_spec.rb
288
+ - spec/unit/client/active_record/apns/notification_spec.rb
289
+ - spec/unit/client/active_record/app_spec.rb
290
+ - spec/unit/client/active_record/gcm/app_spec.rb
291
+ - spec/unit/client/active_record/gcm/notification_spec.rb
292
+ - spec/unit/client/active_record/notification_spec.rb
293
+ - spec/unit/client/active_record/wpns/app_spec.rb
294
+ - spec/unit/client/active_record/wpns/notification_spec.rb
236
295
  - spec/unit/configuration_spec.rb
237
296
  - spec/unit/daemon/adm/delivery_spec.rb
238
297
  - spec/unit/daemon/apns/certificate_expired_error_spec.rb
239
298
  - spec/unit/daemon/apns/delivery_spec.rb
240
- - spec/unit/daemon/apns/disconnection_error_spec.rb
241
299
  - spec/unit/daemon/apns/feedback_receiver_spec.rb
242
300
  - spec/unit/daemon/app_runner_spec.rb
243
301
  - spec/unit/daemon/batch_spec.rb
@@ -249,10 +307,10 @@ test_files:
249
307
  - spec/unit/daemon/dispatcher_loop_spec.rb
250
308
  - spec/unit/daemon/feeder_spec.rb
251
309
  - spec/unit/daemon/gcm/delivery_spec.rb
252
- - spec/unit/daemon/interruptible_sleep_spec.rb
253
310
  - spec/unit/daemon/reflectable_spec.rb
254
311
  - spec/unit/daemon/retryable_error_spec.rb
255
312
  - spec/unit/daemon/service_config_methods_spec.rb
313
+ - spec/unit/daemon/signal_handler_spec.rb
256
314
  - spec/unit/daemon/store/active_record/reconnectable_spec.rb
257
315
  - spec/unit/daemon/store/active_record_spec.rb
258
316
  - spec/unit/daemon/tcp_connection_spec.rb
@@ -262,15 +320,9 @@ test_files:
262
320
  - spec/unit/deprecatable_spec.rb
263
321
  - spec/unit/deprecation_spec.rb
264
322
  - spec/unit/embed_spec.rb
265
- - spec/unit/gcm/app_spec.rb
266
- - spec/unit/gcm/notification_spec.rb
267
323
  - spec/unit/logger_spec.rb
268
324
  - spec/unit/notification_shared.rb
269
- - spec/unit/notification_spec.rb
270
- - spec/unit/notifier_spec.rb
271
325
  - spec/unit/push_spec.rb
272
326
  - spec/unit/reflection_spec.rb
273
327
  - spec/unit/rpush_spec.rb
274
- - spec/unit/wpns/app_spec.rb
275
- - spec/unit/wpns/notification_spec.rb
276
328
  - spec/unit_spec_helper.rb