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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d758bbd299d221fe50d6a3b9d736dce0ae5016fb
4
- data.tar.gz: f29ab31ea4fd92da51b624c84172578354e96246
3
+ metadata.gz: c6555a705340dbf836a1e108191917cb6e070cd4
4
+ data.tar.gz: ff071fb2ba59d97b416843adfd3242482628cb0a
5
5
  SHA512:
6
- metadata.gz: 8fea57524b210a9c547f6efcb17f775210cc591e1d04a904828fa9ac4d388aa0d4b31bc2a74f8b025b9d48f29618ec59f6b0deb5ee3ee2a789d1b4e47c68dece
7
- data.tar.gz: 642f3a3612148d4a721f4bcc554aa9168e89eb0adb5ffbd4a6b9fc35e14187c1143306577a49b223e642caa6be9d1833bbc1bfd355463d97dbc06cbf22ca06ee
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
- payload.merge!(payload_hash.delete(:aps) || { })
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
@@ -1,3 +1,3 @@
1
1
  module Grocer
2
- VERSION = '0.4.0'
2
+ VERSION = '0.4.1'
3
3
  end
@@ -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.0
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-18 00:00:00.000000000 Z
13
+ date: 2013-06-20 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rspec