apple_shove 2.0.1 → 2.0.2

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: fddaff591f202cc2de8d07ce6e6bd5d1ad00d545
4
- data.tar.gz: 49a5b28b2c56c774435afc25784f0209308e6b65
3
+ metadata.gz: b119daa9b46ae843bed8fc8327dd77ac20189551
4
+ data.tar.gz: f2a2c0b62cc2593f5f3a1cb3a239552cd3092028
5
5
  SHA512:
6
- metadata.gz: afaa11ebc095e9fdc384b63a4f8bdcffd5ca9def1a3be8b1899461eb4b60675b70d5e1777d1422d16dec32cc49290086bde30bf3a38a3192859470a4d98f5562
7
- data.tar.gz: 692a7a94043eb7976a4ba2ec2aa1b3e942231fdc97d2c52f5594af94294ad755d48b17052668ce797e3bd48808bdbda33f8ee346f0caf6e3f09dedba68b20333
6
+ metadata.gz: 329d709e3ea8811764a41fe55928e3a2e48bb1a62262c920c15d3c8166c8901b2d92a3e2ec4c3bed360f92ee582b78e023804af41cf053932dbaaca3ab77e3e8
7
+ data.tar.gz: fdad094d6ff2b8519ec200e2b4066b7a2a0d5f26bfce390370c389e7bcc5d061c450b780bcbf265a174837269a7267ffa0948370e8edf26594c86fb77ac2e5a4
data/.travis.yml ADDED
@@ -0,0 +1,9 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
4
+ - 1.9.3
5
+ - jruby-19mode
6
+ - ruby-head
7
+ - jruby-head
8
+
9
+ script: bundle exec rspec
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # AppleShove [![Code Climate](https://codeclimate.com/github/tboyko/apple_shove.png)](https://codeclimate.com/github/tboyko/apple_shove)
1
+ # AppleShove [![Code Climate](https://codeclimate.com/github/tboyko/apple_shove.png)](https://codeclimate.com/github/tboyko/apple_shove) [![Build Status](https://travis-ci.org/tboyko/apple_shove.png?branch=master)](https://travis-ci.org/tboyko/apple_shove)
2
2
 
3
3
  APN Service Provider. More powerful than a push...
4
4
 
@@ -23,7 +23,7 @@ module AppleShove
23
23
  end
24
24
 
25
25
  exclusive
26
-
26
+
27
27
  def connect
28
28
  super
29
29
  @last_used = Time.now
@@ -42,16 +42,22 @@ module AppleShove
42
42
  rescue Exception => e
43
43
  handler = WriteExceptionHandler.new(e)
44
44
  Logger.warn(handler.message, self, notification)
45
- reconnect if handler.reconnect?
46
- socket.write @last_message if handler.rewrite? && @last_message
45
+
46
+ begin
47
+ reconnect if handler.reconnect?
48
+ socket.write @last_message if handler.rewrite? && @last_message
49
+ rescue Exception => e
50
+ Logger.warn("failed while trying to recover from write error", self, notification)
51
+ end
52
+
47
53
  retry if handler.retry?
48
54
  else
49
55
  Logger.info("delivered notification", self, notification)
50
- end
51
56
 
52
- @last_message = message
53
- @last_used = Time.now
54
- @pending_notifications -= 1
57
+ @last_message = message
58
+ @last_used = Time.now
59
+ @pending_notifications -= 1
60
+ end
55
61
  end
56
62
 
57
63
  def shutdown
@@ -1,3 +1,3 @@
1
1
  module AppleShove
2
- VERSION = "2.0.1"
2
+ VERSION = "2.0.2"
3
3
  end
@@ -13,21 +13,30 @@ describe AppleShove::NotificationQueue do
13
13
  end
14
14
 
15
15
  it 'should add notifications to the queue' do
16
+ expect_any_instance_of(Redis).to receive(:rpush)
17
+
16
18
  n = generate_notification
17
19
  @q.add(n)
18
20
  end
19
21
 
20
22
  it 'should count notification on the queue when they are there' do
21
- @q.size.should_not eql(0)
23
+ expect_any_instance_of(Redis).to receive(:llen).and_return(1)
24
+
25
+ expect(@q.size).to be_a_kind_of(Integer)
22
26
  end
23
27
 
24
28
  it 'should get notifications from the queue' do
25
- while n = @q.get
26
- n.should be_an_instance_of(AppleShove::Notification)
27
- end
29
+ json = { p12: 'some p12', device_token: '123123123', payload: 'this is a test payload' }.to_json
30
+ expect_any_instance_of(Redis).to receive(:lpop).and_return(json)
31
+
32
+ notification = @q.get
33
+
34
+ expect(notification).to be_an_instance_of(AppleShove::Notification)
28
35
  end
29
36
 
30
37
  it 'should count 0 notifications when the queue is empty' do
38
+ expect_any_instance_of(Redis).to receive(:llen).and_return(0)
39
+
31
40
  @q.size.should eql(0)
32
41
  end
33
42
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apple_shove
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Taylor Boyko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-24 00:00:00.000000000 Z
11
+ date: 2014-08-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -103,6 +103,7 @@ extensions: []
103
103
  extra_rdoc_files: []
104
104
  files:
105
105
  - .gitignore
106
+ - .travis.yml
106
107
  - Gemfile
107
108
  - LICENSE.txt
108
109
  - README.md