pushr-core 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +22 -22
- data/lib/pushr/configuration.rb +8 -0
- data/lib/pushr/core.rb +1 -0
- data/lib/pushr/error.rb +10 -0
- data/lib/pushr/feedback.rb +8 -0
- data/lib/pushr/message.rb +8 -0
- data/lib/pushr/version.rb +1 -1
- data/spec/lib/pushr/configuration_spec.rb +22 -0
- data/spec/lib/pushr/feedback_spec.rb +22 -0
- data/spec/lib/pushr/message_spec.rb +22 -0
- metadata +15 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d6e254858fcb2c4dc190b0fa1a6a296e57e91b59
|
4
|
+
data.tar.gz: aa3314e0f9fb385870eeb764ec2bbf87a4133a30
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c97e2a1940e91880215a3d55d489260df0e5e04e1e61f818b4468d876c857229a2c3ed60f07f41d72707c3fae7f25c033297c13fd9f0421f3a214af99226fe34
|
7
|
+
data.tar.gz: 2fa7792d71e250b1e63c2389f2533459f13651b153997a9a99ba4b89c6e3bef7c5c0b193cfa75215e453d77531807b3d09a372b3be96a69b4f6bc0acb31bc1bd
|
data/README.md
CHANGED
@@ -1,15 +1,12 @@
|
|
1
1
|
# Pushr
|
2
2
|
|
3
|
-
Please note: We're in the process of updating this gem. The current code is not yet stable. Please contact us if you
|
4
|
-
want to test or contribute to this project.
|
5
|
-
|
6
3
|
[![Build Status](https://travis-ci.org/9to5/pushr-core.svg?branch=master)](https://travis-ci.org/9to5/pushr-core)
|
7
4
|
[![Code Climate](https://codeclimate.com/github/9to5/pushr-core.png)](https://codeclimate.com/github/9to5/pushr-core)
|
8
5
|
[![Coverage Status](https://coveralls.io/repos/9to5/pushr-core/badge.png)](https://coveralls.io/r/9to5/pushr-core)
|
9
6
|
|
10
7
|
## Features
|
11
8
|
|
12
|
-
*
|
9
|
+
* Lightning fast push notification delivery
|
13
10
|
* Redis for queueing
|
14
11
|
* Redis or YAML for configuration
|
15
12
|
* Multi-App
|
@@ -133,18 +130,21 @@ Where `<options>` can be:
|
|
133
130
|
|
134
131
|
## Sending notifications
|
135
132
|
|
133
|
+
Use the `new` and `save` methods to create a message or use the `create` and `create!` methods. These methods are
|
134
|
+
similar to the ActiveRecord model methods.
|
135
|
+
|
136
136
|
APNS:
|
137
137
|
```ruby
|
138
138
|
Pushr::MessageApns.create(
|
139
|
-
app: 'app_name',
|
140
|
-
device: '<APNS device_token here>',
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
content_available: 1)
|
139
|
+
app: 'app_name', # required: String, the name of the configuration
|
140
|
+
device: '<APNS device_token here>', # required: String, token of the device
|
141
|
+
expiry: 1.day.from_now.to_i, # required: Integer, A UNIX epoch date expressed in seconds
|
142
|
+
priority: 10, # required: Integer, 10 or 5 (should be 10 if message includes an alert, sound or badge)
|
143
|
+
alert: 'Hello World', # optional: String or Hash, read APNS documentation for more information
|
144
|
+
sound: '1.aiff', # optional: String, sound to play
|
145
|
+
badge: 1, # optional: Integer, display badge on homescreen
|
146
|
+
attributes_for_device: {key: 'MSG'}, # optional: Hash, send additional parameters
|
147
|
+
content_available: 1) # optional: Integer, 1 if device should be notified if new content is available
|
148
148
|
```
|
149
149
|
|
150
150
|
|
@@ -168,15 +168,15 @@ Use `content_available: 1` if the iOS device should start your app upon receivin
|
|
168
168
|
GCM:
|
169
169
|
```ruby
|
170
170
|
Pushr::MessageGcm.create(
|
171
|
-
app: 'app_name',
|
172
|
-
registration_ids: ['<
|
173
|
-
notification_key: 'notification_key_name',
|
174
|
-
delay_while_idle: true,
|
175
|
-
data: { message: 'Hello World' },
|
176
|
-
time_to_live: 24 * 60 * 60,
|
177
|
-
restricted_package_name: 'com.example.gcm',
|
178
|
-
dry_run: false,
|
179
|
-
collapse_key: 'MSG')
|
171
|
+
app: 'app_name', # required: String, the name of the configuration
|
172
|
+
registration_ids: ['<registration_id>', '...'], # required: Array of registration ids
|
173
|
+
notification_key: 'notification_key_name', # optional: String, Use with User Notifications
|
174
|
+
delay_while_idle: true, # optional: Boolean, message is received if device is active
|
175
|
+
data: { message: 'Hello World' }, # optional: Hash, contains information for the app
|
176
|
+
time_to_live: 24 * 60 * 60, # optional: Integer, in seconds how long the message will be stored
|
177
|
+
restricted_package_name: 'com.example.gcm', # optional: String, message will only be received with this package name
|
178
|
+
dry_run: false, # optional: Boolean, do not actually deliver the message to the app
|
179
|
+
collapse_key: 'MSG') # optional: String, messages with the same key can be collapsed into one
|
180
180
|
```
|
181
181
|
|
182
182
|
## Feedback processing
|
data/lib/pushr/configuration.rb
CHANGED
@@ -33,6 +33,14 @@ module Pushr
|
|
33
33
|
m
|
34
34
|
end
|
35
35
|
|
36
|
+
def self.create!(attributes = {})
|
37
|
+
m = new(attributes)
|
38
|
+
unless m.save
|
39
|
+
raise Pushr::Error::RecordInvalid
|
40
|
+
end
|
41
|
+
m
|
42
|
+
end
|
43
|
+
|
36
44
|
def delete
|
37
45
|
Pushr::Core.redis { |conn| conn.hdel('pushr:configurations', key) }
|
38
46
|
end
|
data/lib/pushr/core.rb
CHANGED
data/lib/pushr/error.rb
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
module Pushr
|
2
|
+
|
3
|
+
# Module containing Pushr::Error classes, all of which extend StandardError.
|
4
|
+
module Error
|
5
|
+
|
6
|
+
# Raised if the entered authentication details (API key or username and password) are incorrect. (Error code: 2)
|
7
|
+
class RecordInvalid < StandardError
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
data/lib/pushr/feedback.rb
CHANGED
data/lib/pushr/message.rb
CHANGED
data/lib/pushr/version.rb
CHANGED
@@ -49,6 +49,28 @@ describe Pushr::Configuration do
|
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
|
+
describe 'create!' do
|
53
|
+
subject { Pushr::ConfigurationDummy.create!(app: app_name, connections: 2, enabled: true) }
|
54
|
+
|
55
|
+
context 'with app name' do
|
56
|
+
let(:app_name) { 'app_name' }
|
57
|
+
it 'should create a message' do
|
58
|
+
expect(subject.valid?).to eql true
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'should create a ConfigurationDummy class' do
|
62
|
+
expect(subject.class).to eql Pushr::ConfigurationDummy
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
context 'without app name' do
|
67
|
+
let(:app_name) { nil }
|
68
|
+
it 'should raise error' do
|
69
|
+
expect { subject }.to raise_error Pushr::Error::RecordInvalid
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
52
74
|
describe 'find' do
|
53
75
|
let!(:config) { Pushr::ConfigurationDummy.new(app: 'app_name', connections: 2, enabled: true) }
|
54
76
|
it 'should find a configuration' do
|
@@ -35,4 +35,26 @@ describe Pushr::Feedback do
|
|
35
35
|
expect(subject.class).to eql Pushr::FeedbackDummy
|
36
36
|
end
|
37
37
|
end
|
38
|
+
|
39
|
+
describe 'create!' do
|
40
|
+
subject { Pushr::FeedbackDummy.create!(app: app_name, device: 'a' * 64, follow_up: 'delete', failed_at: Time.now) }
|
41
|
+
|
42
|
+
context 'with app name' do
|
43
|
+
let(:app_name) { 'app_name' }
|
44
|
+
it 'should create a message' do
|
45
|
+
expect(subject.valid?).to eql true
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'should create a FeedbackDummy class' do
|
49
|
+
expect(subject.class).to eql Pushr::FeedbackDummy
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
context 'without app name' do
|
54
|
+
let(:app_name) { nil }
|
55
|
+
it 'should raise error' do
|
56
|
+
expect { subject }.to raise_error Pushr::Error::RecordInvalid
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
38
60
|
end
|
@@ -41,4 +41,26 @@ describe Pushr::Message do
|
|
41
41
|
expect(subject.class).to eql Pushr::MessageDummy
|
42
42
|
end
|
43
43
|
end
|
44
|
+
|
45
|
+
describe 'create!' do
|
46
|
+
subject { Pushr::MessageDummy.create!(app: app_name) }
|
47
|
+
|
48
|
+
context 'with app name' do
|
49
|
+
let(:app_name) { 'app_name' }
|
50
|
+
it 'should create a message' do
|
51
|
+
expect(subject.valid?).to eql true
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'should create a MessageDummy class' do
|
55
|
+
expect(subject.class).to eql Pushr::MessageDummy
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
context 'without app name' do
|
60
|
+
let(:app_name) { nil }
|
61
|
+
it 'should raise error' do
|
62
|
+
expect { subject }.to raise_error Pushr::Error::RecordInvalid
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
44
66
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pushr-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tom Pesman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-02-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redis
|
@@ -28,16 +28,16 @@ dependencies:
|
|
28
28
|
name: redis-namespace
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 1.4
|
33
|
+
version: '1.4'
|
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
|
-
version: 1.4
|
40
|
+
version: '1.4'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: multi_json
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -84,16 +84,16 @@ dependencies:
|
|
84
84
|
name: rspec
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- -
|
87
|
+
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: 3.0
|
89
|
+
version: '3.0'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- -
|
94
|
+
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: 3.0
|
96
|
+
version: '3.0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: guard
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -201,6 +201,9 @@ executables:
|
|
201
201
|
extensions: []
|
202
202
|
extra_rdoc_files: []
|
203
203
|
files:
|
204
|
+
- MIT-LICENSE
|
205
|
+
- README.md
|
206
|
+
- bin/pushr
|
204
207
|
- lib/generators/templates/feedback_processor.rb
|
205
208
|
- lib/generators/templates/pushr.yml
|
206
209
|
- lib/pushr/configuration.rb
|
@@ -213,12 +216,11 @@ files:
|
|
213
216
|
- lib/pushr/daemon/message_handler.rb
|
214
217
|
- lib/pushr/daemon/pid_file.rb
|
215
218
|
- lib/pushr/daemon/settings.rb
|
219
|
+
- lib/pushr/error.rb
|
216
220
|
- lib/pushr/feedback.rb
|
217
221
|
- lib/pushr/message.rb
|
218
222
|
- lib/pushr/redis_connection.rb
|
219
223
|
- lib/pushr/version.rb
|
220
|
-
- README.md
|
221
|
-
- MIT-LICENSE
|
222
224
|
- spec/lib/pushr/configuration_spec.rb
|
223
225
|
- spec/lib/pushr/daemon/app_spec.rb
|
224
226
|
- spec/lib/pushr/daemon/delivery_error_spec.rb
|
@@ -238,7 +240,6 @@ files:
|
|
238
240
|
- spec/support/pushr_feedback_processor_dummy.rb
|
239
241
|
- spec/support/pushr_invalid_configuration_dummy.rb
|
240
242
|
- spec/support/pushr_message_dummy.rb
|
241
|
-
- bin/pushr
|
242
243
|
homepage: https://github.com/9to5/pushr-core
|
243
244
|
licenses:
|
244
245
|
- MIT
|
@@ -259,7 +260,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
259
260
|
version: '0'
|
260
261
|
requirements: []
|
261
262
|
rubyforge_project:
|
262
|
-
rubygems_version: 2.
|
263
|
+
rubygems_version: 2.2.2
|
263
264
|
signing_key:
|
264
265
|
specification_version: 4
|
265
266
|
summary: Core of the pushr daemon.
|