bmo 0.8.12 → 0.8.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +13 -5
- data/Gemfile.lock +1 -1
- data/lib/bmo/apns/notification.rb +3 -3
- data/lib/bmo/version.rb +1 -1
- data/lib/bmo.rb +1 -1
- data/spec/bmo/apns/notification_spec.rb +12 -12
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,15 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
YWZjZWQ3MDZmOGI1NWNlMjVkMzNjOTk0NjA0MWY3NWI2MmQ1MzNjYg==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
OTM2NWY1YWU0MDRkZDgyZWRlNjA5NDI1ODg0MjM2MDA0Mjg2ZWI2MQ==
|
5
7
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
NTM1MjMyY2ZjOTAyNzJlNTY2YjQ0NGVlOTcyMDIxNWVlNzVmNjdjY2UwMDcy
|
10
|
+
ZTJiMWYwYjlmODIyYmRhODgyM2E5Y2I4NWU2NTAzMDJmNmIxZTkyNmJkMjMx
|
11
|
+
YjBjN2YyNzlhOTM1NGVkMWU1MmFlZmRkM2U3ZWNkOTA0NjQ4Mzk=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
MmZmMjYwMTM1M2JmYzc4ZTZhMzZlZDI1YjcwOThkZTJkZmZjMjEzNTkwM2U2
|
14
|
+
N2ExNTkyZjg3NjFjM2E4NWMwZTRkYTI5ZjViNjZmOWRiMmJlNjA0NzI3MTU4
|
15
|
+
NjA2ZTlhM2EzOWQ4ZTU1YWU0ODlkNmI5NWJiZWNiNTkxODNiMDU=
|
data/Gemfile.lock
CHANGED
@@ -66,11 +66,11 @@ module BMO
|
|
66
66
|
end
|
67
67
|
|
68
68
|
def truncate_field!
|
69
|
-
return unless data[:
|
70
|
-
string = data[:
|
69
|
+
return unless data[:aps] && data[:aps][truncable_field]
|
70
|
+
string = data[:aps][truncable_field]
|
71
71
|
diff_bytesize = package.bytesize - MAX_BYTE_SIZE
|
72
72
|
desirable_bytesize = (string.bytesize - diff_bytesize) - 1
|
73
|
-
data[:
|
73
|
+
data[:aps][truncable_field] = Utils
|
74
74
|
.bytesize_force_truncate(string, desirable_bytesize, options)
|
75
75
|
end
|
76
76
|
|
data/lib/bmo/version.rb
CHANGED
data/lib/bmo.rb
CHANGED
@@ -26,7 +26,7 @@ module BMO
|
|
26
26
|
# @param device_token [String]
|
27
27
|
# @param data [Hash] The data you want to send
|
28
28
|
# @option options :truncable_field If the payload is too large
|
29
|
-
# this field will be truncated, it must be in
|
29
|
+
# this field will be truncated, it must be in an aps hash
|
30
30
|
# @option options :omission ('...') The omission in truncate
|
31
31
|
# @option options :separator The separator use in truncation
|
32
32
|
#
|
@@ -33,11 +33,11 @@ end
|
|
33
33
|
describe BMO::APNS::Notification::Payload do
|
34
34
|
describe '#validate!' do
|
35
35
|
it 'returns true if the payload is valid' do
|
36
|
-
payload = described_class.new(
|
36
|
+
payload = described_class.new(aps: 'a' * 200)
|
37
37
|
expect(payload.validate!).to be_true
|
38
38
|
end
|
39
39
|
it 'raises an error if the payload is too large' do
|
40
|
-
payload = described_class.new(
|
40
|
+
payload = described_class.new(aps: 'a' * 256)
|
41
41
|
expect { payload.validate! }.to raise_error(
|
42
42
|
BMO::APNS::Notification::Payload::PayloadTooLarge)
|
43
43
|
end
|
@@ -46,37 +46,37 @@ describe BMO::APNS::Notification::Payload do
|
|
46
46
|
describe '#to_package' do
|
47
47
|
it 'truncates if there is a truncable field and this is not valid' do
|
48
48
|
options = { truncable_field: :message }
|
49
|
-
payload = described_class.new({
|
50
|
-
expect(payload.to_package).to eq("{\"
|
49
|
+
payload = described_class.new({ aps: { message: 'a' * 256 } }, options)
|
50
|
+
expect(payload.to_package).to eq("{\"aps\":{\"message\":\"#{'a' * 230}...\"}}")
|
51
51
|
end
|
52
52
|
|
53
53
|
it 'truncates to respect the MAX_BYTE_SIZE' do
|
54
54
|
options = { truncable_field: :message }
|
55
|
-
payload = described_class.new({
|
55
|
+
payload = described_class.new({ aps: { message: 'a' * 256 } }, options)
|
56
56
|
expect(payload.to_package.bytesize).to be < BMO::APNS::Notification::Payload::MAX_BYTE_SIZE
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
60
60
|
describe '#truncable_field!' do
|
61
|
-
it 'truncates the corresponding field in
|
61
|
+
it 'truncates the corresponding field in aps' do
|
62
62
|
options = { truncable_field: :message }
|
63
|
-
payload = described_class.new({
|
63
|
+
payload = described_class.new({ aps: { message: 'a' * 256 } }, options)
|
64
64
|
payload.truncate_field!
|
65
|
-
expect(payload.data[:
|
65
|
+
expect(payload.data[:aps][:message]).to eq(('a' * 230) + '...')
|
66
66
|
end
|
67
67
|
|
68
68
|
it 'truncates with omission' do
|
69
69
|
options = { truncable_field: :message, omission: '[more]' }
|
70
|
-
payload = described_class.new({
|
70
|
+
payload = described_class.new({ aps: { message: 'a' * 256 } }, options)
|
71
71
|
payload.truncate_field!
|
72
|
-
expect(payload.data[:
|
72
|
+
expect(payload.data[:aps][:message]).to eq(('a' * 227) + '[more]')
|
73
73
|
end
|
74
74
|
|
75
75
|
it 'truncates with separator' do
|
76
76
|
options = { truncable_field: :message, separator: ' ' }
|
77
|
-
payload = described_class.new({
|
77
|
+
payload = described_class.new({ aps: { message: 'test ' + ('a' * 255) } }, options)
|
78
78
|
payload.truncate_field!
|
79
|
-
expect(payload.data[:
|
79
|
+
expect(payload.data[:aps][:message]).to eq('test...')
|
80
80
|
end
|
81
81
|
end
|
82
82
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bmo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Antoine Lyset
|
@@ -28,14 +28,14 @@ dependencies:
|
|
28
28
|
name: faraday
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - '>'
|
31
|
+
- - ! '>'
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: 0.8.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - '>'
|
38
|
+
- - ! '>'
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 0.8.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
@@ -56,14 +56,14 @@ dependencies:
|
|
56
56
|
name: rake
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - '>='
|
59
|
+
- - ! '>='
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - '>='
|
66
|
+
- - ! '>='
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
description: Push notifications to iOS and Android devices
|
@@ -107,17 +107,17 @@ require_paths:
|
|
107
107
|
- lib
|
108
108
|
required_ruby_version: !ruby/object:Gem::Requirement
|
109
109
|
requirements:
|
110
|
-
- - '>='
|
110
|
+
- - ! '>='
|
111
111
|
- !ruby/object:Gem::Version
|
112
112
|
version: '0'
|
113
113
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
|
-
- - '>='
|
115
|
+
- - ! '>='
|
116
116
|
- !ruby/object:Gem::Version
|
117
117
|
version: '0'
|
118
118
|
requirements: []
|
119
119
|
rubyforge_project:
|
120
|
-
rubygems_version: 2.
|
120
|
+
rubygems_version: 2.2.2
|
121
121
|
signing_key:
|
122
122
|
specification_version: 4
|
123
123
|
summary: Push notifications to iOS and Android devices
|