grocer 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/grocer/notification_reader.rb +14 -1
- data/lib/grocer/version.rb +1 -1
- data/spec/grocer/notification_reader_spec.rb +8 -0
- 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: c6555a705340dbf836a1e108191917cb6e070cd4
|
4
|
+
data.tar.gz: ff071fb2ba59d97b416843adfd3242482628cb0a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 18b17445045304ce0dca3673e8f56188fea6c94df2870a6c56dce035dc79af6c8c6dab48900d3aac37b6a5e687dd5e7486dc6285f4c90b3274ba6292ba90f4c7
|
7
|
+
data.tar.gz: 99874e8769c23afd6a8f5401fae5f276cc6f17b1b65e920d2ed3cfbbbe60bc5ce3a7aeb451de1d08a5cdf97cec368217cd861ed6c309e325fbdc572509cf6619
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,11 @@
|
|
2
2
|
|
3
3
|
## Unreleased
|
4
4
|
|
5
|
+
## 0.4.1
|
6
|
+
|
7
|
+
* Fix `Grocer::NotificationReader`, ensuring it sanitizes incoming `aps`
|
8
|
+
payload keys before building a new `Grocer::Notification`.
|
9
|
+
|
5
10
|
## 0.4.0
|
6
11
|
|
7
12
|
* Add support for `content-available` for background fetches (iOS 7) for all
|
@@ -30,10 +30,23 @@ module Grocer
|
|
30
30
|
payload_length = @io.read(2).unpack("n").first
|
31
31
|
payload_hash = JSON.parse(@io.read(payload_length), symbolize_names: true)
|
32
32
|
|
33
|
-
|
33
|
+
aps = sanitize_keys(payload_hash.delete(:aps))
|
34
|
+
payload.merge!(aps)
|
35
|
+
|
34
36
|
payload[:custom] = payload_hash
|
35
37
|
|
36
38
|
Grocer::Notification.new(payload)
|
37
39
|
end
|
40
|
+
|
41
|
+
def sanitize_keys(hash)
|
42
|
+
hash ||= {}
|
43
|
+
|
44
|
+
clean_hash = hash.map { |k, v|
|
45
|
+
new_key = k.to_s.gsub(/-/i, '_').to_sym
|
46
|
+
[new_key, v]
|
47
|
+
}
|
48
|
+
|
49
|
+
Hash[clean_hash]
|
50
|
+
end
|
38
51
|
end
|
39
52
|
end
|
data/lib/grocer/version.rb
CHANGED
@@ -62,5 +62,13 @@ describe Grocer::NotificationReader do
|
|
62
62
|
notification = subject.first
|
63
63
|
expect(notification.custom).to eq({ foo: "bar" })
|
64
64
|
end
|
65
|
+
|
66
|
+
it "reads content-available" do
|
67
|
+
io.write(Grocer::Notification.new(alert: "Foo", content_available: true).to_bytes)
|
68
|
+
io.rewind
|
69
|
+
|
70
|
+
notification = subject.first
|
71
|
+
expect(notification.content_available).to be_true
|
72
|
+
end
|
65
73
|
end
|
66
74
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: grocer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andy Lindeman
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-06-
|
13
|
+
date: 2013-06-20 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rspec
|