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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 003fa0a9aa2c107746eb4affaa5a22ff13c39914
4
- data.tar.gz: 20aa0e25b3561f31d0fe2fe4bcc0f13b76beaf4e
3
+ metadata.gz: c96cb0793ec34675dad88454fef5acb152b278d7
4
+ data.tar.gz: 21570b81ee97e8fc9132cd9bc8e5ae904e356c18
5
5
  SHA512:
6
- metadata.gz: 5d6a328bb38292445943e19b7fbd9d8ffa7eec962b16d4534afe26c3b930e2d361ec6dc9a96cdeb2587a094e7442db71245f168460acee8bcf8d607a19868fb0
7
- data.tar.gz: 0712b0857645b13c3be749bbf0b6f6a89eadcac3c8292efab28512badafe86309027bd72ec3d589b016f8f9ef841008f1afabdee13dd2f71e95474cd0d69de5a
6
+ metadata.gz: 5cab65d46970744c9fbd0a94fc287cbc999ef7a9e857bc0cbca3f5f20d8d448a2ab25a6dc116c92bc7e6e52305adcee97fab19a9ffd3c60630f520a5ff0ac687
7
+ data.tar.gz: 8fb1f7e0ca76d10ae96fcbe83cc531b9c0a291bc464e6940b52e09595129c50a3529a6aab45aa31849da061b94b8eb8d4a22a588df4565ecdd2f0f4771e589ef
@@ -1,3 +1,3 @@
1
1
  module PushrApns
2
- VERSION = '1.0.0.pre.4'
2
+ VERSION = '1.0.0.rc.1'
3
3
  end
@@ -1,7 +1,7 @@
1
1
  module Pushr
2
2
  class ConfigurationApns < Pushr::Configuration
3
- attr_accessor :id, :type, :app, :enabled, :connections, :certificate, :certificate_password,
4
- :sandbox, :skip_check_for_error
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 to_json
14
- hsh = { type: self.class.to_s, app: app, enabled: enabled, connections: connections, certificate: certificate,
15
- certificate_password: certificate_password, sandbox: sandbox, skip_check_for_error: skip_check_for_error }
16
- MultiJson.dump(hsh)
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 to_json
11
- hsh = { type: self.class.to_s, app: app, enabled: enabled, connections: connections, feedback_poll: feedback_poll }
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
@@ -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.app}:#{configuration.name}", connection, configuration.app, i + 1)
16
+ handler = MessageHandler.new("pushr:#{configuration.key}", connection, configuration.app, i + 1)
17
17
  handler.start
18
18
  @handlers << handler
19
19
  end
@@ -2,7 +2,6 @@ module Pushr
2
2
  module Daemon
3
3
  module ApnsSupport
4
4
  class FeedbackReceiver
5
-
6
5
  FEEDBACK_TUPLE_BYTES = 38
7
6
 
8
7
  def initialize(configuration, _)
@@ -1,12 +1,11 @@
1
1
  module Pushr
2
2
  class FeedbackApns < Pushr::Feedback
3
- attr_accessor :type, :app, :device, :follow_up, :failed_at
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 to_json
9
- MultiJson.dump(type: 'Pushr::FeedbackApns', app: app, device: device, follow_up: follow_up, failed_at: failed_at)
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
@@ -2,8 +2,7 @@ module Pushr
2
2
  class MessageApns < Pushr::Message
3
3
  POSTFIX = 'apns'
4
4
 
5
- attr_accessor :type, :app, :device, :badge, :sound, :expiry, :attributes_for_device, :content_available, :priority
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 to_json
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
- MultiJson.dump(hsh)
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: 'test', certificate_password: nil,
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: 'test', certificate_password: nil,
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.pre.4
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-12 00:00:00.000000000 Z
11
+ date: 2014-06-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json