wireframe-apn_on_rails 0.3.0.20110214201719 → 0.3.0.20130122094500

Sign up to get free protection for your applications and to get access to all the features.
@@ -38,7 +38,7 @@ module APN # :nodoc:
38
38
 
39
39
  # Raised when a notification message to Apple is longer than 256 bytes.
40
40
  class ExceededMessageSizeError < StandardError
41
- MAX_BYTES = 255
41
+ MAX_BYTES = 256
42
42
  def initialize(message) # :nodoc:
43
43
  super("The maximum size allowed for a notification payload is #{MAX_BYTES} bytes: '#{message}'")
44
44
  end
@@ -62,4 +62,4 @@ end
62
62
  ActiveSupport::Dependencies.load_paths << path
63
63
  ActiveSupport::Dependencies.load_once_paths.delete(path)
64
64
  end
65
- end
65
+ end
@@ -13,7 +13,7 @@ class APN::Device < APN::Base
13
13
  has_many :notifications, :class_name => 'APN::Notification'
14
14
 
15
15
  validates_uniqueness_of :token
16
- validates_format_of :token, :with => /^[a-z0-9]{8}\s[a-z0-9]{8}\s[a-z0-9]{8}\s[a-z0-9]{8}\s[a-z0-9]{8}\s[a-z0-9]{8}\s[a-z0-9]{8}\s[a-z0-9]{8}$/
16
+ validates_format_of :token, :with => /\A[a-z0-9]{8}\s[a-z0-9]{8}\s[a-z0-9]{8}\s[a-z0-9]{8}\s[a-z0-9]{8}\s[a-z0-9]{8}\s[a-z0-9]{8}\s[a-z0-9]{8}\z/
17
17
 
18
18
  before_save :set_last_registered_at
19
19
 
@@ -45,4 +45,4 @@ class APN::Device < APN::Base
45
45
  self.last_registered_at = Time.now if self.last_registered_at.nil?
46
46
  end
47
47
 
48
- end
48
+ end
@@ -59,9 +59,12 @@ class APN::Notification < APN::Base
59
59
  # see http://developer.apple.com/IPhone/library/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CommunicatingWIthAPS/CommunicatingWIthAPS.html#//apple_ref/doc/uid/TP40008194-CH101-SW4
60
60
  def message_for_sending
61
61
  json = self.to_apple_json
62
- raise APN::Errors::ExceededMessageSizeError.new(json) if json.size.to_i > APN::Errors::ExceededMessageSizeError::MAX_BYTES
63
-
64
- "\0\0 #{self.device.to_hexa}\0#{(json.length).chr}#{json}"
62
+ message = "\0\0 #{self.device.to_hexa}\0#{encode((json.bytesize).chr)}#{encode(json)}"
63
+ raise APN::Errors::ExceededMessageSizeError.new(message) if message.bytesize.to_i > APN::Errors::ExceededMessageSizeError::MAX_BYTES
64
+ message
65
+ end
66
+ def encode(string)
67
+ string.respond_to?(:force_encoding) ? string.force_encoding('BINARY') : string
65
68
  end
66
69
 
67
70
  class << self
@@ -107,4 +110,4 @@ class APN::Notification < APN::Base
107
110
  end
108
111
  end
109
112
  end
110
- end # APN::Notification
113
+ end # APN::Notification
metadata CHANGED
@@ -1,62 +1,56 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: wireframe-apn_on_rails
3
- version: !ruby/object:Gem::Version
4
- hash: 40220428403385
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.0.20130122094500
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 3
9
- - 0
10
- - 20110214201719
11
- version: 0.3.0.20110214201719
12
6
  platform: ruby
13
- authors:
7
+ authors:
14
8
  - ryan
15
9
  autorequire:
16
10
  bindir: bin
17
11
  cert_chain: []
18
-
19
- date: 2011-02-14 00:00:00 -06:00
20
- default_executable:
21
- dependencies:
22
- - !ruby/object:Gem::Dependency
12
+ date: 2011-02-14 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
23
15
  name: configatron
24
- prerelease: false
25
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
26
17
  none: false
27
- requirements:
28
- - - ">="
29
- - !ruby/object:Gem::Version
30
- hash: 3
31
- segments:
32
- - 0
33
- version: "0"
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
34
22
  type: :runtime
35
- version_requirements: *id001
36
- - !ruby/object:Gem::Dependency
37
- name: activerecord
38
23
  prerelease: false
39
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: activerecord
32
+ requirement: !ruby/object:Gem::Requirement
40
33
  none: false
41
- requirements:
42
- - - ">="
43
- - !ruby/object:Gem::Version
44
- hash: 3
45
- segments:
46
- - 0
47
- version: "0"
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
48
38
  type: :runtime
49
- version_requirements: *id002
50
- description: "apn_on_rails was developed by: ryan"
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ description: ! 'apn_on_rails was developed by: ryan'
51
47
  email: mark@markbates.com
52
48
  executables: []
53
-
54
49
  extensions: []
55
-
56
- extra_rdoc_files:
50
+ extra_rdoc_files:
57
51
  - README
58
52
  - LICENSE
59
- files:
53
+ files:
60
54
  - lib/apn_on_rails/apn_on_rails.rb
61
55
  - lib/apn_on_rails/app/models/apn/base.rb
62
56
  - lib/apn_on_rails/app/models/apn/device.rb
@@ -74,39 +68,28 @@ files:
74
68
  - generators/templates/apn_migrations/002_create_apn_notifications.rb
75
69
  - generators/templates/apn_migrations/003_alter_apn_devices.rb
76
70
  - generators/templates/apn_migrations/004_add_payload_to_notifications.rb
77
- has_rdoc: true
78
71
  homepage: http://www.metabates.com
79
72
  licenses: []
80
-
81
73
  post_install_message:
82
74
  rdoc_options: []
83
-
84
- require_paths:
75
+ require_paths:
85
76
  - lib
86
- required_ruby_version: !ruby/object:Gem::Requirement
77
+ required_ruby_version: !ruby/object:Gem::Requirement
87
78
  none: false
88
- requirements:
89
- - - ">="
90
- - !ruby/object:Gem::Version
91
- hash: 3
92
- segments:
93
- - 0
94
- version: "0"
95
- required_rubygems_version: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ! '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ required_rubygems_version: !ruby/object:Gem::Requirement
96
84
  none: false
97
- requirements:
98
- - - ">="
99
- - !ruby/object:Gem::Version
100
- hash: 3
101
- segments:
102
- - 0
103
- version: "0"
85
+ requirements:
86
+ - - ! '>='
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
104
89
  requirements: []
105
-
106
90
  rubyforge_project: magrathea
107
- rubygems_version: 1.5.2
91
+ rubygems_version: 1.8.24
108
92
  signing_key:
109
93
  specification_version: 3
110
94
  summary: apn_on_rails
111
95
  test_files: []
112
-