houston 2.2.0 → 2.2.1
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/Gemfile.lock +1 -1
- data/coverage/index.html +224 -278
- data/houston-2.2.0.gem +0 -0
- data/lib/houston/client.rb +5 -22
- data/lib/houston/notification.rb +9 -1
- data/lib/houston/version.rb +1 -1
- data/spec/notification_spec.rb +27 -0
- metadata +3 -2
data/houston-2.2.0.gem
ADDED
|
Binary file
|
data/lib/houston/client.rb
CHANGED
|
@@ -36,7 +36,6 @@ module Houston
|
|
|
36
36
|
return if notifications.empty?
|
|
37
37
|
|
|
38
38
|
notifications.flatten!
|
|
39
|
-
error = nil
|
|
40
39
|
|
|
41
40
|
Connection.open(@gateway_uri, @certificate, @passphrase) do |connection|
|
|
42
41
|
ssl = connection.ssl
|
|
@@ -51,32 +50,16 @@ module Houston
|
|
|
51
50
|
connection.write(notification.message)
|
|
52
51
|
notification.mark_as_sent!
|
|
53
52
|
|
|
54
|
-
break if notifications.count == 1 || notification == notifications.last
|
|
55
|
-
|
|
56
53
|
read_socket, write_socket = IO.select([ssl], [ssl], [ssl], nil)
|
|
57
54
|
if (read_socket && read_socket[0])
|
|
58
|
-
error = connection.read(6)
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
return if notifications.count == 1
|
|
64
|
-
|
|
65
|
-
unless error
|
|
66
|
-
read_socket, write_socket = IO.select([ssl], nil, [ssl], timeout)
|
|
67
|
-
if (read_socket && read_socket[0])
|
|
68
|
-
error = connection.read(6)
|
|
55
|
+
if error = connection.read(6)
|
|
56
|
+
command, status, index = error.unpack("ccN")
|
|
57
|
+
notification.apns_error_code = status
|
|
58
|
+
notification.mark_as_unsent!
|
|
59
|
+
end
|
|
69
60
|
end
|
|
70
61
|
end
|
|
71
62
|
end
|
|
72
|
-
|
|
73
|
-
if error
|
|
74
|
-
command, status, index = error.unpack("ccN")
|
|
75
|
-
notifications[index].apns_error_code = status
|
|
76
|
-
notifications.slice!(0..index)
|
|
77
|
-
notifications.each(&:mark_as_unsent!)
|
|
78
|
-
push(*notifications)
|
|
79
|
-
end
|
|
80
63
|
end
|
|
81
64
|
|
|
82
65
|
def unregistered_devices
|
data/lib/houston/notification.rb
CHANGED
|
@@ -17,6 +17,14 @@ module Houston
|
|
|
17
17
|
10 => "Shutdown",
|
|
18
18
|
255 => "Unknown error"
|
|
19
19
|
}
|
|
20
|
+
|
|
21
|
+
attr_reader :code
|
|
22
|
+
|
|
23
|
+
def initialize(code)
|
|
24
|
+
raise ArgumentError unless CODES.include?(code)
|
|
25
|
+
super(CODES[code])
|
|
26
|
+
@code = code
|
|
27
|
+
end
|
|
20
28
|
end
|
|
21
29
|
|
|
22
30
|
MAXIMUM_PAYLOAD_SIZE = 2048
|
|
@@ -81,7 +89,7 @@ module Houston
|
|
|
81
89
|
end
|
|
82
90
|
|
|
83
91
|
def error
|
|
84
|
-
APNSError.new(
|
|
92
|
+
APNSError.new(@apns_error_code) if @apns_error_code and @apns_error_code.nonzero?
|
|
85
93
|
end
|
|
86
94
|
|
|
87
95
|
private
|
data/lib/houston/version.rb
CHANGED
data/spec/notification_spec.rb
CHANGED
|
@@ -247,4 +247,31 @@ describe Houston::Notification do
|
|
|
247
247
|
expect(items.find { |item| item[0] == 5 }).to be_nil
|
|
248
248
|
end
|
|
249
249
|
end
|
|
250
|
+
|
|
251
|
+
describe '#error' do
|
|
252
|
+
context 'a status code has been set' do
|
|
253
|
+
it 'returns an error object mapped to that status code' do
|
|
254
|
+
status_code = 1
|
|
255
|
+
notification = Houston::Notification.new(notification_options)
|
|
256
|
+
notification.apns_error_code = status_code
|
|
257
|
+
expect(notification.error.message).to eq(Houston::Notification::APNSError::CODES[status_code])
|
|
258
|
+
end
|
|
259
|
+
end
|
|
260
|
+
|
|
261
|
+
context 'a status code has been set to 0' do
|
|
262
|
+
it 'returns nil' do
|
|
263
|
+
status_code = 0
|
|
264
|
+
notification = Houston::Notification.new(notification_options)
|
|
265
|
+
notification.apns_error_code = status_code
|
|
266
|
+
expect(notification.error).to be_nil
|
|
267
|
+
end
|
|
268
|
+
end
|
|
269
|
+
|
|
270
|
+
context 'a status code has not been set' do
|
|
271
|
+
it 'returns nil' do
|
|
272
|
+
notification = Houston::Notification.new(notification_options)
|
|
273
|
+
expect(notification.error).to be_nil
|
|
274
|
+
end
|
|
275
|
+
end
|
|
276
|
+
end
|
|
250
277
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: houston
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.2.
|
|
4
|
+
version: 2.2.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Mattt Thompson
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2014-08-
|
|
11
|
+
date: 2014-08-13 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: commander
|
|
@@ -155,6 +155,7 @@ files:
|
|
|
155
155
|
- ./coverage/index.html
|
|
156
156
|
- ./Gemfile
|
|
157
157
|
- ./Gemfile.lock
|
|
158
|
+
- ./houston-2.2.0.gem
|
|
158
159
|
- ./houston.gemspec
|
|
159
160
|
- ./lib/houston/client.rb
|
|
160
161
|
- ./lib/houston/connection.rb
|