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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3c93d207045d385543328378c3b2a8599d3263dd
4
- data.tar.gz: 216667de8a48363778d2c8d9bba91d1856e1ed56
3
+ metadata.gz: 6a06d78cc911ead79cb82a82ac8d300356103c61
4
+ data.tar.gz: a8ab71412ce38e6243ae014a01967033f76c0f99
5
5
  SHA512:
6
- metadata.gz: 88bf1a0ec973d3cd9b3424ae411d35a7c572e887ee217c524e892a49fdae609b12c8de9f5e68ccdb64c92a35a0061d0d28ae1382d0085e717796e17f595472b5
7
- data.tar.gz: 5c0d1c890ef904da91a93c66bef085171eb2202dca140644b5276af46fb6fb74772e1e0509c8141513ea184b422ab9ee5f226a318e557bacdf1f7e0bc71bced9
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
- TODO: Write a gem description
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
- def enqueue(device_token)
19
+ def enqueue(device_token)
19
20
 
20
- grocer_notification = ::Grocer::Notification.new(
21
- device_token: device_token.token,
22
- alert: notification.message,
23
- custom: notification.send_params
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
- # TODO - add errors via enhanced interface
29
- #0 - No errors encountered
30
- #1 - Processing error
31
- #2 - Missing device token
32
- #3 - Missing topic
33
- #4 - Missing payload
34
- #5 - Invalid token size
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
- def flush
44
- process_feedback unless self.test_env?
45
- end
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 grocer_pusher
73
- @grocer_pusher ||= ::Grocer.pusher(gateway_config)
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
@@ -1,7 +1,7 @@
1
1
  module Notifiable
2
2
  module Apns
3
3
  module Grocer
4
- VERSION = "0.9.2"
4
+ VERSION = "0.10.0"
5
5
  end
6
6
  end
7
7
  end
@@ -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 "works using production gateway" do
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 be_false
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.9.2
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-03 00:00:00.000000000 Z
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