apns_dispatch 0.1.0 → 1.0.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b6a9fb49ce25c8c98e83297fafa388e24998194f
4
+ data.tar.gz: 41fd68140a59f37cc37752535b425f37048d7d0d
5
+ SHA512:
6
+ metadata.gz: cf0fdf5ecc666a38a2db6d0357bd624cbb87557f1c6424c3e24c35e1cb13df1a95ec0b93a0f7dad5adcba3de54e9945fa594795df548ffbe8535a31531668c5e
7
+ data.tar.gz: 88fcc554e3b29ff26c17585b7f176c89dd00e8cc7cd0b3bec6073d7c5ea466498ecc259262f9f0d1b2d30a34c94f64b006563bdf45547946edb92feb843c96bb
data/.gitignore CHANGED
@@ -1,10 +1,12 @@
1
+ *.sw?
1
2
  *.gem
2
3
  *.rbc
3
4
  .bundle
4
5
  .config
5
6
  .rvmrc
7
+ .ruby-gemset
8
+ .ruby-version
6
9
  .yardoc
7
- Gemfile.lock
8
10
  InstalledFiles
9
11
  _yardoc
10
12
  coverage
data/Gemfile.lock ADDED
@@ -0,0 +1,30 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ apns_dispatch (1.0.0)
5
+ json (~> 1.7.5)
6
+ retryable (~> 1.3.5)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ diff-lcs (1.2.5)
12
+ json (1.7.7)
13
+ rake (10.1.1)
14
+ retryable (1.3.5)
15
+ rspec (2.13.0)
16
+ rspec-core (~> 2.13.0)
17
+ rspec-expectations (~> 2.13.0)
18
+ rspec-mocks (~> 2.13.0)
19
+ rspec-core (2.13.1)
20
+ rspec-expectations (2.13.0)
21
+ diff-lcs (>= 1.1.3, < 2.0)
22
+ rspec-mocks (2.13.1)
23
+
24
+ PLATFORMS
25
+ ruby
26
+
27
+ DEPENDENCIES
28
+ apns_dispatch!
29
+ rake
30
+ rspec (~> 2.13.0)
@@ -11,14 +11,16 @@ Gem::Specification.new do |gem|
11
11
  gem.summary = 'A simple Ruby framework for communicating with the APNs'
12
12
  gem.description = 'A simple Ruby framework for sending push notifications and receiving feedback using the Apple Push Notification service'
13
13
  gem.homepage = 'http://github.com/TheLevelUp/apns_dispatch'
14
+ gem.license = 'MIT'
14
15
 
15
16
  gem.files = `git ls-files`.split($/)
16
17
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
17
18
 
18
19
  gem.add_dependency 'json', '~> 1.7.5'
20
+ gem.add_dependency 'retryable', '~> 1.3.5'
19
21
 
20
22
  gem.add_development_dependency 'rake'
21
- gem.add_development_dependency 'rspec', '~> 2.0'
23
+ gem.add_development_dependency 'rspec', '~> 2.13.0'
22
24
 
23
25
  gem.required_ruby_version = Gem::Requirement.new('>= 1.9.2')
24
26
  gem.require_paths = ["lib"]
@@ -1,4 +1,5 @@
1
1
  require 'openssl'
2
+ require 'retryable'
2
3
  require 'socket'
3
4
 
4
5
  module ApnsDispatch
@@ -77,23 +78,17 @@ module ApnsDispatch
77
78
  connect!
78
79
  end
79
80
 
80
- def with_connection
81
+ def retryable_errors
82
+ [Errno::EPIPE, Errno::ETIMEDOUT, OpenSSL::SSL::SSLError]
83
+ end
84
+
85
+ def with_connection(&block)
81
86
  unless connected?
82
87
  connect!
83
88
  end
84
89
 
85
- attempted = false
86
-
87
- begin
88
- if block_given?
89
- yield
90
- end
91
- rescue Errno::EPIPE, OpenSSL::SSL::SSLError
92
- unless attempted
93
- reconnect!
94
- attempted = true
95
- retry
96
- end
90
+ retryable exception_cb: lambda { |e| reconnect! }, on: retryable_errors, sleep: 0, tries: 2 do
91
+ yield
97
92
  end
98
93
  end
99
94
  end
@@ -1,3 +1,3 @@
1
1
  module ApnsDispatch
2
- VERSION = '0.1.0'
2
+ VERSION = '1.0.0'
3
3
  end
@@ -21,21 +21,33 @@ describe ApnsDispatch::ApnsConnection do
21
21
  @apns_connection.send command, argument
22
22
  end
23
23
 
