notifiable-apns-grocer 0.9.2 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -27
- data/lib/notifiable/apns/grocer/stream.rb +43 -35
- data/lib/notifiable/apns/grocer/version.rb +1 -1
- data/notifiable-apns-grocer.gemspec +1 -0
- data/spec/{grocer_spec.rb → stream_spec.rb} +13 -3
- metadata +18 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6a06d78cc911ead79cb82a82ac8d300356103c61
|
4
|
+
data.tar.gz: a8ab71412ce38e6243ae014a01967033f76c0f99
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2b58e61ad194010c7893140834ec7a87b1e90a227943cdf9211bf95af62646b25703a18d3316b919169585fbd68dfa7686d7a8fb2155779fbbd24a98af872e28
|
7
|
+
data.tar.gz: 1ca98ff7c33c18737dca7a9b7b957685c526d9c9da339baae973fc9757a5c989e2f409527bd69d29e2610f16340fd5300978d8ae6beb45509928a0bf5fc1a9ea
|
data/README.md
CHANGED
@@ -1,29 +1,3 @@
|
|
1
1
|
# Notifiable::Apns::Grocer
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
## Installation
|
6
|
-
|
7
|
-
Add this line to your application's Gemfile:
|
8
|
-
|
9
|
-
gem 'notifiable-apns-grocer'
|
10
|
-
|
11
|
-
And then execute:
|
12
|
-
|
13
|
-
$ bundle
|
14
|
-
|
15
|
-
Or install it yourself as:
|
16
|
-
|
17
|
-
$ gem install notifiable-apns-grocer
|
18
|
-
|
19
|
-
## Usage
|
20
|
-
|
21
|
-
TODO: Write usage instructions here
|
22
|
-
|
23
|
-
## Contributing
|
24
|
-
|
25
|
-
1. Fork it
|
26
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
-
5. Create new Pull Request
|
3
|
+
Please refer to the [notifiable-rails](https://github.com/FutureWorkshops/notifiable-rails) Readme for further information.
|
@@ -1,13 +1,14 @@
|
|
1
1
|
require 'notifiable'
|
2
2
|
require 'grocer'
|
3
|
+
require 'connection_pool'
|
3
4
|
|
4
5
|
module Notifiable
|
5
6
|
module Apns
|
6
7
|
module Grocer
|
7
8
|
class Stream < Notifiable::NotifierBase
|
8
9
|
|
9
|
-
attr_accessor :sandbox, :certificate, :passphrase
|
10
|
-
|
10
|
+
attr_accessor :sandbox, :certificate, :passphrase, :connection_pool_size, :connection_pool_timeout
|
11
|
+
|
11
12
|
def close
|
12
13
|
super
|
13
14
|
@grocer_pusher = nil
|
@@ -15,40 +16,45 @@ module Notifiable
|
|
15
16
|
end
|
16
17
|
|
17
18
|
protected
|
18
|
-
|
19
|
+
def enqueue(device_token)
|
19
20
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
grocer_pusher.push(grocer_notification) unless Notifiable.delivery_method == :test
|
21
|
+
grocer_notification = ::Grocer::Notification.new(
|
22
|
+
device_token: device_token.token,
|
23
|
+
alert: notification.message,
|
24
|
+
custom: notification.send_params
|
25
|
+
)
|
27
26
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
#6 - Invalid topic size
|
36
|
-
#7 - Invalid payload size
|
37
|
-
#8 - Invalid token
|
38
|
-
#255 - None (unknown)
|
39
|
-
|
40
|
-
processed(device_token, 0)
|
41
|
-
end
|
27
|
+
pusher_pool.with do |pusher|
|
28
|
+
pusher.push(grocer_notification) unless Notifiable.delivery_method == :test
|
29
|
+
end
|
30
|
+
|
31
|
+
# assume processed. Errors will be receieved through a callback
|
32
|
+
processed(device_token, 0)
|
33
|
+
end
|
42
34
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
def sandbox?
|
48
|
-
self.sandbox.eql? "1"
|
49
|
-
end
|
35
|
+
def flush
|
36
|
+
process_feedback unless self.test_env?
|
37
|
+
end
|
50
38
|
|
51
|
-
private
|
39
|
+
private
|
40
|
+
# override getters with defaults
|
41
|
+
def sandbox
|
42
|
+
@sandbox || "0"
|
43
|
+
end
|
44
|
+
|
45
|
+
def connection_pool_size
|
46
|
+
@connection_pool_size || 10
|
47
|
+
end
|
48
|
+
|
49
|
+
def connection_pool_timeout
|
50
|
+
@connection_pool_timeout || 10
|
51
|
+
end
|
52
|
+
|
53
|
+
def sandbox?
|
54
|
+
sandbox.eql? "1"
|
55
|
+
end
|
56
|
+
|
57
|
+
# logic
|
52
58
|
def gateway_config
|
53
59
|
{
|
54
60
|
certificate: self.certificate,
|
@@ -68,9 +74,11 @@ module Notifiable
|
|
68
74
|
retries: 3
|
69
75
|
}
|
70
76
|
end
|
71
|
-
|
72
|
-
def
|
73
|
-
@
|
77
|
+
|
78
|
+
def pusher_pool
|
79
|
+
@pusher_pool ||= ConnectionPool.new(size: connection_pool_size, timeout: connection_pool_timeout) do
|
80
|
+
::Grocer.pusher(gateway_config)
|
81
|
+
end
|
74
82
|
end
|
75
83
|
|
76
84
|
def grocer_feedback
|
@@ -20,6 +20,7 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.add_dependency "notifiable-rails", ">=0.19.0"
|
22
22
|
spec.add_dependency "grocer", '~> 0.5.0'
|
23
|
+
spec.add_dependency "connection_pool", '~> 2.0.0'
|
23
24
|
|
24
25
|
spec.add_development_dependency "bundler", "~> 1.3"
|
25
26
|
spec.add_development_dependency "rake"
|
@@ -37,14 +37,24 @@ describe Notifiable::Apns::Grocer::Stream do
|
|
37
37
|
}
|
38
38
|
end
|
39
39
|
|
40
|
-
it "
|
41
|
-
|
40
|
+
it "can use production gateway" do
|
42
41
|
g = Notifiable::Apns::Grocer::Stream.new(Rails.env, n1)
|
43
42
|
a.configuration = {:apns => {:sandbox => "0"}} # This is how production is configured
|
44
43
|
a.configure(:apns, g)
|
45
44
|
|
46
|
-
expect(g.send(:sandbox?)).to
|
45
|
+
expect(g.send(:sandbox?)).to be_falsey
|
46
|
+
end
|
47
|
+
|
48
|
+
it "has default connection pool size" do
|
49
|
+
g = Notifiable::Apns::Grocer::Stream.new(Rails.env, n1)
|
50
|
+
|
51
|
+
expect(g.send(:connection_pool_size)).to eq 10
|
52
|
+
end
|
53
|
+
|
54
|
+
it "has default connection pool timeout" do
|
55
|
+
g = Notifiable::Apns::Grocer::Stream.new(Rails.env, n1)
|
47
56
|
|
57
|
+
expect(g.send(:connection_pool_timeout)).to eq 10
|
48
58
|
end
|
49
59
|
|
50
60
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: notifiable-apns-grocer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kamil Kocemba
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-09-
|
12
|
+
date: 2014-09-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: notifiable-rails
|
@@ -39,6 +39,20 @@ dependencies:
|
|
39
39
|
- - ~>
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: 0.5.0
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: connection_pool
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ~>
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: 2.0.0
|
49
|
+
type: :runtime
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ~>
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: 2.0.0
|
42
56
|
- !ruby/object:Gem::Dependency
|
43
57
|
name: bundler
|
44
58
|
requirement: !ruby/object:Gem::Requirement
|
@@ -172,8 +186,8 @@ files:
|
|
172
186
|
- lib/notifiable/apns/grocer/version.rb
|
173
187
|
- lib/tasks/load_test.rake
|
174
188
|
- notifiable-apns-grocer.gemspec
|
175
|
-
- spec/grocer_spec.rb
|
176
189
|
- spec/spec_helper.rb
|
190
|
+
- spec/stream_spec.rb
|
177
191
|
- spec/support/db/migrate/20131228225138_create_notifiable_apps.rb
|
178
192
|
- spec/support/db/migrate/20131228225139_create_notifiable_device_tokens.rb
|
179
193
|
- spec/support/db/migrate/20131228225140_create_notifiable_notifications.rb
|
@@ -203,8 +217,8 @@ signing_key:
|
|
203
217
|
specification_version: 4
|
204
218
|
summary: Plugin to use Grocer for APNS with Notifiable-Rails
|
205
219
|
test_files:
|
206
|
-
- spec/grocer_spec.rb
|
207
220
|
- spec/spec_helper.rb
|
221
|
+
- spec/stream_spec.rb
|
208
222
|
- spec/support/db/migrate/20131228225138_create_notifiable_apps.rb
|
209
223
|
- spec/support/db/migrate/20131228225139_create_notifiable_device_tokens.rb
|
210
224
|
- spec/support/db/migrate/20131228225140_create_notifiable_notifications.rb
|