notifiable-apns-grocer 0.11.0 → 0.12.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/.rspec +1 -0
- data/.ruby-version +1 -1
- data/README.md +1 -27
- data/lib/notifiable/apns/grocer/stream.rb +22 -6
- data/lib/notifiable/apns/grocer/version.rb +1 -1
- data/notifiable-apns-grocer.gemspec +1 -0
- data/spec/stream_spec.rb +21 -12
- metadata +18 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5f48af75969ed972bfe7f7b5a57b9c5101b6243f
|
4
|
+
data.tar.gz: ef7ca9aa7a7e70aa11e36157cee603f504c88136
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2f881897464dae23b6d14bbfd1577ec24ed235d457052a99db40f034c312544137883d9d7ac4c756d48557a713d270f04669e6758bd6f84d71d96d9c0ba252a0
|
7
|
+
data.tar.gz: 75fbaafa5746bdffe5ef5529b725fe43db58b2f39e3bceef7038567c8e48cdc3cc7574e42e3b557d2ce03c5ef053eca4115fb0fd942acd254056534fa68c22c9
|
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.1.
|
1
|
+
2.1.5
|
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.
|
@@ -7,13 +7,29 @@ module Notifiable
|
|
7
7
|
module Grocer
|
8
8
|
class Stream < Notifiable::NotifierBase
|
9
9
|
|
10
|
-
attr_accessor :
|
10
|
+
attr_accessor :certificate, :passphrase, :connection_pool_size, :connection_pool_timeout, :gateway_host, :gateway_port, :feedback_host, :feedback_port
|
11
11
|
|
12
12
|
def close
|
13
13
|
super
|
14
14
|
@grocer_pusher = nil
|
15
15
|
@grocer_feedback = nil
|
16
16
|
end
|
17
|
+
|
18
|
+
def gateway_host
|
19
|
+
@gateway_host || "gateway.push.apple.com"
|
20
|
+
end
|
21
|
+
|
22
|
+
def gateway_port
|
23
|
+
@gateway_port || 2195
|
24
|
+
end
|
25
|
+
|
26
|
+
def feedback_host
|
27
|
+
@gateway_host || "feedback.push.apple.com"
|
28
|
+
end
|
29
|
+
|
30
|
+
def feedback_port
|
31
|
+
@feedback_port || 2196
|
32
|
+
end
|
17
33
|
|
18
34
|
protected
|
19
35
|
def enqueue(device_token, localized_notification)
|
@@ -25,7 +41,7 @@ module Notifiable
|
|
25
41
|
)
|
26
42
|
|
27
43
|
pusher_pool.with do |pusher|
|
28
|
-
pusher.push(grocer_notification)
|
44
|
+
pusher.push(grocer_notification)
|
29
45
|
end
|
30
46
|
|
31
47
|
# assume processed. Errors will be receieved through a callback
|
@@ -59,8 +75,8 @@ module Notifiable
|
|
59
75
|
{
|
60
76
|
certificate: self.certificate,
|
61
77
|
passphrase: self.passphrase,
|
62
|
-
gateway: self.
|
63
|
-
port:
|
78
|
+
gateway: self.gateway_host,
|
79
|
+
port: self.gateway_port,
|
64
80
|
retries: 3
|
65
81
|
}
|
66
82
|
end
|
@@ -69,8 +85,8 @@ module Notifiable
|
|
69
85
|
{
|
70
86
|
certificate: self.certificate,
|
71
87
|
passphrase: self.passphrase,
|
72
|
-
gateway: self.
|
73
|
-
port:
|
88
|
+
gateway: self.feedback_host,
|
89
|
+
port: self.feedback_port,
|
74
90
|
retries: 3
|
75
91
|
}
|
76
92
|
end
|
data/spec/stream_spec.rb
CHANGED
@@ -7,19 +7,26 @@ describe Notifiable::Apns::Grocer::Stream do
|
|
7
7
|
let!(:ln) { Notifiable::LocalizedNotification.create(:message => "Test message", :params => {:flag => true}, :notification => n1, :locale => :en) }
|
8
8
|
let(:d) { Notifiable::DeviceToken.create(:token => "ABC123", :provider => :apns, :app => a, :locale => :en) }
|
9
9
|
|
10
|
+
before(:each) do
|
11
|
+
a.configuration = {:apns => {
|
12
|
+
:gateway_host => "localhost",
|
13
|
+
:gateway_port => 2195,
|
14
|
+
:feedback_host => "localhost",
|
15
|
+
:feedback_port => 2196}}
|
16
|
+
end
|
17
|
+
|
10
18
|
it "sends a single notification" do
|
11
|
-
|
12
19
|
n1.batch do |n|
|
13
20
|
n.add_device_token(d)
|
14
21
|
end
|
15
22
|
|
16
|
-
Notifiable::NotificationStatus.count.
|
17
|
-
Notifiable::NotificationStatus.first.status.
|
23
|
+
expect(Notifiable::NotificationStatus.count).to eql 1
|
24
|
+
expect(Notifiable::NotificationStatus.first.status).to eql 0
|
18
25
|
|
19
26
|
Timeout.timeout(2) {
|
20
27
|
notification = @grocer.notifications.pop
|
21
|
-
notification.alert.
|
22
|
-
notification.custom[:localized_notification_id].
|
28
|
+
expect(notification.alert).to eql "Test message"
|
29
|
+
expect(notification.custom[:localized_notification_id]).to eql ln.id
|
23
30
|
}
|
24
31
|
end
|
25
32
|
|
@@ -28,22 +35,24 @@ describe Notifiable::Apns::Grocer::Stream do
|
|
28
35
|
n.add_device_token(d)
|
29
36
|
end
|
30
37
|
|
31
|
-
Notifiable::NotificationStatus.count.
|
32
|
-
Notifiable::NotificationStatus.first.status.
|
38
|
+
expect(Notifiable::NotificationStatus.count).to eql 1
|
39
|
+
expect(Notifiable::NotificationStatus.first.status).to eql 0
|
33
40
|
|
34
41
|
Timeout.timeout(2) {
|
35
42
|
notification = @grocer.notifications.pop
|
36
|
-
notification.custom[:localized_notification_id].
|
37
|
-
notification.custom[:flag].
|
43
|
+
expect(notification.custom[:localized_notification_id]).to eql ln.id
|
44
|
+
expect(notification.custom[:flag]).to eql true
|
38
45
|
}
|
39
46
|
end
|
40
47
|
|
41
|
-
it "
|
48
|
+
it "sets gateway and feedback properties" do
|
42
49
|
g = Notifiable::Apns::Grocer::Stream.new(Rails.env, n1)
|
43
|
-
a.configuration = {:apns => {:sandbox => "0"}} # This is how production is configured
|
44
50
|
a.configure(:apns, g)
|
45
51
|
|
46
|
-
expect(g.send(:
|
52
|
+
expect(g.send(:gateway_host)).to eql "localhost"
|
53
|
+
expect(g.send(:gateway_port)).to eql 2195
|
54
|
+
expect(g.send(:feedback_host)).to eql "localhost"
|
55
|
+
expect(g.send(:feedback_port)).to eql 2196
|
47
56
|
|
48
57
|
end
|
49
58
|
|
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.12.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: 2015-
|
12
|
+
date: 2015-11-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: notifiable-rails
|
@@ -165,6 +165,20 @@ dependencies:
|
|
165
165
|
- - ">="
|
166
166
|
- !ruby/object:Gem::Version
|
167
167
|
version: '0'
|
168
|
+
- !ruby/object:Gem::Dependency
|
169
|
+
name: byebug
|
170
|
+
requirement: !ruby/object:Gem::Requirement
|
171
|
+
requirements:
|
172
|
+
- - ">="
|
173
|
+
- !ruby/object:Gem::Version
|
174
|
+
version: '0'
|
175
|
+
type: :development
|
176
|
+
prerelease: false
|
177
|
+
version_requirements: !ruby/object:Gem::Requirement
|
178
|
+
requirements:
|
179
|
+
- - ">="
|
180
|
+
- !ruby/object:Gem::Version
|
181
|
+
version: '0'
|
168
182
|
description: Plugin to use Grocer for APNS with Notifiable-Rails
|
169
183
|
email:
|
170
184
|
- kamil@futureworkshops.com
|
@@ -174,6 +188,7 @@ extensions: []
|
|
174
188
|
extra_rdoc_files: []
|
175
189
|
files:
|
176
190
|
- ".gitignore"
|
191
|
+
- ".rspec"
|
177
192
|
- ".ruby-gemset"
|
178
193
|
- ".ruby-version"
|
179
194
|
- Gemfile
|
@@ -213,7 +228,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
213
228
|
version: '0'
|
214
229
|
requirements: []
|
215
230
|
rubyforge_project:
|
216
|
-
rubygems_version: 2.
|
231
|
+
rubygems_version: 2.4.3
|
217
232
|
signing_key:
|
218
233
|
specification_version: 4
|
219
234
|
summary: Plugin to use Grocer for APNS with Notifiable-Rails
|