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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 915d2b22f7338ed473b11711d2928b99f77b140d
4
- data.tar.gz: 70614eb04113241f04021e1d691bd595a12bb0d3
3
+ metadata.gz: 8d5bf4a64ca72a0c58b62a78da3e4315d06601cc
4
+ data.tar.gz: 2472ea351a2cc76e46668951eeabcfaf43b94b1f
5
5
  SHA512:
6
- metadata.gz: d307e38e19be35ffd0bafcef76e5601371760b78d0f4fb6481d223a9db5a3ff706ca527eb61ee315b1f53f30c576b8d93fe8f402462371c864eb6f92b052f633
7
- data.tar.gz: fd82f029800ef107c7b0cb312084763244e11a5f499add5f0530133b59737f1d98a8db7274dbaedbbcc17c62f9858559c0a4d4c25e9252ffd4d0841e20f8a15d
6
+ metadata.gz: 1e34c0d97f7a604e0cc47b9c2e3548055207d87cd7a09c0800632c123cc4d7f4f62c7dbc7d014fa302c797ae822e2df2ae788d50b9670c24b003dbe00e7af767
7
+ data.tar.gz: 39e8509bb7fcfc76cb0347d55b4eee1a74f2083248ea3c71ccfbfff5e08a4ca8a3cfe6d8f6d1b7f788955f8af8fea016c469e741a5306c0c547fef5afd031029
@@ -1,3 +1,16 @@
1
+ ## 2.0.0 (unreleased)
2
+ * Use APNs enhanced binary format version 2.
3
+ * Support running multiple Rpush processes when using ActiveRecord and Redis.
4
+ * APNs error detection is now performed asynchronously, 'check_for_errors' is therefore deprecated.
5
+ * Deprecated attributes_for_device accessors. Use data instead.
6
+ * Fix signal handling to work with Ruby 2.x. (#40).
7
+ * You no longer need to signal HUP after creating a new app, they will be loaded automatically for you.
8
+ * APNs notifications are now delivered in batches, greatly improving throughput.
9
+ * Signaling HUP now also causes Rpush to immediately check for new notifications.
10
+ * The 'wakeup' config option has been removed.
11
+ * The 'batch_storage_updates' config option has been deprecated, storage backends will now always batch updates where appropriate.
12
+ * The rpush process title updates with number of queued notifications and number of dispatchers.
13
+
1
14
  ## 1.0.0 (Feb 9, 2014)
2
15
  * Renamed to Rpush (from Rapns). Version number reset to 1.0.0.
3
16
  * Reduce default batch size to 100.
data/README.md CHANGED
@@ -1,24 +1,24 @@
1
1
  [![Build Status](https://secure.travis-ci.org/rpush/rpush.png?branch=master)](http://travis-ci.org/rpush/rpush)
2
2
  [![Code Climate](https://codeclimate.com/github/rpush/rpush.png)](https://codeclimate.com/github/rpush/rpush)
3
- [![Coverage Status](https://coveralls.io/repos/rpush/rpush/badge.png?branch=master)](https://coveralls.io/r/rpush/rpush?branch=master)
3
+ [![Code Coverage](https://codeclimate.com/github/rpush/rpush/coverage.png)](https://codeclimate.com/github/rpush/rpush)
4
4
  [![Gem Version](https://badge.fury.io/rb/rpush.png)](http://badge.fury.io/rb/rpush)
5
5
 
6
- <img src="https://raw.github.com/rpush/rpush/master/rpush.png" align="right" width="200px" />
6
+ <img src="https://raw.github.com/rpush/rpush/master/logo.png" align="right" width="200px" />
7
7
 
8
8
  ### Rpush. The push notification service for Ruby.
9
9
 
10
10
  * Supports:
11
11
  * **Apple Push Notification Service**
12
- * **Google Cloud Messaging)**
13
- * **Amazon Devide Messaging**
14
- * **Windows Push Notification Service**.
12
+ * **Google Cloud Messaging**
13
+ * **Amazon Device Messaging**
14
+ * **Windows Phone Push Notification Service**.
15
15
  * Seamless Rails (3, 4) integration.
16
16
  * Scalable - choose the number of persistent connections for each app.
17
17
  * Designed for uptime - signal -HUP to add, update apps.
18
18
  * Run as a daemon or inside an [existing processs](https://github.com/rpush/rpush/wiki/Embedding-API).
19
19
  * Use in a scheduler for low-workload deployments ([Push API](https://github.com/rpush/rpush/wiki/Push-API)).
20
20
  * Hooks for fine-grained instrumentation and error handling ([Reflection API](https://github.com/rpush/rpush/wiki/Reflection-API)).
21
- * Works with MRI, JRuby, Rubinius 1.9, 2.0, 2.1.
21
+ * Works with MRI, JRuby and Rubinius.
22
22
 
23
23
 
24
24
  ### Getting Started
@@ -57,7 +57,7 @@ n = Rpush::Apns::Notification.new
57
57
  n.app = Rpush::Apns::App.find_by_name("ios_app")
58
58
  n.device_token = "..."
59
59
  n.alert = "hi mom!"
60
- n.attributes_for_device = {:foo => :bar}
60
+ n.data = { foo: :bar }
61
61
  n.save!
62
62
  ```
63
63
 
@@ -76,8 +76,8 @@ app.save!
76
76
  ```ruby
77
77
  n = Rpush::Gcm::Notification.new
78
78
  n.app = Rpush::Gcm::App.find_by_name("android_app")
79
- n.registration_ids = ["..."]
80
- n.data = {:message => "hi mom!"}
79
+ n.registration_ids = ["token", "..."]
80
+ n.data = { message: "hi mom!" }
81
81
  n.save!
82
82
  ```
83
83
 
@@ -98,7 +98,7 @@ app.save!
98
98
  n = Rpush::Adm::Notification.new
99
99
  n.app = Rpush::Adm::App.find_by_name("kindle_app")
100
100
  n.registration_ids = ["..."]
101
- n.data = {:message => "hi mom!"}
101
+ n.data = { message: "hi mom!"}
102
102
  n.collapse_key = "Optional consolidationKey"
103
103
  n.save!
104
104
  ```
@@ -124,7 +124,7 @@ n.save!
124
124
 
125
125
  ### Starting Rpush
126
126
 
127
- As a daemon:
127
+ As a daemon (recommended):
128
128
 
129
129
  cd /path/to/rails/app
130
130
  rpush <Rails environment> [options]
@@ -135,8 +135,6 @@ Inside an existing process (see [Embedding API](https://github.com/rpush/rpush/w
135
135
  Rpush.embed
136
136
  ```
137
137
 
138
- *Please note that only ever a single instance of Rpush should be running.*
139
-
140
138
  In a scheduler (see [Push API](https://github.com/rpush/rpush/wiki/Push-API)):
141
139
 
142
140
  ```ruby
@@ -172,7 +170,7 @@ After updating you should run `rails g rpush` to check for any new migrations.
172
170
  * [Silent failures might be dropped connections](https://github.com/rpush/rpush/wiki/Dropped-connections)
173
171
 
174
172
  ### Google Cloud Messaging
175
- * [Notification Options](https://github.com/rpush/rpush/wiki//GCM-Notification-Options)
173
+ * [Notification Options](https://github.com/rpush/rpush/wiki/GCM-Notification-Options)
176
174
  * [Canonical IDs](https://github.com/rpush/rpush/wiki/Canonical-IDs)
177
175
  * [Delivery Failures & Retries](https://github.com/rpush/rpush/wiki/Delivery-Failures-&-Retries)
178
176
 
data/bin/rpush CHANGED
@@ -16,8 +16,17 @@ options = ARGV.options do |opts|
16
16
  opts.on('-p PATH', '--pid-file PATH', String, 'Path to write PID file. Relative to Rails root unless absolute.') { |path| config.pid_file = path }
17
17
  opts.on('-b N', '--batch-size N', Integer, 'Storage backend notification batch size.') { |n| config.batch_size = n }
18
18
  opts.on('-B', '--[no-]batch-storage-updates', 'Perform storage updates in batches.') { |v| config.batch_storage_updates = v }
19
- opts.on('-v', '--version', 'Print the version.') { puts "rpush #{Rpush::VERSION}"; exit }
20
- opts.on('-h', '--help', 'You\'re looking at it.') { puts opts; exit }
19
+ opts.on('-v', '--version', 'Print the version.') do
20
+ puts "rpush #{Rpush::VERSION}"
21
+ exit
22
+ end
23
+ opts.on('-h', '--help', 'You\'re looking at it.') do
24
+ hidden_switches = %w(-e --no-error-checks)
25
+ puts opts.to_s.split("\n").delete_if do |line|
26
+ hidden_switches.any? { |s| line =~ /#{s}/ }
27
+ end.join("\n")
28
+ exit
29
+ end
21
30
  end
22
31
 
23
32
  if environment.nil? || environment =~ /^-/
@@ -20,8 +20,10 @@ class RpushGenerator < Rails::Generators::Base
20
20
  add_rpush_migration('add_adm')
21
21
  add_rpush_migration('rename_rapns_to_rpush')
22
22
  add_rpush_migration('add_fail_after_to_rpush_notifications')
23
+ add_rpush_migration('add_processing_to_rpush_notifications')
23
24
  else
24
25
  add_rpush_migration('add_rpush')
26
+ add_rpush_migration('rpush_2_0_0_updates')
25
27
  end
26
28
  end
27
29
 
@@ -6,14 +6,14 @@ class AddAdm < ActiveRecord::Migration
6
6
  end
7
7
 
8
8
  def self.up
9
- add_column :rapns_apps, :client_id, :string, :null => true
10
- add_column :rapns_apps, :client_secret, :string, :null => true
11
- add_column :rapns_apps, :access_token, :string, :null => true
12
- add_column :rapns_apps, :access_token_expiration, :datetime, :null => true
9
+ add_column :rapns_apps, :client_id, :string, null: true
10
+ add_column :rapns_apps, :client_secret, :string, null: true
11
+ add_column :rapns_apps, :access_token, :string, null: true
12
+ add_column :rapns_apps, :access_token_expiration, :datetime, null: true
13
13
  end
14
14
 
15
15
  def self.down
16
- AddAdm::Rapns::Notification.where(:type => 'Rapns::Adm::Notification').delete_all
16
+ AddAdm::Rapns::Notification.where(type: 'Rapns::Adm::Notification').delete_all
17
17
 
18
18
  remove_column :rapns_apps, :client_id
19
19
  remove_column :rapns_apps, :client_secret
@@ -1,6 +1,6 @@
1
1
  class AddAlertIsJsonToRapnsNotifications < ActiveRecord::Migration
2
2
  def self.up
3
- add_column :rapns_notifications, :alert_is_json, :boolean, :null => true, :default => false
3
+ add_column :rapns_notifications, :alert_is_json, :boolean, null: true, default: false
4
4
  end
5
5
 
6
6
  def self.down
@@ -1,7 +1,7 @@
1
1
  class AddAppToRapns < ActiveRecord::Migration
2
2
  def self.up
3
- add_column :rapns_notifications, :app, :string, :null => true
4
- add_column :rapns_feedback, :app, :string, :null => true
3
+ add_column :rapns_notifications, :app, :string, null: true
4
+ add_column :rapns_feedback, :app, :string, null: true
5
5
  end
6
6
 
7
7
  def self.down
@@ -1,6 +1,6 @@
1
1
  class AddFailAfterToRpushNotifications < ActiveRecord::Migration
2
2
  def self.up
3
- add_column :rpush_notifications, :fail_after, :timestamp, :null => true
3
+ add_column :rpush_notifications, :fail_after, :timestamp, null: true
4
4
  end
5
5
 
6
6
  def self.down
@@ -11,34 +11,34 @@ class AddGcm < ActiveRecord::Migration
11
11
  end
12
12
 
13
13
  def self.up
14
- add_column :rapns_notifications, :type, :string, :null => true
15
- add_column :rapns_apps, :type, :string, :null => true
14
+ add_column :rapns_notifications, :type, :string, null: true
15
+ add_column :rapns_apps, :type, :string, null: true
16
16
 
17
- AddGcm::Rapns::Notification.update_all :type => 'Rapns::Apns::Notification'
18
- AddGcm::Rapns::App.update_all :type => 'Rapns::Apns::App'
17
+ AddGcm::Rapns::Notification.update_all type: 'Rapns::Apns::Notification'
18
+ AddGcm::Rapns::App.update_all type: 'Rapns::Apns::App'
19
19
 
20
- change_column :rapns_notifications, :type, :string, :null => false
21
- change_column :rapns_apps, :type, :string, :null => false
22
- change_column :rapns_notifications, :device_token, :string, { :null => true, :limit => 64 }
23
- change_column :rapns_notifications, :expiry, :integer, { :null => true, :default => 1.day.to_i }
24
- change_column :rapns_apps, :environment, :string, :null => true
25
- change_column :rapns_apps, :certificate, :text, :null => true, :default => nil
20
+ change_column :rapns_notifications, :type, :string, null: false
21
+ change_column :rapns_apps, :type, :string, null: false
22
+ change_column :rapns_notifications, :device_token, :string, { null: true, limit: 64 }
23
+ change_column :rapns_notifications, :expiry, :integer, { null: true, default: 1.day.to_i }
24
+ change_column :rapns_apps, :environment, :string, null: true
25
+ change_column :rapns_apps, :certificate, :text, null: true, default: nil
26
26
 
27
- change_column :rapns_notifications, :error_description, :text, :null => true, :default => nil
28
- change_column :rapns_notifications, :sound, :string, :default => 'default'
27
+ change_column :rapns_notifications, :error_description, :text, null: true, default: nil
28
+ change_column :rapns_notifications, :sound, :string, default: 'default'
29
29
 
30
30
  rename_column :rapns_notifications, :attributes_for_device, :data
31
31
  rename_column :rapns_apps, :key, :name
32
32
 
33
- add_column :rapns_apps, :auth_key, :string, :null => true
33
+ add_column :rapns_apps, :auth_key, :string, null: true
34
34
 
35
- add_column :rapns_notifications, :collapse_key, :string, :null => true
36
- add_column :rapns_notifications, :delay_while_idle, :boolean, :null => false, :default => false
35
+ add_column :rapns_notifications, :collapse_key, :string, null: true
36
+ add_column :rapns_notifications, :delay_while_idle, :boolean, null: false, default: false
37
37
 
38
38
  reg_ids_type = ActiveRecord::Base.connection.adapter_name.include?('Mysql') ? :mediumtext : :text
39
- add_column :rapns_notifications, :registration_ids, reg_ids_type, :null => true
40
- add_column :rapns_notifications, :app_id, :integer, :null => true
41
- add_column :rapns_notifications, :retries, :integer, :null => true, :default => 0
39
+ add_column :rapns_notifications, :registration_ids, reg_ids_type, null: true
40
+ add_column :rapns_notifications, :app_id, :integer, null: true
41
+ add_column :rapns_notifications, :retries, :integer, null: true, default: 0
42
42
 
43
43
  AddGcm::Rapns::Notification.reset_column_information
44
44
  AddGcm::Rapns::App.reset_column_information
@@ -47,30 +47,30 @@ class AddGcm < ActiveRecord::Migration
47
47
  AddGcm::Rapns::Notification.update_all(['app_id = ?', app.id], ['app = ?', app.name])
48
48
  end
49
49
 
50
- change_column :rapns_notifications, :app_id, :integer, :null => false
50
+ change_column :rapns_notifications, :app_id, :integer, null: false
51
51
  remove_column :rapns_notifications, :app
52
52
 
53
53
  if index_name_exists?(:rapns_notifications, "index_rapns_notifications_multi", true)
54
- remove_index :rapns_notifications, :name => "index_rapns_notifications_multi"
54
+ remove_index :rapns_notifications, name: "index_rapns_notifications_multi"
55
55
  elsif index_name_exists?(:rapns_notifications, "index_rapns_notifications_on_delivered_failed_deliver_after", false)
56
- remove_index :rapns_notifications, :name => "index_rapns_notifications_on_delivered_failed_deliver_after"
56
+ remove_index :rapns_notifications, name: "index_rapns_notifications_on_delivered_failed_deliver_after"
57
57
  end
58
- add_index :rapns_notifications, [:app_id, :delivered, :failed, :deliver_after], :name => "index_rapns_notifications_multi"
58
+ add_index :rapns_notifications, [:app_id, :delivered, :failed, :deliver_after], name: "index_rapns_notifications_multi"
59
59
  end
60
60
 
61
61
  def self.down
62
- AddGcm::Rapns::Notification.where(:type => 'Rapns::Gcm::Notification').delete_all
62
+ AddGcm::Rapns::Notification.where(type: 'Rapns::Gcm::Notification').delete_all
63
63
 
64
64
  remove_column :rapns_notifications, :type
65
65
  remove_column :rapns_apps, :type
66
66
 
67
- change_column :rapns_notifications, :device_token, :string, { :null => false, :limit => 64 }
68
- change_column :rapns_notifications, :expiry, :integer, { :null => false, :default => 1.day.to_i }
69
- change_column :rapns_apps, :environment, :string, :null => false
70
- change_column :rapns_apps, :certificate, :text, :null => false
67
+ change_column :rapns_notifications, :device_token, :string, { null: false, limit: 64 }
68
+ change_column :rapns_notifications, :expiry, :integer, { null: false, default: 1.day.to_i }
69
+ change_column :rapns_apps, :environment, :string, null: false
70
+ change_column :rapns_apps, :certificate, :text, null: false
71
71
 
72
- change_column :rapns_notifications, :error_description, :string, :null => true, :default => nil
73
- change_column :rapns_notifications, :sound, :string, :default => '1.aiff'
72
+ change_column :rapns_notifications, :error_description, :string, null: true, default: nil
73
+ change_column :rapns_notifications, :sound, :string, default: '1.aiff'
74
74
 
75
75
  rename_column :rapns_notifications, :data, :attributes_for_device
76
76
  rename_column :rapns_apps, :name, :key
@@ -82,7 +82,7 @@ class AddGcm < ActiveRecord::Migration
82
82
  remove_column :rapns_notifications, :registration_ids
83
83
  remove_column :rapns_notifications, :retries
84
84
 
85
- add_column :rapns_notifications, :app, :string, :null => true
85
+ add_column :rapns_notifications, :app, :string, null: true
86
86
 
87
87
  AddGcm::Rapns::Notification.reset_column_information
88
88
  AddGcm::Rapns::App.reset_column_information
@@ -92,11 +92,11 @@ class AddGcm < ActiveRecord::Migration
92
92
  end
93
93
 
94
94
  if index_name_exists?(:rapns_notifications, :index_rapns_notifications_multi, true)
95
- remove_index :rapns_notifications, :name => :index_rapns_notifications_multi
95
+ remove_index :rapns_notifications, name: :index_rapns_notifications_multi
96
96
  end
97
97
 
98
98
  remove_column :rapns_notifications, :app_id
99
99
 
100
- add_index :rapns_notifications, [:delivered, :failed, :deliver_after], :name => :index_rapns_notifications_multi
100
+ add_index :rapns_notifications, [:delivered, :failed, :deliver_after], name: :index_rapns_notifications_multi
101
101
  end
102
102
  end
@@ -44,28 +44,28 @@ class AddRpush < ActiveRecord::Migration
44
44
  class CreateRapnsNotifications < ActiveRecord::Migration
45
45
  def self.up
46
46
  create_table :rapns_notifications do |t|
47
- t.integer :badge, :null => true
48
- t.string :device_token, :null => false, :limit => 64
49
- t.string :sound, :null => true, :default => "1.aiff"
50
- t.string :alert, :null => true
51
- t.text :attributes_for_device, :null => true
52
- t.integer :expiry, :null => false, :default => 1.day.to_i
53
- t.boolean :delivered, :null => false, :default => false
54
- t.timestamp :delivered_at, :null => true
55
- t.boolean :failed, :null => false, :default => false
56
- t.timestamp :failed_at, :null => true
57
- t.integer :error_code, :null => true
58
- t.string :error_description, :null => true
59
- t.timestamp :deliver_after, :null => true
47
+ t.integer :badge, null: true
48
+ t.string :device_token, null: false, limit: 64
49
+ t.string :sound, null: true, default: "1.aiff"
50
+ t.string :alert, null: true
51
+ t.text :attributes_for_device, null: true
52
+ t.integer :expiry, null: false, default: 1.day.to_i
53
+ t.boolean :delivered, null: false, default: false
54
+ t.timestamp :delivered_at, null: true
55
+ t.boolean :failed, null: false, default: false
56
+ t.timestamp :failed_at, null: true
57
+ t.integer :error_code, null: true
58
+ t.string :error_description, null: true
59
+ t.timestamp :deliver_after, null: true
60
60
  t.timestamps
61
61
  end
62
62
 
63
- add_index :rapns_notifications, [:delivered, :failed, :deliver_after], :name => 'index_rapns_notifications_multi'
63
+ add_index :rapns_notifications, [:delivered, :failed, :deliver_after], name: 'index_rapns_notifications_multi'
64
64
  end
65
65
 
66
66
  def self.down
67
67
  if index_name_exists?(:rapns_notifications, 'index_rapns_notifications_multi', true)
68
- remove_index :rapns_notifications, :name => 'index_rapns_notifications_multi'
68
+ remove_index :rapns_notifications, name: 'index_rapns_notifications_multi'
69
69
  end
70
70
  drop_table :rapns_notifications
71
71
  end
@@ -74,8 +74,8 @@ class AddRpush < ActiveRecord::Migration
74
74
  class CreateRapnsFeedback < ActiveRecord::Migration
75
75
  def self.up
76
76
  create_table :rapns_feedback do |t|
77
- t.string :device_token, :null => false, :limit => 64
78
- t.timestamp :failed_at, :null => false
77
+ t.string :device_token, null: false, limit: 64
78
+ t.timestamp :failed_at, null: false
79
79
  t.timestamps
80
80
  end
81
81
 
@@ -92,7 +92,7 @@ class AddRpush < ActiveRecord::Migration
92
92
 
93
93
  class AddAlertIsJsonToRapnsNotifications < ActiveRecord::Migration
94
94
  def self.up
95
- add_column :rapns_notifications, :alert_is_json, :boolean, :null => true, :default => false
95
+ add_column :rapns_notifications, :alert_is_json, :boolean, null: true, default: false
96
96
  end
97
97
 
98
98
  def self.down
@@ -102,8 +102,8 @@ class AddRpush < ActiveRecord::Migration
102
102
 
103
103
  class AddAppToRapns < ActiveRecord::Migration
104
104
  def self.up
105
- add_column :rapns_notifications, :app, :string, :null => true
106
- add_column :rapns_feedback, :app, :string, :null => true
105
+ add_column :rapns_notifications, :app, :string, null: true
106
+ add_column :rapns_feedback, :app, :string, null: true
107
107
  end
108
108
 
109
109
  def self.down
@@ -115,11 +115,11 @@ class AddRpush < ActiveRecord::Migration
115
115
  class CreateRapnsApps < ActiveRecord::Migration
116
116
  def self.up
117
117
  create_table :rapns_apps do |t|
118
- t.string :key, :null => false
119
- t.string :environment, :null => false
120
- t.text :certificate, :null => false
121
- t.string :password, :null => true
122
- t.integer :connections, :null => false, :default => 1
118
+ t.string :key, null: false
119
+ t.string :environment, null: false
120
+ t.text :certificate, null: false
121
+ t.string :password, null: true
122
+ t.integer :connections, null: false, default: 1
123
123
  t.timestamps
124
124
  end
125
125
  end
@@ -142,66 +142,66 @@ class AddRpush < ActiveRecord::Migration
142
142
  end
143
143
 
144
144
  def self.up
145
- add_column :rapns_notifications, :type, :string, :null => true
146
- add_column :rapns_apps, :type, :string, :null => true
145
+ add_column :rapns_notifications, :type, :string, null: true
146
+ add_column :rapns_apps, :type, :string, null: true
147
147
 
148
- AddGcm::Rapns::Notification.update_all :type => 'Rapns::Apns::Notification'
149
- AddGcm::Rapns::App.update_all :type => 'Rapns::Apns::App'
148
+ AddGcm::Rapns::Notification.update_all type: 'Rapns::Apns::Notification'
149
+ AddGcm::Rapns::App.update_all type: 'Rapns::Apns::App'
150
150
 
151
- change_column :rapns_notifications, :type, :string, :null => false
152
- change_column :rapns_apps, :type, :string, :null => false
153
- change_column :rapns_notifications, :device_token, :string, { :null => true, :limit => 64 }
154
- change_column :rapns_notifications, :expiry, :integer, { :null => true, :default => 1.day.to_i }
155
- change_column :rapns_apps, :environment, :string, :null => true
156
- change_column :rapns_apps, :certificate, :text, :null => true, :default => nil
151
+ change_column :rapns_notifications, :type, :string, null: false
152
+ change_column :rapns_apps, :type, :string, null: false
153
+ change_column :rapns_notifications, :device_token, :string, { null: true, limit: 64 }
154
+ change_column :rapns_notifications, :expiry, :integer, { null: true, default: 1.day.to_i }
155
+ change_column :rapns_apps, :environment, :string, null: true
156
+ change_column :rapns_apps, :certificate, :text, null: true, default: nil
157
157
 
158
- change_column :rapns_notifications, :error_description, :text, :null => true, :default => nil
159
- change_column :rapns_notifications, :sound, :string, :default => 'default'
158
+ change_column :rapns_notifications, :error_description, :text, null: true, default: nil
159
+ change_column :rapns_notifications, :sound, :string, default: 'default'
160
160
 
161
161
  rename_column :rapns_notifications, :attributes_for_device, :data
162
162
  rename_column :rapns_apps, :key, :name
163
163
 
164
- add_column :rapns_apps, :auth_key, :string, :null => true
164
+ add_column :rapns_apps, :auth_key, :string, null: true
165
165
 
166
- add_column :rapns_notifications, :collapse_key, :string, :null => true
167
- add_column :rapns_notifications, :delay_while_idle, :boolean, :null => false, :default => false
166
+ add_column :rapns_notifications, :collapse_key, :string, null: true
167
+ add_column :rapns_notifications, :delay_while_idle, :boolean, null: false, default: false
168
168
 
169
169
  reg_ids_type = ActiveRecord::Base.connection.adapter_name.include?('Mysql') ? :mediumtext : :text
170
- add_column :rapns_notifications, :registration_ids, reg_ids_type, :null => true
171
- add_column :rapns_notifications, :app_id, :integer, :null => true
172
- add_column :rapns_notifications, :retries, :integer, :null => true, :default => 0
170
+ add_column :rapns_notifications, :registration_ids, reg_ids_type, null: true
171
+ add_column :rapns_notifications, :app_id, :integer, null: true
172
+ add_column :rapns_notifications, :retries, :integer, null: true, default: 0
173
173
 
174
174
  AddGcm::Rapns::Notification.reset_column_information
175
175
  AddGcm::Rapns::App.reset_column_information
176
176
 
177
177
  AddGcm::Rapns::App.all.each do |app|
178
- AddGcm::Rapns::Notification.update_all(['app_id = ?', app.id], ['app = ?', app.name])
178
+ AddGcm::Rapns::Notification.where(app: app.name).update_all(app_id: app.id)
179
179
  end
180
180
 
181
- change_column :rapns_notifications, :app_id, :integer, :null => false
181
+ change_column :rapns_notifications, :app_id, :integer, null: false
182
182
  remove_column :rapns_notifications, :app
183
183
 
184
184
  if index_name_exists?(:rapns_notifications, "index_rapns_notifications_multi", true)
185
- remove_index :rapns_notifications, :name => "index_rapns_notifications_multi"
185
+ remove_index :rapns_notifications, name: "index_rapns_notifications_multi"
186
186
  elsif index_name_exists?(:rapns_notifications, "index_rapns_notifications_on_delivered_failed_deliver_after", false)
187
- remove_index :rapns_notifications, :name => "index_rapns_notifications_on_delivered_failed_deliver_after"
187
+ remove_index :rapns_notifications, name: "index_rapns_notifications_on_delivered_failed_deliver_after"
188
188
  end
189
- add_index :rapns_notifications, [:app_id, :delivered, :failed, :deliver_after], :name => "index_rapns_notifications_multi"
189
+ add_index :rapns_notifications, [:app_id, :delivered, :failed, :deliver_after], name: "index_rapns_notifications_multi"
190
190
  end
191
191
 
192
192
  def self.down
193
- AddGcm::Rapns::Notification.where(:type => 'Rapns::Gcm::Notification').delete_all
193
+ AddGcm::Rapns::Notification.where(type: 'Rapns::Gcm::Notification').delete_all
194
194
 
195
195
  remove_column :rapns_notifications, :type
196
196
  remove_column :rapns_apps, :type
197
197
 
198
- change_column :rapns_notifications, :device_token, :string, { :null => false, :limit => 64 }
199
- change_column :rapns_notifications, :expiry, :integer, { :null => false, :default => 1.day.to_i }
200
- change_column :rapns_apps, :environment, :string, :null => false
201
- change_column :rapns_apps, :certificate, :text, :null => false
198
+ change_column :rapns_notifications, :device_token, :string, { null: false, limit: 64 }
199
+ change_column :rapns_notifications, :expiry, :integer, { null: false, default: 1.day.to_i }
200
+ change_column :rapns_apps, :environment, :string, null: false
201
+ change_column :rapns_apps, :certificate, :text, null: false
202
202
 
203
- change_column :rapns_notifications, :error_description, :string, :null => true, :default => nil
204
- change_column :rapns_notifications, :sound, :string, :default => '1.aiff'
203
+ change_column :rapns_notifications, :error_description, :string, null: true, default: nil
204
+ change_column :rapns_notifications, :sound, :string, default: '1.aiff'
205
205
 
206
206
  rename_column :rapns_notifications, :data, :attributes_for_device
207
207
  rename_column :rapns_apps, :name, :key
@@ -213,22 +213,22 @@ class AddRpush < ActiveRecord::Migration
213
213
  remove_column :rapns_notifications, :registration_ids
214
214
  remove_column :rapns_notifications, :retries
215
215
 
216
- add_column :rapns_notifications, :app, :string, :null => true
216
+ add_column :rapns_notifications, :app, :string, null: true
217
217
 
218
218
  AddGcm::Rapns::Notification.reset_column_information
219
219
  AddGcm::Rapns::App.reset_column_information
220
220
 
221
221
  AddGcm::Rapns::App.all.each do |app|
222
- AddGcm::Rapns::Notification.update_all(['app = ?', app.key], ['app_id = ?', app.id])
222
+ AddGcm::Rapns::Notification.where(app_id: app.id).update_all(app: app.key)
223
223
  end
224
224
 
225
225
  if index_name_exists?(:rapns_notifications, :index_rapns_notifications_multi, true)
226
- remove_index :rapns_notifications, :name => :index_rapns_notifications_multi
226
+ remove_index :rapns_notifications, name: :index_rapns_notifications_multi
227
227
  end
228
228
 
229
229
  remove_column :rapns_notifications, :app_id
230
230
 
231
- add_index :rapns_notifications, [:delivered, :failed, :deliver_after], :name => :index_rapns_notifications_multi
231
+ add_index :rapns_notifications, [:delivered, :failed, :deliver_after], name: :index_rapns_notifications_multi
232
232
  end
233
233
  end
234
234
 
@@ -240,11 +240,11 @@ class AddRpush < ActiveRecord::Migration
240
240
  end
241
241
 
242
242
  def self.up
243
- add_column :rapns_notifications, :uri, :string, :null => true
243
+ add_column :rapns_notifications, :uri, :string, null: true
244
244
  end
245
245
 
246
246
  def self.down
247
- AddWpns::Rapns::Notification.where(:type => 'Rapns::Wpns::Notification').delete_all
247
+ AddWpns::Rapns::Notification.where(type: 'Rapns::Wpns::Notification').delete_all
248
248
  remove_column :rapns_notifications, :uri
249
249
  end
250
250
  end
@@ -257,14 +257,14 @@ class AddRpush < ActiveRecord::Migration
257
257
  end
258
258
 
259
259
  def self.up
260
- add_column :rapns_apps, :client_id, :string, :null => true
261
- add_column :rapns_apps, :client_secret, :string, :null => true
262
- add_column :rapns_apps, :access_token, :string, :null => true
263
- add_column :rapns_apps, :access_token_expiration, :datetime, :null => true
260
+ add_column :rapns_apps, :client_id, :string, null: true
261
+ add_column :rapns_apps, :client_secret, :string, null: true
262
+ add_column :rapns_apps, :access_token, :string, null: true
263
+ add_column :rapns_apps, :access_token_expiration, :datetime, null: true
264
264
  end
265
265
 
266
266
  def self.down
267
- AddAdm::Rapns::Notification.where(:type => 'Rapns::Adm::Notification').delete_all
267
+ AddAdm::Rapns::Notification.where(type: 'Rapns::Adm::Notification').delete_all
268
268
 
269
269
  remove_column :rapns_apps, :client_id
270
270
  remove_column :rapns_apps, :client_secret
@@ -339,7 +339,7 @@ class AddRpush < ActiveRecord::Migration
339
339
 
340
340
  class AddFailAfterToRpushNotifications < ActiveRecord::Migration
341
341
  def self.up
342
- add_column :rpush_notifications, :fail_after, :timestamp, :null => true
342
+ add_column :rpush_notifications, :fail_after, :timestamp, null: true
343
343
  end
344
344
 
345
345
  def self.down