pushr-apns 1.0.0.pre.4 → 1.0.0.rc.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pushr-apns/version.rb +1 -1
- data/lib/pushr/configuration_apns.rb +31 -6
- data/lib/pushr/configuration_apns_feedback.rb +2 -3
- data/lib/pushr/daemon/apns.rb +1 -1
- data/lib/pushr/daemon/apns_support/feedback_receiver.rb +0 -1
- data/lib/pushr/feedback_apns.rb +3 -4
- data/lib/pushr/message_apns.rb +4 -4
- data/spec/lib/pushr/configuration_apns_spec.rb +4 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c96cb0793ec34675dad88454fef5acb152b278d7
|
4
|
+
data.tar.gz: 21570b81ee97e8fc9132cd9bc8e5ae904e356c18
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5cab65d46970744c9fbd0a94fc287cbc999ef7a9e857bc0cbca3f5f20d8d448a2ab25a6dc116c92bc7e6e52305adcee97fab19a9ffd3c60630f520a5ff0ac687
|
7
|
+
data.tar.gz: 8fb1f7e0ca76d10ae96fcbe83cc531b9c0a291bc464e6940b52e09595129c50a3529a6aab45aa31849da061b94b8eb8d4a22a588df4565ecdd2f0f4771e589ef
|
data/lib/pushr-apns/version.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Pushr
|
2
2
|
class ConfigurationApns < Pushr::Configuration
|
3
|
-
|
4
|
-
|
3
|
+
attr_reader :certificate
|
4
|
+
attr_accessor :certificate_password, :sandbox, :skip_check_for_error
|
5
5
|
validates :certificate, presence: true
|
6
6
|
validates :sandbox, inclusion: { in: [true, false] }
|
7
7
|
validates :skip_check_for_error, inclusion: { in: [true, false] }, allow_blank: true
|
@@ -10,10 +10,35 @@ module Pushr
|
|
10
10
|
:apns
|
11
11
|
end
|
12
12
|
|
13
|
-
def
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
def certificate=(value)
|
14
|
+
if /BEGIN CERTIFICATE/.match(value)
|
15
|
+
@certificate = value
|
16
|
+
else
|
17
|
+
# assume it's the path to the certificate and try to read it:
|
18
|
+
@certificate = read_file(value)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def to_hash
|
23
|
+
{ type: self.class.to_s, app: app, enabled: enabled, connections: connections, certificate: certificate,
|
24
|
+
certificate_password: certificate_password, sandbox: sandbox, skip_check_for_error: skip_check_for_error }
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
# if filename is something wacky, this will break and raise an exception - that's OK
|
30
|
+
def read_file(filename)
|
31
|
+
File.read(build_filename(filename))
|
32
|
+
end
|
33
|
+
|
34
|
+
def build_filename(filename)
|
35
|
+
if Pathname.new(filename).absolute?
|
36
|
+
filename
|
37
|
+
elsif Pushr::Core.configuration_file
|
38
|
+
File.join(File.dirname(Pushr::Core.configuration_file), filename)
|
39
|
+
else
|
40
|
+
File.join(Dir.pwd, filename)
|
41
|
+
end
|
17
42
|
end
|
18
43
|
end
|
19
44
|
end
|
@@ -7,9 +7,8 @@ module Pushr
|
|
7
7
|
:apns_feedback
|
8
8
|
end
|
9
9
|
|
10
|
-
def
|
11
|
-
|
12
|
-
MultiJson.dump(hsh)
|
10
|
+
def to_hash
|
11
|
+
{ type: self.class.to_s, app: app, enabled: enabled, connections: connections, feedback_poll: feedback_poll }
|
13
12
|
end
|
14
13
|
end
|
15
14
|
end
|
data/lib/pushr/daemon/apns.rb
CHANGED
@@ -13,7 +13,7 @@ module Pushr
|
|
13
13
|
connection = ApnsSupport::ConnectionApns.new(configuration, i + 1)
|
14
14
|
connection.connect
|
15
15
|
|
16
|
-
handler = MessageHandler.new("pushr:#{configuration.
|
16
|
+
handler = MessageHandler.new("pushr:#{configuration.key}", connection, configuration.app, i + 1)
|
17
17
|
handler.start
|
18
18
|
@handlers << handler
|
19
19
|
end
|
data/lib/pushr/feedback_apns.rb
CHANGED
@@ -1,12 +1,11 @@
|
|
1
1
|
module Pushr
|
2
2
|
class FeedbackApns < Pushr::Feedback
|
3
|
-
attr_accessor :
|
4
|
-
|
3
|
+
attr_accessor :device, :follow_up, :failed_at
|
5
4
|
validates :device, format: { with: /\A[a-z0-9]{64}\z/ }
|
6
5
|
validates :follow_up, inclusion: { in: %w(delete), message: '%{value} is not a valid follow-up' }
|
7
6
|
|
8
|
-
def
|
9
|
-
|
7
|
+
def to_hash
|
8
|
+
{ type: 'Pushr::FeedbackApns', app: app, device: device, follow_up: follow_up, failed_at: failed_at }
|
10
9
|
end
|
11
10
|
end
|
12
11
|
end
|
data/lib/pushr/message_apns.rb
CHANGED
@@ -2,8 +2,7 @@ module Pushr
|
|
2
2
|
class MessageApns < Pushr::Message
|
3
3
|
POSTFIX = 'apns'
|
4
4
|
|
5
|
-
attr_accessor :
|
6
|
-
|
5
|
+
attr_accessor :device, :badge, :sound, :expiry, :attributes_for_device, :content_available, :priority
|
7
6
|
validates :badge, numericality: true, allow_nil: true
|
8
7
|
validates :expiry, numericality: true, presence: true
|
9
8
|
validates :device, format: { with: /\A[a-z0-9]{64}\z/ }
|
@@ -49,11 +48,12 @@ module Pushr
|
|
49
48
|
payload.bytesize
|
50
49
|
end
|
51
50
|
|
52
|
-
def
|
51
|
+
def to_hash
|
53
52
|
hsh = { type: self.class.to_s, app: app, device: device, alert: alert, badge: badge,
|
54
53
|
sound: sound, expiry: expiry, attributes_for_device: attributes_for_device,
|
55
54
|
content_available: content_available, priority: priority }
|
56
|
-
|
55
|
+
hsh[Pushr::Core.external_id_tag] = external_id if external_id
|
56
|
+
hsh
|
57
57
|
end
|
58
58
|
|
59
59
|
private
|
@@ -17,16 +17,16 @@ describe Pushr::ConfigurationApns do
|
|
17
17
|
|
18
18
|
describe 'create' do
|
19
19
|
it 'should create a configuration' do
|
20
|
-
config = Pushr::ConfigurationApns.new(app: 'app_name', connections: 2, enabled: true, certificate: '
|
21
|
-
sandbox: true, skip_check_for_error: true)
|
20
|
+
config = Pushr::ConfigurationApns.new(app: 'app_name', connections: 2, enabled: true, certificate: 'BEGIN CERTIFICATE',
|
21
|
+
certificate_password: nil, sandbox: true, skip_check_for_error: true)
|
22
22
|
expect(config.key).to eql('app_name:apns')
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
26
|
describe 'save' do
|
27
27
|
let(:config) do
|
28
|
-
Pushr::ConfigurationApns.new(app: 'app_name', connections: 2, enabled: true, certificate: '
|
29
|
-
sandbox: true, skip_check_for_error: true)
|
28
|
+
Pushr::ConfigurationApns.new(app: 'app_name', connections: 2, enabled: true, certificate: 'BEGIN CERTIFICATE',
|
29
|
+
certificate_password: nil, sandbox: true, skip_check_for_error: true)
|
30
30
|
end
|
31
31
|
it 'should save a configuration' do
|
32
32
|
config.save
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pushr-apns
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.
|
4
|
+
version: 1.0.0.rc.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tom Pesman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-06-
|
11
|
+
date: 2014-06-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: multi_json
|