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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d50ae95d68648f0740d8a4ffb19f080f106c423b
4
- data.tar.gz: 874fa74a2c4ce892d38fd48c1a4727a61e56f737
3
+ metadata.gz: 5f48af75969ed972bfe7f7b5a57b9c5101b6243f
4
+ data.tar.gz: ef7ca9aa7a7e70aa11e36157cee603f504c88136
5
5
  SHA512:
6
- metadata.gz: e740ef4e3559dd85c1a4d7b75e0bf0ae3ddc54e0a6ee11dc9ecb0d215556761d028fbc49151b199733326afa78fbe4b8c7237fb027d2c6005122444e2364c54b
7
- data.tar.gz: f4f51cdc7842c60f7c17afcfb38905609c805588aa73ff09906ccd73f6d0dfc672e9a2adf0d30f363d3c151b5f9bbe8c657c4ceab6a431dc735e9336dff5b29a
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.0
1
+ 2.1.5
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.
@@ -7,13 +7,29 @@ module Notifiable
7
7
  module Grocer
8
8
  class Stream < Notifiable::NotifierBase
9
9
 
10
- attr_accessor :sandbox, :certificate, :passphrase, :connection_pool_size, :connection_pool_timeout
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) unless Notifiable.delivery_method == :test
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.test_env? ? "localhost" : sandbox? ? "gateway.sandbox.push.apple.com" : "gateway.push.apple.com",
63
- port: 2195,
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.test_env? ? "feedback.sandbox.push.apple.com" : "feedback.push.apple.com",
73
- port: 2196,
88
+ gateway: self.feedback_host,
89
+ port: self.feedback_port,
74
90
  retries: 3
75
91
  }
76
92
  end
@@ -1,7 +1,7 @@
1
1
  module Notifiable
2
2
  module Apns
3
3
  module Grocer
4
- VERSION = "0.11.0"
4
+ VERSION = "0.12.0"
5
5
  end
6
6
  end
7
7
  end
@@ -30,5 +30,6 @@ Gem::Specification.new do |spec|
30
30
  spec.add_development_dependency "sqlite3"
31
31
  spec.add_development_dependency "database_cleaner"
32
32
  spec.add_development_dependency 'ruby-prof'
33
+ spec.add_development_dependency 'byebug'
33
34
 
34
35
  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.should == 1
17
- Notifiable::NotificationStatus.first.status.should == 0
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.should eql "Test message"
22
- notification.custom[:localized_notification_id].should == ln.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.should == 1
32
- Notifiable::NotificationStatus.first.status.should == 0
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].should == ln.id
37
- notification.custom[:flag].should == true
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 "can use production gateway" do
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(:sandbox?)).to eq false
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.11.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-02-22 00:00:00.000000000 Z
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.2.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