grocer 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +1 -2
- data/README.md +23 -0
- data/lib/grocer/notification.rb +3 -2
- data/lib/grocer/version.rb +1 -1
- data/spec/grocer/connection_spec.rb +1 -1
- data/spec/grocer/feedback_connection_spec.rb +1 -1
- data/spec/grocer/notification_spec.rb +4 -1
- data/spec/grocer/push_connection_spec.rb +1 -1
- metadata +19 -13
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -10,6 +10,10 @@ to send push notifications to iOS devices.
|
|
10
10
|
There are other gems out there to do this, but **grocer** plans to be the
|
11
11
|
cleanest, most extensible, and friendliest.
|
12
12
|
|
13
|
+
## Requirements
|
14
|
+
|
15
|
+
* Ruby/MRI 1.9.x *or* Rubinius in 1.9 mode (JRuby in 1.9 is broken due to some problem with 'json' not being in the stdlib?)
|
16
|
+
|
13
17
|
## Installation
|
14
18
|
|
15
19
|
Add this line to your application's Gemfile:
|
@@ -75,6 +79,25 @@ notifications.each do |notification|
|
|
75
79
|
end
|
76
80
|
```
|
77
81
|
|
82
|
+
#### Custom Payloads
|
83
|
+
|
84
|
+
The Apple documentation says "Providers can specify custom payload values
|
85
|
+
outside the Apple-reserved aps namespace." To specify a custom payload, set
|
86
|
+
`Grocer::Notification#custom`.
|
87
|
+
|
88
|
+
```ruby
|
89
|
+
notification = Grocer::Notification.new(
|
90
|
+
device_token: "...",
|
91
|
+
alert: "Hello from Grocer",
|
92
|
+
custom: {
|
93
|
+
"acme2": ["bang", "whiz"]
|
94
|
+
}
|
95
|
+
)
|
96
|
+
|
97
|
+
# Generates a JSON payload like:
|
98
|
+
# {"aps": {"alert": "Hello from Grocer"}, "acme2": ["bang", "whiz"]}
|
99
|
+
```
|
100
|
+
|
78
101
|
### Feedback
|
79
102
|
|
80
103
|
```ruby
|
data/lib/grocer/notification.rb
CHANGED
@@ -3,7 +3,8 @@ require_relative 'no_payload_error'
|
|
3
3
|
|
4
4
|
module Grocer
|
5
5
|
class Notification
|
6
|
-
attr_accessor :identifier, :expiry, :device_token, :alert, :badge, :sound
|
6
|
+
attr_accessor :identifier, :expiry, :device_token, :alert, :badge, :sound,
|
7
|
+
:custom
|
7
8
|
|
8
9
|
def initialize(payload = {})
|
9
10
|
@identifier = 0
|
@@ -36,7 +37,7 @@ module Grocer
|
|
36
37
|
aps_hash[:badge] = badge if badge
|
37
38
|
aps_hash[:sound] = sound if sound
|
38
39
|
|
39
|
-
{ aps: aps_hash }
|
40
|
+
{ aps: aps_hash }.merge(custom || { })
|
40
41
|
end
|
41
42
|
|
42
43
|
def expiry_epoch_time
|
data/lib/grocer/version.rb
CHANGED
@@ -99,7 +99,7 @@ describe Grocer::Connection do
|
|
99
99
|
|
100
100
|
it "retries #write in the case of an #{error}" do
|
101
101
|
ssl.stubs(:write).raises(error).then.returns(42)
|
102
|
-
subject.write(
|
102
|
+
subject.write('abc123')
|
103
103
|
end
|
104
104
|
|
105
105
|
it 'raises the error if none of the retries work' do
|
@@ -4,7 +4,7 @@ require 'grocer/feedback_connection'
|
|
4
4
|
describe Grocer::FeedbackConnection do
|
5
5
|
subject { described_class.new(options) }
|
6
6
|
let(:options) { { certificate: '/path/to/cert.pem' } }
|
7
|
-
let(:connection) { stub(
|
7
|
+
let(:connection) { stub('Connection') }
|
8
8
|
|
9
9
|
it 'delegates reading to the Connection' do
|
10
10
|
Grocer::Connection.any_instance.expects(:read).with(42, 'lolIO')
|
@@ -66,7 +66,10 @@ describe Grocer::Notification do
|
|
66
66
|
payload_dictionary_from_bytes[:aps][:sound].should == 'siren.aiff'
|
67
67
|
end
|
68
68
|
|
69
|
-
it 'encodes custom payload attributes'
|
69
|
+
it 'encodes custom payload attributes' do
|
70
|
+
notification.custom = { :foo => 'bar' }
|
71
|
+
payload_dictionary_from_bytes[:foo].should == 'bar'
|
72
|
+
end
|
70
73
|
|
71
74
|
context 'invalid payload' do
|
72
75
|
let(:payload_options) { Hash.new }
|
@@ -4,7 +4,7 @@ require 'grocer/push_connection'
|
|
4
4
|
describe Grocer::PushConnection do
|
5
5
|
subject { described_class.new(options) }
|
6
6
|
let(:options) { { certificate: '/path/to/cert.pem' } }
|
7
|
-
let(:connection) { stub(
|
7
|
+
let(:connection) { stub('Connection') }
|
8
8
|
|
9
9
|
it 'delegates reading to the Connection' do
|
10
10
|
Grocer::Connection.any_instance.expects(:read).with(42, 'lolIO')
|
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.0.
|
4
|
+
version: 0.0.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,11 +11,11 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2012-04-
|
14
|
+
date: 2012-04-04 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: rspec
|
18
|
-
requirement: &
|
18
|
+
requirement: &70100208337060 !ruby/object:Gem::Requirement
|
19
19
|
none: false
|
20
20
|
requirements:
|
21
21
|
- - ~>
|
@@ -23,10 +23,10 @@ dependencies:
|
|
23
23
|
version: 2.9.0
|
24
24
|
type: :development
|
25
25
|
prerelease: false
|
26
|
-
version_requirements: *
|
26
|
+
version_requirements: *70100208337060
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: pry
|
29
|
-
requirement: &
|
29
|
+
requirement: &70100208503620 !ruby/object:Gem::Requirement
|
30
30
|
none: false
|
31
31
|
requirements:
|
32
32
|
- - ~>
|
@@ -34,10 +34,10 @@ dependencies:
|
|
34
34
|
version: 0.9.8
|
35
35
|
type: :development
|
36
36
|
prerelease: false
|
37
|
-
version_requirements: *
|
37
|
+
version_requirements: *70100208503620
|
38
38
|
- !ruby/object:Gem::Dependency
|
39
39
|
name: mocha
|
40
|
-
requirement: &
|
40
|
+
requirement: &70100208502540 !ruby/object:Gem::Requirement
|
41
41
|
none: false
|
42
42
|
requirements:
|
43
43
|
- - ! '>='
|
@@ -45,10 +45,10 @@ dependencies:
|
|
45
45
|
version: '0'
|
46
46
|
type: :development
|
47
47
|
prerelease: false
|
48
|
-
version_requirements: *
|
48
|
+
version_requirements: *70100208502540
|
49
49
|
- !ruby/object:Gem::Dependency
|
50
50
|
name: bourne
|
51
|
-
requirement: &
|
51
|
+
requirement: &70100208497180 !ruby/object:Gem::Requirement
|
52
52
|
none: false
|
53
53
|
requirements:
|
54
54
|
- - ! '>='
|
@@ -56,10 +56,10 @@ dependencies:
|
|
56
56
|
version: '0'
|
57
57
|
type: :development
|
58
58
|
prerelease: false
|
59
|
-
version_requirements: *
|
59
|
+
version_requirements: *70100208497180
|
60
60
|
- !ruby/object:Gem::Dependency
|
61
61
|
name: rake
|
62
|
-
requirement: &
|
62
|
+
requirement: &70100208581300 !ruby/object:Gem::Requirement
|
63
63
|
none: false
|
64
64
|
requirements:
|
65
65
|
- - ! '>='
|
@@ -67,7 +67,7 @@ dependencies:
|
|
67
67
|
version: '0'
|
68
68
|
type: :development
|
69
69
|
prerelease: false
|
70
|
-
version_requirements: *
|
70
|
+
version_requirements: *70100208581300
|
71
71
|
description: ! " Grocer interfaces with the Apple Push\n
|
72
72
|
\ Notification Service to send push\n notifications
|
73
73
|
to iOS devices and collect\n notification feedback via
|
@@ -130,15 +130,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
130
130
|
- - ! '>='
|
131
131
|
- !ruby/object:Gem::Version
|
132
132
|
version: '0'
|
133
|
+
segments:
|
134
|
+
- 0
|
135
|
+
hash: -942820174361288389
|
133
136
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
134
137
|
none: false
|
135
138
|
requirements:
|
136
139
|
- - ! '>='
|
137
140
|
- !ruby/object:Gem::Version
|
138
141
|
version: '0'
|
142
|
+
segments:
|
143
|
+
- 0
|
144
|
+
hash: -942820174361288389
|
139
145
|
requirements: []
|
140
146
|
rubyforge_project:
|
141
|
-
rubygems_version: 1.8.
|
147
|
+
rubygems_version: 1.8.15
|
142
148
|
signing_key:
|
143
149
|
specification_version: 3
|
144
150
|
summary: Pushing Apple notifications since 2012.
|