grocer 0.0.10 → 0.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +13 -8
- data/lib/grocer.rb +7 -7
- data/lib/grocer/extensions/deep_symbolize_keys.rb +16 -0
- data/lib/grocer/failed_delivery_attempt.rb +1 -1
- data/lib/grocer/feedback.rb +1 -1
- data/lib/grocer/feedback_connection.rb +4 -2
- data/lib/grocer/notification.rb +1 -1
- data/lib/grocer/notification_reader.rb +1 -1
- data/lib/grocer/push_connection.rb +4 -2
- data/lib/grocer/server.rb +2 -2
- data/lib/grocer/ssl_connection.rb +1 -1
- data/lib/grocer/ssl_server.rb +3 -1
- data/lib/grocer/version.rb +1 -1
- data/spec/grocer/extensions/deep_symbolize_keys_spec.rb +36 -0
- metadata +5 -8
data/README.md
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
[](http://travis-ci.org/highgroove/grocer)
|
4
4
|
[](https://gemnasium.com/highgroove/grocer)
|
5
|
+
[](https://codeclimate.com/github/highgroove/grocer)
|
5
6
|
|
6
7
|
**grocer** interfaces with the [Apple Push Notification
|
7
8
|
Service](http://developer.apple.com/library/mac/#documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/ApplePushService/ApplePushService.html)
|
@@ -12,7 +13,8 @@ cleanest, most extensible, and friendliest.
|
|
12
13
|
|
13
14
|
## Requirements
|
14
15
|
|
15
|
-
* Ruby/MRI 1.9.x *or* Rubinius in 1.9 mode (JRuby in 1.9 is broken due to some
|
16
|
+
* Ruby/MRI 1.9.x *or* Rubinius in 1.9 mode (JRuby in 1.9 is broken due to some
|
17
|
+
problem with `json` not being in the stdlib?)
|
16
18
|
|
17
19
|
## Installation
|
18
20
|
|
@@ -46,7 +48,7 @@ pusher = Grocer.pusher(
|
|
46
48
|
* `gateway`: Defaults to different values depending on the `RAILS_ENV` or
|
47
49
|
`RACK_ENV` environment variables. If set to `production`, defaults to
|
48
50
|
`gateway.push.apple.com`, if set to `test`, defaults to `localhost` (see
|
49
|
-
|
51
|
+
[Acceptance Testing](#acceptance-testing) later), otherwise defaults to
|
50
52
|
`gateway.sandbox.push.apple.com`.
|
51
53
|
* `retries`: The number of times **grocer** will retry writing to or reading
|
52
54
|
from the Apple Push Notification Service before raising any errors to client
|
@@ -127,7 +129,7 @@ end
|
|
127
129
|
from the Apple Push Notification Service before raising any errors to client
|
128
130
|
code.
|
129
131
|
|
130
|
-
|
132
|
+
### Acceptance Testing
|
131
133
|
|
132
134
|
Grocer ships with framework to setup a real looking APNS server. It listens on
|
133
135
|
a real SSL-capable socket bound to localhost.
|
@@ -165,7 +167,7 @@ describe "apple push notifications" do
|
|
165
167
|
end
|
166
168
|
```
|
167
169
|
|
168
|
-
|
170
|
+
## Device Token
|
169
171
|
|
170
172
|
A device token is obtained from within the iOS app. More details are in Apple's
|
171
173
|
[Registering for Remote
|
@@ -191,15 +193,17 @@ The key code for this purpose is:
|
|
191
193
|
}
|
192
194
|
```
|
193
195
|
|
194
|
-
|
196
|
+
## Certificate File
|
195
197
|
|
196
198
|
Login to the [iOS Provisioning Portal (App IDs)](https://developer.apple.com/ios/manage/bundles/index.action).
|
197
199
|
|
198
|
-
Configure the appropriate certificate for push notifications and download the
|
200
|
+
Configure the appropriate certificate for push notifications and download the
|
201
|
+
certificate:
|
199
202
|
|
200
203
|

|
201
204
|
|
202
|
-
Open the file in Keychain Access, then expand the certificate to show both the
|
205
|
+
Open the file in Keychain Access, then expand the certificate to show both the
|
206
|
+
certificate *and* the private key. Command select so both are highlighted:
|
203
207
|
|
204
208
|

|
205
209
|
|
@@ -207,7 +211,8 @@ Control click and select to export the 2 items:
|
|
207
211
|
|
208
212
|

|
209
213
|
|
210
|
-
Save the items as a `.p12` file. Open a terminal window and run the following
|
214
|
+
Save the items as a `.p12` file. Open a terminal window and run the following
|
215
|
+
command:
|
211
216
|
|
212
217
|
```bash
|
213
218
|
openssl pkcs12 -in exported_certificate.p12 -out certificate.pem -nodes -clcerts
|
data/lib/grocer.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
1
|
+
require 'grocer/feedback'
|
2
|
+
require 'grocer/notification'
|
3
|
+
require 'grocer/feedback_connection'
|
4
|
+
require 'grocer/push_connection'
|
5
|
+
require 'grocer/pusher'
|
6
|
+
require 'grocer/version'
|
7
|
+
require 'grocer/server'
|
8
8
|
|
9
9
|
module Grocer
|
10
10
|
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Grocer
|
2
|
+
module Extensions
|
3
|
+
module DeepSymbolizeKeys
|
4
|
+
|
5
|
+
def deep_symbolize_keys
|
6
|
+
result = {}
|
7
|
+
each do |key, value|
|
8
|
+
result[(key.to_sym rescue key)] = value.is_a?(Hash) ?
|
9
|
+
(value.extend DeepSymbolizeKeys).deep_symbolize_keys : value
|
10
|
+
end
|
11
|
+
result
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/grocer/feedback.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'delegate'
|
2
|
-
|
2
|
+
require 'grocer/extensions/deep_symbolize_keys'
|
3
|
+
require 'grocer/connection'
|
3
4
|
|
4
5
|
module Grocer
|
5
6
|
class FeedbackConnection < SimpleDelegator
|
@@ -8,7 +9,8 @@ module Grocer
|
|
8
9
|
SANDBOX_GATEWAY = 'feedback.sandbox.push.apple.com'
|
9
10
|
|
10
11
|
def initialize(options)
|
11
|
-
options
|
12
|
+
options.extend Extensions::DeepSymbolizeKeys
|
13
|
+
options = defaults.merge(options.deep_symbolize_keys)
|
12
14
|
super(Connection.new(options))
|
13
15
|
end
|
14
16
|
|
data/lib/grocer/notification.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'delegate'
|
2
|
-
|
2
|
+
require 'grocer/extensions/deep_symbolize_keys'
|
3
|
+
require 'grocer/connection'
|
3
4
|
|
4
5
|
module Grocer
|
5
6
|
class PushConnection < SimpleDelegator
|
@@ -9,7 +10,8 @@ module Grocer
|
|
9
10
|
SANDBOX_GATEWAY = 'gateway.sandbox.push.apple.com'
|
10
11
|
|
11
12
|
def initialize(options)
|
12
|
-
options
|
13
|
+
options.extend Extensions::DeepSymbolizeKeys
|
14
|
+
options = defaults.merge(options.deep_symbolize_keys)
|
13
15
|
super(Connection.new(options))
|
14
16
|
end
|
15
17
|
|
data/lib/grocer/server.rb
CHANGED
data/lib/grocer/ssl_server.rb
CHANGED
@@ -1,13 +1,15 @@
|
|
1
1
|
require 'openssl'
|
2
2
|
require 'socket'
|
3
3
|
require 'thread'
|
4
|
+
require 'grocer/extensions/deep_symbolize_keys'
|
4
5
|
|
5
6
|
module Grocer
|
6
7
|
class SSLServer
|
7
8
|
attr_accessor :port
|
8
9
|
|
9
10
|
def initialize(options = {})
|
10
|
-
options
|
11
|
+
options.extend Extensions::DeepSymbolizeKeys
|
12
|
+
options = defaults.merge(options.deep_symbolize_keys)
|
11
13
|
options.each { |k, v| send("#{k}=", v) }
|
12
14
|
end
|
13
15
|
|
data/lib/grocer/version.rb
CHANGED
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'grocer/extensions/deep_symbolize_keys'
|
2
|
+
|
3
|
+
describe Grocer::Extensions::DeepSymbolizeKeys do
|
4
|
+
let(:nested_strings) { { 'a' => { 'b' => { 'c' => 3 } } } }
|
5
|
+
let(:nested_symbols) { { :a => { :b => { :c => 3 } } } }
|
6
|
+
let(:nested_mixed) { { 'a' => { :b => { 'c' => 3 } } } }
|
7
|
+
let(:nested_fixnums) { { 0 => { 1 => { 2 => 3} } } }
|
8
|
+
let(:nested_illegal_symbols) { { [] => { [] => 3} } }
|
9
|
+
before do
|
10
|
+
nested_symbols.extend described_class
|
11
|
+
nested_strings.extend described_class
|
12
|
+
nested_mixed.extend described_class
|
13
|
+
nested_fixnums.extend described_class
|
14
|
+
nested_illegal_symbols.extend described_class
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'does not change nested symbols' do
|
18
|
+
nested_symbols.deep_symbolize_keys.should == nested_symbols
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'symbolizes nested strings' do
|
22
|
+
nested_strings.deep_symbolize_keys.should == nested_symbols
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'symbolizes a mix of nested strings and symbols' do
|
26
|
+
nested_mixed.deep_symbolize_keys.should == nested_symbols
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'preserves fixnum keys' do
|
30
|
+
nested_fixnums.deep_symbolize_keys.should == nested_fixnums
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'preserves keys that cannot be symbolized' do
|
34
|
+
nested_illegal_symbols.deep_symbolize_keys.should == nested_illegal_symbols
|
35
|
+
end
|
36
|
+
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.0.
|
4
|
+
version: 0.0.11
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2012-06-
|
14
|
+
date: 2012-06-13 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: rspec
|
@@ -117,6 +117,7 @@ files:
|
|
117
117
|
- grocer.gemspec
|
118
118
|
- lib/grocer.rb
|
119
119
|
- lib/grocer/connection.rb
|
120
|
+
- lib/grocer/extensions/deep_symbolize_keys.rb
|
120
121
|
- lib/grocer/failed_delivery_attempt.rb
|
121
122
|
- lib/grocer/feedback.rb
|
122
123
|
- lib/grocer/feedback_connection.rb
|
@@ -139,6 +140,7 @@ files:
|
|
139
140
|
- spec/fixtures/example.key
|
140
141
|
- spec/fixtures/example.pem
|
141
142
|
- spec/grocer/connection_spec.rb
|
143
|
+
- spec/grocer/extensions/deep_symbolize_keys_spec.rb
|
142
144
|
- spec/grocer/failed_delivery_attempt_spec.rb
|
143
145
|
- spec/grocer/feedback_connection_spec.rb
|
144
146
|
- spec/grocer/feedback_spec.rb
|
@@ -163,18 +165,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
163
165
|
- - ! '>='
|
164
166
|
- !ruby/object:Gem::Version
|
165
167
|
version: '0'
|
166
|
-
segments:
|
167
|
-
- 0
|
168
|
-
hash: -3763223415178507043
|
169
168
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
170
169
|
none: false
|
171
170
|
requirements:
|
172
171
|
- - ! '>='
|
173
172
|
- !ruby/object:Gem::Version
|
174
173
|
version: '0'
|
175
|
-
segments:
|
176
|
-
- 0
|
177
|
-
hash: -3763223415178507043
|
178
174
|
requirements: []
|
179
175
|
rubyforge_project:
|
180
176
|
rubygems_version: 1.8.24
|
@@ -186,6 +182,7 @@ test_files:
|
|
186
182
|
- spec/fixtures/example.key
|
187
183
|
- spec/fixtures/example.pem
|
188
184
|
- spec/grocer/connection_spec.rb
|
185
|
+
- spec/grocer/extensions/deep_symbolize_keys_spec.rb
|
189
186
|
- spec/grocer/failed_delivery_attempt_spec.rb
|
190
187
|
- spec/grocer/feedback_connection_spec.rb
|
191
188
|
- spec/grocer/feedback_spec.rb
|