rpush 2.4.0 → 2.5.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -0
- data/README.md +11 -7
- data/lib/generators/templates/rpush.rb +8 -2
- data/lib/generators/templates/rpush_2_0_0_updates.rb +1 -1
- data/lib/rpush/cli.rb +61 -27
- data/lib/rpush/client/active_model.rb +3 -0
- data/lib/rpush/client/active_model/apns/notification.rb +1 -1
- data/lib/rpush/client/active_model/wns/app.rb +23 -0
- data/lib/rpush/client/active_model/wns/notification.rb +28 -0
- data/lib/rpush/client/active_model/wpns/notification.rb +11 -6
- data/lib/rpush/client/active_record.rb +3 -0
- data/lib/rpush/client/active_record/wns/app.rb +11 -0
- data/lib/rpush/client/active_record/wns/notification.rb +11 -0
- data/lib/rpush/client/mongoid.rb +3 -0
- data/lib/rpush/client/mongoid/apns/feedback.rb +3 -0
- data/lib/rpush/client/mongoid/notification.rb +6 -0
- data/lib/rpush/client/mongoid/wns/app.rb +14 -0
- data/lib/rpush/client/mongoid/wns/notification.rb +11 -0
- data/lib/rpush/client/redis.rb +3 -0
- data/lib/rpush/client/redis/wns/app.rb +14 -0
- data/lib/rpush/client/redis/wns/notification.rb +11 -0
- data/lib/rpush/configuration.rb +3 -7
- data/lib/rpush/daemon.rb +9 -0
- data/lib/rpush/daemon/apns/feedback_receiver.rb +5 -0
- data/lib/rpush/daemon/app_runner.rb +4 -5
- data/lib/rpush/daemon/dispatcher/apns_tcp.rb +47 -12
- data/lib/rpush/daemon/dispatcher_loop.rb +5 -0
- data/lib/rpush/daemon/feeder.rb +11 -0
- data/lib/rpush/daemon/interruptible_sleep.rb +8 -3
- data/lib/rpush/daemon/loggable.rb +4 -0
- data/lib/rpush/daemon/rpc.rb +9 -0
- data/lib/rpush/daemon/rpc/client.rb +27 -0
- data/lib/rpush/daemon/rpc/server.rb +82 -0
- data/lib/rpush/daemon/signal_handler.rb +7 -0
- data/lib/rpush/daemon/store/active_record.rb +17 -3
- data/lib/rpush/daemon/store/mongoid.rb +2 -2
- data/lib/rpush/daemon/store/redis.rb +2 -2
- data/lib/rpush/daemon/tcp_connection.rb +2 -2
- data/lib/rpush/daemon/wns.rb +9 -0
- data/lib/rpush/daemon/wns/delivery.rb +206 -0
- data/lib/rpush/embed.rb +15 -13
- data/lib/rpush/logger.rb +4 -0
- data/lib/rpush/plugin.rb +1 -1
- data/lib/rpush/push.rb +2 -11
- data/lib/rpush/reflection_collection.rb +15 -17
- data/lib/rpush/reflection_public_methods.rb +6 -4
- data/lib/rpush/version.rb +1 -1
- data/spec/functional/apns_spec.rb +1 -11
- data/spec/functional/cli_spec.rb +35 -0
- data/spec/functional_spec_helper.rb +11 -1
- data/spec/spec_helper.rb +4 -3
- data/spec/support/active_record_setup.rb +1 -1
- data/spec/unit/client/active_record/apns/notification_spec.rb +1 -1
- data/spec/unit/configuration_spec.rb +0 -7
- data/spec/unit/daemon/adm/delivery_spec.rb +2 -2
- data/spec/unit/daemon/app_runner_spec.rb +2 -3
- data/spec/unit/daemon/gcm/delivery_spec.rb +1 -1
- data/spec/unit/daemon/tcp_connection_spec.rb +1 -1
- data/spec/unit/daemon/wns/delivery_spec.rb +171 -0
- data/spec/unit/daemon/wpns/delivery_spec.rb +1 -1
- data/spec/unit/daemon_spec.rb +2 -0
- data/spec/unit/embed_spec.rb +4 -11
- data/spec/unit/logger_spec.rb +2 -2
- data/spec/unit/push_spec.rb +0 -7
- data/spec/unit_spec_helper.rb +1 -1
- metadata +20 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8e562313c0e7b3ce34abf0013edf503f2f5dd4d2
|
4
|
+
data.tar.gz: 1b3e1799010d17074316c353e77f8bef16bf54a7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd1b05e4f6a848428b2d3f008e57806f062b9803605d2544b9ad45a26e4e2f90f56f1af095a56963d1e3f2b5edf835e07694b758bec2fca036171de3135543bc
|
7
|
+
data.tar.gz: 85f65b3f5278077a738dbbc10ae16f1eeae6ece50cfdde65c9333a053ea595551ce071aa9e68a52acdf9ce4710230bda6d9d866f97f69352fcc9e63ffdc23014
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
## 2.5.0 (July 19, 2015)
|
2
|
+
Features:
|
3
|
+
* Add 'rpush status' to inspect running Rpush internal status.
|
4
|
+
* ActiveRecord logging is no longer redirected to rpush.log when embedded (#138).
|
5
|
+
* Support for WNS (Windows RT) (#137).
|
6
|
+
* Indexes added to some Mongoid fields (#151).
|
7
|
+
* Added support for Oracle.
|
8
|
+
|
9
|
+
Bug fixes:
|
10
|
+
* Fix for handling APNs error when using `rpush push` or `Rpush.push`.
|
11
|
+
* Fix backwards compatibility issue with ActiveRecord (#144).
|
12
|
+
|
1
13
|
## 2.4.0 (Fed 18, 2015)
|
2
14
|
Features:
|
3
15
|
* Support for MongoDB (using Mongoid).
|
data/README.md
CHANGED
@@ -1,7 +1,5 @@
|
|
1
|
-
[](http://travis-ci.org/rpush/rpush)
|
2
|
-
[](https://codeclimate.com/github/rpush/rpush)
|
3
|
-
[](https://codeclimate.com/github/rpush/rpush)
|
4
1
|
[](http://badge.fury.io/rb/rpush)
|
2
|
+
[](https://gitter.im/rpush/rpush?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
5
3
|
|
6
4
|
<img src="https://raw.github.com/rpush/rpush/master/logo.png" align="right" width="200px" />
|
7
5
|
|
@@ -21,9 +19,9 @@ Rpush aims to be the *de facto* gem for sending push notifications in Ruby. Its
|
|
21
19
|
|
22
20
|
* Use [**ActiveRecord**](https://github.com/rpush/rpush/wiki/Using-ActiveRecord), [**Redis**](https://github.com/rpush/rpush/wiki/Using-Redis) or [**MongoDB**](https://github.com/rpush/rpush/wiki/Using-Mongodb) for storage.
|
23
21
|
* Plugins for [**Bugsnag**](https://github.com/rpush/rpush-plugin-bugsnag),
|
24
|
-
[**Sentry**](https://github.com/rpush/rpush-plugin-sentry), [**StatsD**](https://github.com/rpush/rpush-plugin-statsd).
|
22
|
+
[**Sentry**](https://github.com/rpush/rpush-plugin-sentry), [**StatsD**](https://github.com/rpush/rpush-plugin-statsd) or [write your own](https://github.com/rpush/rpush/wiki/Writing-a-Plugin).
|
25
23
|
* Seamless integration with your projects, including **Rails**.
|
26
|
-
* Run as a [daemon](https://github.com/rpush/rpush#as-a-daemon
|
24
|
+
* Run as a [daemon](https://github.com/rpush/rpush#as-a-daemon), inside a [job queue](https://github.com/rpush/rpush/wiki/Push-API), on the [command-line](https://github.com/rpush/rpush#on-the-command-line) or [embedded](https://github.com/rpush/rpush/wiki/Embedding-API) in another process.
|
27
25
|
* Scales vertically (threading) and horizontally (multiple processes).
|
28
26
|
* Designed for uptime - new apps are loaded automatically, signal `HUP` to update running apps.
|
29
27
|
* Hooks for fine-grained instrumentation and error handling ([Reflection API](https://github.com/rpush/rpush/wiki/Reflection-API)).
|
@@ -87,7 +85,7 @@ app.save!
|
|
87
85
|
```ruby
|
88
86
|
n = Rpush::Gcm::Notification.new
|
89
87
|
n.app = Rpush::Gcm::App.find_by_name("android_app")
|
90
|
-
n.registration_ids = ["
|
88
|
+
n.registration_ids = ["..."]
|
91
89
|
n.data = { message: "hi mom!" }
|
92
90
|
n.save!
|
93
91
|
```
|
@@ -198,6 +196,7 @@ You should run `rpush init` after upgrading Rpush to check for configuration and
|
|
198
196
|
* [Reflection API](https://github.com/rpush/rpush/wiki/Reflection-API)
|
199
197
|
* [Push API](https://github.com/rpush/rpush/wiki/Push-API)
|
200
198
|
* [Embedding API](https://github.com/rpush/rpush/wiki/Embedding-API)
|
199
|
+
* [Writing a Plugin](https://github.com/rpush/rpush/wiki/Writing-a-Plugin)
|
201
200
|
* [Implementing your own storage backend](https://github.com/rpush/rpush/wiki/Implementing-your-own-storage-backend)
|
202
201
|
* [Upgrading from 2.x to 3.0](https://github.com/rpush/rpush/wiki/Upgrading-from-version-2.x-to-3.0)
|
203
202
|
|
@@ -223,4 +222,9 @@ Note that the database username is changed at runtime to be the currently logged
|
|
223
222
|
with mysql and you're using a user named 'bob', you will need to grant a mysql user 'bob' access to the 'rpush_test'
|
224
223
|
mysql database.
|
225
224
|
|
226
|
-
To switch between ActiveRecord and Redis, set the `CLIENT` environment variable to either
|
225
|
+
To switch between ActiveRecord and Redis, set the `CLIENT` environment variable to either `active_record`, `redis` or `mongoid`.
|
226
|
+
|
227
|
+
|
228
|
+
[](http://travis-ci.org/rpush/rpush)
|
229
|
+
[](https://codeclimate.com/github/rpush/rpush)
|
230
|
+
[](https://codeclimate.com/github/rpush/rpush)
|
@@ -21,7 +21,7 @@ Rpush.configure do |config|
|
|
21
21
|
# Path to log file. Relative to current directory unless absolute.
|
22
22
|
config.log_file = 'log/rpush.log'
|
23
23
|
|
24
|
-
config.log_level = (defined?(Rails) && Rails.logger) ? Rails.logger.level : ::Logger::Severity::
|
24
|
+
config.log_level = (defined?(Rails) && Rails.logger) ? Rails.logger.level : ::Logger::Severity::INFO
|
25
25
|
|
26
26
|
# Define a custom logger.
|
27
27
|
# config.logger = MyLogger.new
|
@@ -29,7 +29,7 @@ Rpush.configure do |config|
|
|
29
29
|
# config.apns.feedback_receiver.enabled = true
|
30
30
|
# config.apns.feedback_receiver.frequency = 60
|
31
31
|
|
32
|
-
|
32
|
+
end
|
33
33
|
|
34
34
|
Rpush.reflect do |on|
|
35
35
|
|
@@ -123,6 +123,12 @@ Rpush.reflect do |on|
|
|
123
123
|
# on.adm_failed_to_recipient do |notification, registration_id, reason|
|
124
124
|
# end
|
125
125
|
|
126
|
+
# Called when Failed to deliver to WNS. Check the 'reason' string for further
|
127
|
+
# explanations.
|
128
|
+
# You should remove this uri from your records
|
129
|
+
# on.wns_invalid_channel do |notification, uri, reason|
|
130
|
+
# end
|
131
|
+
|
126
132
|
# Called when an exception is raised.
|
127
133
|
# on.error do |error|
|
128
134
|
# end
|
@@ -58,7 +58,7 @@ class Rpush200Updates < ActiveRecord::Migration
|
|
58
58
|
|
59
59
|
def self.adapter_name
|
60
60
|
env = (defined?(Rails) && Rails.env) ? Rails.env : 'development'
|
61
|
-
ActiveRecord::Base.configurations[env][
|
61
|
+
Hash[ActiveRecord::Base.configurations[env].map { |k,v| [k.to_sym,v] }][:adapter]
|
62
62
|
end
|
63
63
|
|
64
64
|
def self.postgresql?
|
data/lib/rpush/cli.rb
CHANGED
@@ -30,28 +30,23 @@ module Rpush
|
|
30
30
|
option 'pid-file', type: :string, aliases: '-p'
|
31
31
|
def stop
|
32
32
|
config_setup
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
break
|
47
|
-
end
|
33
|
+
pid = rpush_process_pid
|
34
|
+
return unless pid
|
35
|
+
|
36
|
+
STDOUT.write "* Stopping Rpush (pid #{pid})... "
|
37
|
+
STDOUT.flush
|
38
|
+
Process.kill('TERM', pid)
|
39
|
+
|
40
|
+
loop do
|
41
|
+
begin
|
42
|
+
Process.getpgid(pid)
|
43
|
+
sleep 0.05
|
44
|
+
rescue Errno::ESRCH
|
45
|
+
break
|
48
46
|
end
|
49
|
-
|
50
|
-
puts ANSI.green { '✔' }
|
51
|
-
else
|
52
|
-
STDERR.puts("* Rpush isn't running? #{Rpush.config.pid_file} does not exist.")
|
53
|
-
return
|
54
47
|
end
|
48
|
+
|
49
|
+
puts ANSI.green { '✔' }
|
55
50
|
end
|
56
51
|
|
57
52
|
desc 'init', 'Initialize Rpush into the current directory'
|
@@ -96,6 +91,15 @@ module Rpush
|
|
96
91
|
Rpush.push
|
97
92
|
end
|
98
93
|
|
94
|
+
desc 'status', 'Show the internal status of the running Rpush instance.'
|
95
|
+
def status
|
96
|
+
require 'rpush/daemon'
|
97
|
+
rpc = Rpush::Daemon::Rpc::Client.new(rpush_process_pid)
|
98
|
+
status = rpc.status
|
99
|
+
rpc.close
|
100
|
+
puts humanize_json(status)
|
101
|
+
end
|
102
|
+
|
99
103
|
desc 'version', 'Print Rpush version'
|
100
104
|
def version
|
101
105
|
puts Rpush::VERSION
|
@@ -146,13 +150,6 @@ module Rpush
|
|
146
150
|
self.class.default_config_path
|
147
151
|
end
|
148
152
|
|
149
|
-
def ensure_pid_file_set
|
150
|
-
return unless Rpush.config.pid_file.blank?
|
151
|
-
|
152
|
-
STDERR.puts(ANSI.red { 'ERROR: ' } + 'config.pid_file is not set.')
|
153
|
-
exit 1
|
154
|
-
end
|
155
|
-
|
156
153
|
def check_ruby_version
|
157
154
|
STDERR.puts(ANSI.yellow { 'WARNING: ' } + "You are using an old and unsupported version of Ruby.") if RUBY_VERSION <= '1.9.3' && RUBY_ENGINE == 'ruby'
|
158
155
|
end
|
@@ -173,5 +170,42 @@ module Rpush
|
|
173
170
|
new_options.freeze
|
174
171
|
self.options = new_options
|
175
172
|
end
|
173
|
+
|
174
|
+
def rpush_process_pid
|
175
|
+
if Rpush.config.pid_file.blank?
|
176
|
+
STDERR.puts(ANSI.red { 'ERROR: ' } + 'config.pid_file is not set.')
|
177
|
+
exit 1
|
178
|
+
end
|
179
|
+
|
180
|
+
unless File.exist?(Rpush.config.pid_file)
|
181
|
+
STDERR.puts("* Rpush isn't running? #{Rpush.config.pid_file} does not exist.")
|
182
|
+
exit 1
|
183
|
+
end
|
184
|
+
|
185
|
+
File.read(Rpush.config.pid_file).strip.to_i
|
186
|
+
end
|
187
|
+
|
188
|
+
def humanize_json(node, str = '', depth = 0) # rubocop:disable Metrics/PerceivedComplexity
|
189
|
+
if node.is_a?(Hash)
|
190
|
+
node = node.sort_by { |_, v| [Array, Hash].include?(v.class) ? 1 : 0 }
|
191
|
+
node.each do |k, v|
|
192
|
+
if [Array, Hash].include?(v.class)
|
193
|
+
str << "\n#{' ' * depth}#{k}:\n"
|
194
|
+
humanize_json(v, str, depth + 1)
|
195
|
+
else
|
196
|
+
str << "#{' ' * depth}#{k}: #{v}\n"
|
197
|
+
end
|
198
|
+
end
|
199
|
+
elsif node.is_a?(Array)
|
200
|
+
node.each do |v|
|
201
|
+
str << "\n" if v.is_a?(Hash)
|
202
|
+
humanize_json(v, str, depth)
|
203
|
+
end
|
204
|
+
else
|
205
|
+
str << "#{' ' * depth}#{node}\n"
|
206
|
+
end
|
207
|
+
|
208
|
+
str
|
209
|
+
end
|
176
210
|
end
|
177
211
|
end
|
@@ -64,7 +64,7 @@ module Rpush
|
|
64
64
|
json
|
65
65
|
end
|
66
66
|
|
67
|
-
def to_binary(options = {})
|
67
|
+
def to_binary(options = {})
|
68
68
|
frame_payload = payload
|
69
69
|
frame_id = options[:for_validation] ? 0 : send(options.fetch(:id_attribute, :id))
|
70
70
|
frame = ""
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Rpush
|
2
|
+
module Client
|
3
|
+
module ActiveModel
|
4
|
+
module Wns
|
5
|
+
module App
|
6
|
+
def self.included(base)
|
7
|
+
base.instance_eval do
|
8
|
+
validates :client_id, :client_secret, presence: true
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def access_token_expired?
|
13
|
+
access_token_expiration.nil? || access_token_expiration < Time.now
|
14
|
+
end
|
15
|
+
|
16
|
+
def service_name
|
17
|
+
'wns'
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Rpush
|
2
|
+
module Client
|
3
|
+
module ActiveModel
|
4
|
+
module Wns
|
5
|
+
module Notification
|
6
|
+
module InstanceMethods
|
7
|
+
def alert=(value)
|
8
|
+
return unless value
|
9
|
+
data = self.data || {}
|
10
|
+
data['title'] = value
|
11
|
+
self.data = data
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.included(base)
|
16
|
+
base.instance_eval do
|
17
|
+
include InstanceMethods
|
18
|
+
|
19
|
+
validates :uri, presence: true
|
20
|
+
validates :uri, format: { with: %r{https?://[\S]+} }
|
21
|
+
validates :data, presence: true
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -3,12 +3,7 @@ module Rpush
|
|
3
3
|
module ActiveModel
|
4
4
|
module Wpns
|
5
5
|
module Notification
|
6
|
-
|
7
|
-
base.instance_eval do
|
8
|
-
validates :uri, presence: true
|
9
|
-
validates :uri, format: { with: %r{https?://[\S]+} }
|
10
|
-
validates :data, presence: true
|
11
|
-
end
|
6
|
+
module InstanceMethods
|
12
7
|
def alert=(value)
|
13
8
|
return unless value
|
14
9
|
data = self.data || {}
|
@@ -16,6 +11,16 @@ module Rpush
|
|
16
11
|
self.data = data
|
17
12
|
end
|
18
13
|
end
|
14
|
+
|
15
|
+
def self.included(base)
|
16
|
+
base.instance_eval do
|
17
|
+
include InstanceMethods
|
18
|
+
|
19
|
+
validates :uri, presence: true
|
20
|
+
validates :uri, format: { with: %r{https?://[\S]+} }
|
21
|
+
validates :data, presence: true
|
22
|
+
end
|
23
|
+
end
|
19
24
|
end
|
20
25
|
end
|
21
26
|
end
|
@@ -15,5 +15,8 @@ require 'rpush/client/active_record/gcm/app'
|
|
15
15
|
require 'rpush/client/active_record/wpns/notification'
|
16
16
|
require 'rpush/client/active_record/wpns/app'
|
17
17
|
|
18
|
+
require 'rpush/client/active_record/wns/notification'
|
19
|
+
require 'rpush/client/active_record/wns/app'
|
20
|
+
|
18
21
|
require 'rpush/client/active_record/adm/notification'
|
19
22
|
require 'rpush/client/active_record/adm/app'
|
data/lib/rpush/client/mongoid.rb
CHANGED
@@ -27,5 +27,8 @@ require 'rpush/client/mongoid/gcm/app'
|
|
27
27
|
require 'rpush/client/mongoid/wpns/notification'
|
28
28
|
require 'rpush/client/mongoid/wpns/app'
|
29
29
|
|
30
|
+
require 'rpush/client/mongoid/wns/notification'
|
31
|
+
require 'rpush/client/mongoid/wns/app'
|
32
|
+
|
30
33
|
require 'rpush/client/mongoid/adm/notification'
|
31
34
|
require 'rpush/client/mongoid/adm/app'
|
@@ -3,6 +3,7 @@ module Rpush
|
|
3
3
|
module Mongoid
|
4
4
|
class Notification
|
5
5
|
include ::Mongoid::Document
|
6
|
+
include ::Mongoid::Timestamps
|
6
7
|
include ::Mongoid::Autoinc
|
7
8
|
include Rpush::MultiJsonHelper
|
8
9
|
include Rpush::Client::ActiveModel::Notification
|
@@ -36,6 +37,11 @@ module Rpush
|
|
36
37
|
increments :integer_id, model_name: name
|
37
38
|
index integer_id: 1
|
38
39
|
|
40
|
+
index delivered: 1, failed: 1, deliver_after: 1, processing: 1
|
41
|
+
index delivered: 1, failed: 1
|
42
|
+
index device_token: 1
|
43
|
+
index app_id: 1
|
44
|
+
|
39
45
|
belongs_to :app
|
40
46
|
end
|
41
47
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Rpush
|
2
|
+
module Client
|
3
|
+
module Mongoid
|
4
|
+
module Wns
|
5
|
+
class App < Rpush::Client::Mongoid::App
|
6
|
+
include Rpush::Client::ActiveModel::Wns::App
|
7
|
+
|
8
|
+
field :access_token, type: String
|
9
|
+
field :access_token_expiration, type: Time
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|