pushr-core 1.0.0.pre.3 → 1.0.0.pre.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +13 -4
- data/lib/pushr/configuration.rb +1 -1
- data/lib/pushr/daemon/app.rb +7 -18
- data/lib/pushr/daemon/delivery_error.rb +1 -1
- data/lib/pushr/daemon/settings.rb +2 -1
- data/lib/pushr/feedback.rb +1 -1
- data/lib/pushr/message.rb +6 -1
- data/lib/pushr/version.rb +1 -1
- data/spec/support/pushr_dummy.rb +16 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c4013d245094a4659d51610f6448da91813c933e
|
4
|
+
data.tar.gz: dad963d156b9b3d0fda568a7fdbc2426d8ef8230
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 03bb413cee574cbe9c314fd52352e91ba0265d345afff11b2db1d811800eaede790823367d6c9ab96d33658b178172ba45637424429a34994b18c10947b4f60c
|
7
|
+
data.tar.gz: 568ff09d71fd0546c0c6508f29d0c5cf2579f80159cb763e75772338132530d36dd353969c3ef87c0c784c1f9f73beaf07f3845e7f7a634cc114a39e340d1912
|
data/README.md
CHANGED
@@ -43,13 +43,21 @@ it will use that. The configuration is stored in Redis and you add the configura
|
|
43
43
|
APNS ([see](https://github.com/9to5/pushr-core#generating-certificates)):
|
44
44
|
```ruby
|
45
45
|
Pushr::ConfigurationApns.create(app: 'app_name', connections: 2, enabled: true,
|
46
|
-
certificate: File.read('certificate.pem'),
|
46
|
+
certificate: File.read('certificate.pem'), sandbox: false, skip_check_for_error: false)
|
47
47
|
```
|
48
48
|
|
49
|
-
The `skip_check_for_error` parameter
|
49
|
+
The `skip_check_for_error` parameter can be set to `true` or `false`. If set to `true` the APNS service
|
50
50
|
will not check for errors when sending messages. This option should be used in a production environment and improves
|
51
51
|
performance. In production the errors are reported and handled by the feedback service. Please note that if you use
|
52
|
-
sandbox devices in your production environment you should not `skip_check_for_error`.
|
52
|
+
sandbox devices in your production environment you should not set `skip_check_for_error = true`.
|
53
|
+
|
54
|
+
APNS Feedback:
|
55
|
+
```ruby
|
56
|
+
Pushr::ConfigurationApnsFeedback.create(app: 'app_name', connections: 1, enabled: true,
|
57
|
+
feedback_poll: 60)
|
58
|
+
```
|
59
|
+
|
60
|
+
Use this configuration to let a thread check for feedback on all APNS Configurations. It checks every `feedback_poll` in seconds.
|
53
61
|
|
54
62
|
GCM ([see](http://developer.android.com/guide/google/gcm/gs.html)):
|
55
63
|
```ruby
|
@@ -131,4 +139,5 @@ Push runs on Heroku with the following line in the `Procfile`.
|
|
131
139
|
|
132
140
|
## Prerequisites
|
133
141
|
|
134
|
-
* Ruby 1.9.
|
142
|
+
* Ruby 1.9.3, 2.0, 2.1
|
143
|
+
* Redis
|
data/lib/pushr/configuration.rb
CHANGED
data/lib/pushr/daemon/app.rb
CHANGED
@@ -1,27 +1,25 @@
|
|
1
1
|
module Pushr
|
2
2
|
module Daemon
|
3
3
|
class App
|
4
|
-
@apps =
|
4
|
+
@apps = []
|
5
5
|
|
6
6
|
class << self
|
7
7
|
attr_reader :apps
|
8
8
|
|
9
9
|
def load
|
10
|
-
Configuration.all.
|
11
|
-
@apps["#{config.app}:#{config.name}"] = App.new(config) if config.enabled == true
|
12
|
-
end
|
10
|
+
@apps = Configuration.all.keep_if { |c| c.enabled == true }.map { |c| App.new(c) }
|
13
11
|
end
|
14
12
|
|
15
13
|
def total_connections
|
16
|
-
@apps.
|
14
|
+
@apps.map(&:connections).inject(0, :+)
|
17
15
|
end
|
18
16
|
|
19
17
|
def start
|
20
|
-
@apps.
|
18
|
+
@apps.map(&:start)
|
21
19
|
end
|
22
20
|
|
23
21
|
def stop
|
24
|
-
@apps.
|
22
|
+
@apps.map(&:stop)
|
25
23
|
end
|
26
24
|
end
|
27
25
|
|
@@ -37,19 +35,10 @@ module Pushr
|
|
37
35
|
|
38
36
|
def start
|
39
37
|
@provider = load_provider(@config.name, @config)
|
40
|
-
|
41
|
-
@config.connections.times do |i|
|
42
|
-
connection = @provider.connectiontype.new(@config, i + 1)
|
43
|
-
connection.connect
|
44
|
-
|
45
|
-
handler = MessageHandler.new("pushr:#{@config.app}:#{@config.name}", connection, @config.app, i + 1)
|
46
|
-
handler.start
|
47
|
-
@handlers << handler
|
48
|
-
end
|
38
|
+
@provider.start
|
49
39
|
end
|
50
40
|
|
51
41
|
def stop
|
52
|
-
@handlers.map(&:stop)
|
53
42
|
@provider.stop
|
54
43
|
end
|
55
44
|
|
@@ -60,7 +49,7 @@ module Pushr
|
|
60
49
|
middleware = Pushr::Daemon.const_get("#{klass}".camelize)
|
61
50
|
rescue NameError
|
62
51
|
message = "Could not find matching push provider for #{klass.inspect}. " \
|
63
|
-
"You may need to install an additional gem (such as
|
52
|
+
"You may need to install an additional gem (such as pushr-#{klass})."
|
64
53
|
raise LoadError, message
|
65
54
|
end
|
66
55
|
|
@@ -1,7 +1,8 @@
|
|
1
1
|
module Pushr
|
2
2
|
module Daemon
|
3
3
|
class Settings
|
4
|
-
|
4
|
+
attr_reader :pid_file
|
5
|
+
attr_accessor :foreground, :error_notification, :feedback_processor, :stats_processor
|
5
6
|
|
6
7
|
def initialize
|
7
8
|
@foreground = false
|
data/lib/pushr/feedback.rb
CHANGED
data/lib/pushr/message.rb
CHANGED
@@ -6,7 +6,7 @@ module Pushr
|
|
6
6
|
|
7
7
|
def initialize(attributes = {})
|
8
8
|
attributes.each do |name, value|
|
9
|
-
send("#{name}=", value)
|
9
|
+
send("#{name}=", value) if respond_to?("#{name}=")
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
@@ -19,6 +19,11 @@ module Pushr
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
+
def save!
|
23
|
+
save || fail(RecordNotSaved)
|
24
|
+
# fail 'x' unless save
|
25
|
+
end
|
26
|
+
|
22
27
|
def self.next(queue_name, timeout = 3)
|
23
28
|
Pushr::Core.redis do |conn|
|
24
29
|
message = conn.blpop(queue_name, timeout: timeout)
|
data/lib/pushr/version.rb
CHANGED
data/spec/support/pushr_dummy.rb
CHANGED
@@ -1,16 +1,27 @@
|
|
1
1
|
module Pushr
|
2
2
|
module Daemon
|
3
3
|
class Dummy
|
4
|
-
attr_accessor :configuration
|
4
|
+
attr_accessor :configuration, :handlers
|
5
|
+
|
5
6
|
def initialize(options)
|
6
|
-
|
7
|
+
@configuration = options
|
8
|
+
@handlers = []
|
7
9
|
end
|
8
10
|
|
9
|
-
def
|
10
|
-
|
11
|
+
def start
|
12
|
+
configuration.connections.times do |i|
|
13
|
+
connection = DummySupport::ConnectionDummy.new(configuration, i + 1)
|
14
|
+
connection.connect
|
15
|
+
|
16
|
+
handler = MessageHandler.new("pushr:#{configuration.app}:#{configuration.name}", connection, configuration.app, i + 1)
|
17
|
+
handler.start
|
18
|
+
@handlers << handler
|
19
|
+
end
|
11
20
|
end
|
12
21
|
|
13
|
-
def stop
|
22
|
+
def stop
|
23
|
+
@handlers.map(&:stop)
|
24
|
+
end
|
14
25
|
end
|
15
26
|
end
|
16
27
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pushr-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.pre.
|
4
|
+
version: 1.0.0.pre.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tom Pesman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-05-
|
11
|
+
date: 2014-05-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redis
|