24
- it 'retries once' do
25
- @ssl.should_receive(command).with(argument).twice.and_return do
26
- unless @run
27
- @run = true
28
- raise OpenSSL::SSL::SSLError
29
- end
30
- end
24
+ it 'uses the correct host and port' do
25
+ TCPSocket.should_receive(:new).with(@apns_connection.host, @apns_connection.port)
31
26
 
32
27
  @apns_connection.send command, argument
33
28
  end
34
29
 
35
- it 'uses the correct host and port' do
36
- TCPSocket.should_receive(:new).with(@apns_connection.host, @apns_connection.port)
30
+ context 'when the connection throws an error' do
31
+ before do
32
+ @ssl.stub(command).with(argument).and_return do
33
+ unless @run
34
+ @run = true
35
+ raise OpenSSL::SSL::SSLError
36
+ end
37
+ end
38
+ end
37
39
 
38
- @apns_connection.send command, argument
40
+ it 'retries once' do
41
+ @ssl.should_receive(command).with(argument).twice
42
+
43
+ @apns_connection.send command, argument
44
+ end
45
+
46
+ it 'reconnects before retrying' do
47
+ OpenSSL::SSL::SSLSocket.should_receive(:new).twice
48
+
49
+ @apns_connection.send command, argument
50
+ end
39
51
  end
40
52
 
41
53
  context 'when there is no connection' do
metadata CHANGED
@@ -1,64 +1,71 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apns_dispatch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
5
- prerelease:
4
+ version: 1.0.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Costa Walcott
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-11-05 00:00:00.000000000 Z
11
+ date: 2014-02-04 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: json
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ~>
17
+ - - "~>"
20
18
  - !ruby/object:Gem::Version
21
19
  version: 1.7.5
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ~>
24
+ - - "~>"
28
25
  - !ruby/object:Gem::Version
29
26
  version: 1.7.5
27
+ - !ruby/object:Gem::Dependency
28
+ name: retryable
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 1.3.5
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 1.3.5
30
41
  - !ruby/object:Gem::Dependency
31
42
  name: rake
32
43
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
44
  requirements:
35
- - - ! '>='
45
+ - - ">="
36
46
  - !ruby/object:Gem::Version
37
47
  version: '0'
38
48
  type: :development
39
49
  prerelease: false
40
50
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
51
  requirements:
43
- - - ! '>='
52
+ - - ">="
44
53
  - !ruby/object:Gem::Version
45
54
  version: '0'
46
55
  - !ruby/object:Gem::Dependency
47
56
  name: rspec
48
57
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
58
  requirements:
51
- - - ~>
59
+ - - "~>"
52
60
  - !ruby/object:Gem::Version
53
- version: '2.0'
61
+ version: 2.13.0
54
62
  type: :development
55
63
  prerelease: false
56
64
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
65
  requirements:
59
- - - ~>
66
+ - - "~>"
60
67
  - !ruby/object:Gem::Version
61
- version: '2.0'
68
+ version: 2.13.0
62
69
  description: A simple Ruby framework for sending push notifications and receiving
63
70
  feedback using the Apple Push Notification service
64
71
  email:
@@ -67,8 +74,9 @@ executables: []
67
74
  extensions: []
68
75
  extra_rdoc_files: []
69
76
  files:
70
- - .gitignore
77
+ - ".gitignore"
71
78
  - Gemfile
79
+ - Gemfile.lock
72
80
  - MIT-LICENSE
73
81
  - README.md
74
82
  - Rakefile
@@ -86,28 +94,28 @@ files:
86
94
  - spec/apns_dispatch/apns_connection_spec.rb
87
95
  - spec/spec_helper.rb
88
96
  homepage: http://github.com/TheLevelUp/apns_dispatch
89
- licenses: []
97
+ licenses:
98
+ - MIT
99
+ metadata: {}
90
100
  post_install_message:
91
101
  rdoc_options: []
92
102
  require_paths:
93
103
  - lib
94
104
  required_ruby_version: !ruby/object:Gem::Requirement
95
- none: false
96
105
  requirements:
97
- - - ! '>='
106
+ - - ">="
98
107
  - !ruby/object:Gem::Version
99
108
  version: 1.9.2
100
109
  required_rubygems_version: !ruby/object:Gem::Requirement
101
- none: false
102
110
  requirements:
103
- - - ! '>='
111
+ - - ">="
104
112
  - !ruby/object:Gem::Version
105
113
  version: '0'
106
114
  requirements: []
107
115
  rubyforge_project:
108
- rubygems_version: 1.8.24
116
+ rubygems_version: 2.2.1
109
117
  signing_key:
110
- specification_version: 3
118
+ specification_version: 4
111
119
  summary: A simple Ruby framework for communicating with the APNs
112
120
  test_files:
113
121
  - spec/apns_dispatch/apn_feedback_spec.rb