apnotic 0.9.1 → 0.9.2
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/README.md +5 -4
- data/apnotic.gemspec +1 -1
- data/lib/apnotic/connection.rb +9 -8
- data/lib/apnotic/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f1a10d2e906280964fd17047d5a6dbd4401f0a81
|
4
|
+
data.tar.gz: 05e865f118c12f829b7232d5c2f44e5d43bcc0c0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 335531c6db288c0befc75bf91235ae2cd5387810b9410d6e8a342af89aeee0b81ab6e739a73f1762abb78aa7919876b8f1962517e96b1330b89d20a0998208d9
|
7
|
+
data.tar.gz: 9b413dcd3a8aa1cabbb8d7dd544b3d72a7a1627e92fe2bd91939e2dd17d08fc14c2c129582d60c70f45ab4a22e24b837be55cb9d5916dbc667ffee08e9f62ea0
|
data/README.md
CHANGED
@@ -108,7 +108,8 @@ Apnotic::Connection.new(options)
|
|
108
108
|
|-----|-----
|
109
109
|
| :cert_path | Required. The path to a valid APNS push certificate in .pem or .p12 format, or any object that responds to `:read`.
|
110
110
|
| :cert_pass | Optional. The certificate's password.
|
111
|
-
| :
|
111
|
+
| :url | Optional. Defaults to https://api.push.apple.com:443.
|
112
|
+
| :connect_timeout | Optional. Expressed in seconds, defaults to 30.
|
112
113
|
|
113
114
|
It is also possible to create a connection that points to the Apple Development servers by calling instead:
|
114
115
|
|
@@ -120,15 +121,15 @@ Apnotic::Connection.development(options)
|
|
120
121
|
|
121
122
|
#### Methods
|
122
123
|
|
123
|
-
* **
|
124
|
+
* **url** → **`URL`**
|
124
125
|
|
125
|
-
Returns the
|
126
|
+
Returns the URL of the APNS endpoint.
|
126
127
|
|
127
128
|
* **cert_path** → **`string`**
|
128
129
|
|
129
130
|
Returns the path to the certificate
|
130
131
|
|
131
|
-
* **push(notification, timeout
|
132
|
+
* **push(notification, timeout: 30)** → **`Apnotic::Response` or `nil`**
|
132
133
|
|
133
134
|
Sends a notification. Returns `nil` in case a timeout occurs.
|
134
135
|
|
data/apnotic.gemspec
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_dependency "net-http2", "~> 0.
|
21
|
+
spec.add_dependency "net-http2", "~> 0.11.0"
|
22
22
|
spec.add_dependency "connection_pool", "~> 2.0"
|
23
23
|
|
24
24
|
spec.add_development_dependency "bundler", "~> 1.3"
|
data/lib/apnotic/connection.rb
CHANGED
@@ -3,27 +3,28 @@ require 'openssl'
|
|
3
3
|
|
4
4
|
module Apnotic
|
5
5
|
|
6
|
-
|
7
|
-
|
6
|
+
APPLE_DEVELOPMENT_SERVER_URL = "https://api.development.push.apple.com:443"
|
7
|
+
APPLE_PRODUCTION_SERVER_URL = "https://api.push.apple.com:443"
|
8
8
|
|
9
9
|
class Connection
|
10
10
|
attr_reader :url, :cert_path
|
11
11
|
|
12
12
|
class << self
|
13
13
|
def development(options={})
|
14
|
-
options.merge!(url:
|
14
|
+
options.merge!(url: APPLE_DEVELOPMENT_SERVER_URL)
|
15
15
|
new(options)
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
19
|
def initialize(options={})
|
20
|
-
@url
|
21
|
-
@cert_path
|
22
|
-
@cert_pass
|
20
|
+
@url = options[:url] || APPLE_PRODUCTION_SERVER_URL
|
21
|
+
@cert_path = options[:cert_path]
|
22
|
+
@cert_pass = options[:cert_pass]
|
23
|
+
@connect_timeout = options[:connect_timeout] || 30
|
23
24
|
|
24
25
|
raise "Cert file not found: #{@cert_path}" unless @cert_path && (@cert_path.respond_to?(:read) || File.exist?(@cert_path))
|
25
26
|
|
26
|
-
@client = NetHttp2::Client.new(@url, ssl_context: ssl_context)
|
27
|
+
@client = NetHttp2::Client.new(@url, ssl_context: ssl_context, connect_timeout: @connect_timeout)
|
27
28
|
end
|
28
29
|
|
29
30
|
def push(notification, options={})
|
@@ -46,7 +47,7 @@ module Apnotic
|
|
46
47
|
@ssl_context ||= begin
|
47
48
|
ctx = OpenSSL::SSL::SSLContext.new
|
48
49
|
begin
|
49
|
-
p12
|
50
|
+
p12 = OpenSSL::PKCS12.new(certificate, @cert_pass)
|
50
51
|
ctx.key = p12.key
|
51
52
|
ctx.cert = p12.certificate
|
52
53
|
rescue OpenSSL::PKCS12::PKCS12Error
|
data/lib/apnotic/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: apnotic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Roberto Ostinelli
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-05-
|
11
|
+
date: 2016-05-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: net-http2
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 0.11.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.
|
26
|
+
version: 0.11.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: connection_pool
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|