cloud_five_push 0.0.4 → 0.0.5
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.
- checksums.yaml +5 -13
- data/README.md +11 -0
- data/lib/cloud_five_push/notification.rb +19 -13
- data/lib/cloud_five_push/version.rb +1 -1
- data/lib/cloud_five_push.rb +12 -1
- data/spec/notification_spec.rb +12 -5
- metadata +17 -17
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
Y2NlMDc5OTFiNjA4ODhkZjk4ODhiZWQ4OGI0NTg2NDBjYmQ4M2ExYg==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: dc9c0537ea3f89021a5664a8185ace3d7843ba24
|
4
|
+
data.tar.gz: 62abbd862b7ade53d0e4e0c7ed4f56b01ebfb62e
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
Nzg1NDkzZmIyZDdkN2I4MWEyNjExOGYzZTEyMDBhYzczMWNiOTA4YWIyMGZh
|
11
|
-
ZWQ4NzI1MzRmMjM5MTc0NDQzN2Y1YjlkZWUyYTZlMGMwZDFkZDE=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
NGQxMGU4MmU0Nzg0ZmExM2EzN2MxNmJlY2ZjZmFjZjY4MWU0YjA0MTUxNWVk
|
14
|
-
MzBmNzRlMzQ2NmNjYTE4YWNiYTFlNDBlNjA5NDRjNjc0YzQwYWMyOWFiZGMx
|
15
|
-
OTAwM2Q3ZGY4YTJlNDc4N2FlMjI2M2JlNjllOGYwMTIyOTZjOTA=
|
6
|
+
metadata.gz: 5e2651907a3e6badc689fe89d2636472bd49f24cb956be5395117360ce463bdf8c0236e309eff4f8c6c8c40ff2116d74905d7ed10a127b0342c3a7613e3230b9
|
7
|
+
data.tar.gz: dccd455216213fa70375da9ecd3e2abbc156b9ebfe73048dee07bf6eff1c10159810d1ee8a2736d495ecb504196a472c3e64c9dab8cd8dbc1e50356873e6ce5d
|
data/README.md
CHANGED
@@ -56,6 +56,17 @@ Send a notification with custom json payload
|
|
56
56
|
notification.user_identifiers = 123
|
57
57
|
notification.data = {foo: "bar", bizz: "buzz"}
|
58
58
|
|
59
|
+
By default, all iOS notifications will be sent through the production APNs. To use the development service instead:
|
60
|
+
|
61
|
+
# set this globally, good for use in a local development server
|
62
|
+
CloudFivePush.aps_environment = :development
|
63
|
+
|
64
|
+
# or set it on-off
|
65
|
+
notification = CloudFivePush::Notification.new
|
66
|
+
notification.alert = "testing, testing, 1 2 3"
|
67
|
+
notification.aps_environment = :development
|
68
|
+
|
69
|
+
|
59
70
|
|
60
71
|
## Contributing
|
61
72
|
|
@@ -1,10 +1,10 @@
|
|
1
1
|
require 'httparty'
|
2
2
|
module CloudFivePush
|
3
3
|
class Notification
|
4
|
-
attr_accessor :user_identifiers, :alert, :message, :badge, :scheduled_at, :broadcast, :api_key, :data
|
4
|
+
attr_accessor :user_identifiers, :alert, :message, :badge, :scheduled_at, :broadcast, :api_key, :data, :aps_environment
|
5
5
|
|
6
6
|
include HTTParty
|
7
|
-
base_uri 'https://
|
7
|
+
base_uri 'https://push.cloudfiveapp.com'
|
8
8
|
# debug_output $stderr
|
9
9
|
|
10
10
|
def initialize(api_key=nil)
|
@@ -14,6 +14,7 @@ module CloudFivePush
|
|
14
14
|
end
|
15
15
|
@broadcast = false
|
16
16
|
@user_identifiers = []
|
17
|
+
@aps_environment = CloudFivePush.aps_environment
|
17
18
|
end
|
18
19
|
|
19
20
|
def notify!
|
@@ -27,6 +28,20 @@ module CloudFivePush
|
|
27
28
|
raise "Can't both broadcast and set user_identifiers"
|
28
29
|
end
|
29
30
|
|
31
|
+
self.class.post('/push/notify', body: push_params)
|
32
|
+
end
|
33
|
+
|
34
|
+
def user_identifiers=(user_identifiers)
|
35
|
+
@user_identifiers = [user_identifiers].flatten
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
def blank_param?(param)
|
41
|
+
param.nil? || param.empty?
|
42
|
+
end
|
43
|
+
|
44
|
+
def push_params
|
30
45
|
params = {
|
31
46
|
api_key: @api_key,
|
32
47
|
alert: @alert,
|
@@ -36,6 +51,7 @@ module CloudFivePush
|
|
36
51
|
params[:message] = @message if @message
|
37
52
|
params[:when] = @scheduled_at.iso8601 if @scheduled_at
|
38
53
|
params[:data] = @data.to_json if @data
|
54
|
+
params[:aps_environment] = @aps_environment.to_s if @aps_environment
|
39
55
|
|
40
56
|
if @broadcast
|
41
57
|
params[:audience] = "broadcast"
|
@@ -43,17 +59,7 @@ module CloudFivePush
|
|
43
59
|
params[:user_identifiers] = @user_identifiers
|
44
60
|
end
|
45
61
|
|
46
|
-
|
47
|
-
end
|
48
|
-
|
49
|
-
def user_identifiers=(user_identifiers)
|
50
|
-
@user_identifiers = [user_identifiers].flatten
|
51
|
-
end
|
52
|
-
|
53
|
-
private
|
54
|
-
|
55
|
-
def blank_param?(param)
|
56
|
-
param.nil? || param.empty?
|
62
|
+
params
|
57
63
|
end
|
58
64
|
|
59
65
|
end
|
data/lib/cloud_five_push.rb
CHANGED
@@ -11,19 +11,30 @@ module CloudFivePush
|
|
11
11
|
@api_key
|
12
12
|
end
|
13
13
|
|
14
|
+
@aps_environment = nil
|
15
|
+
def self.aps_environment=(aps_environment)
|
16
|
+
@aps_environment = aps_environment
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.aps_environment
|
20
|
+
@aps_environment
|
21
|
+
end
|
22
|
+
|
14
23
|
def self.broadcast!(alert, scheduled_at = nil)
|
15
24
|
notification = CloudFivePush::Notification.new
|
16
25
|
notification.broadcast = true
|
17
26
|
notification.alert = alert
|
18
27
|
notification.scheduled_at = scheduled_at
|
28
|
+
notification.aps_environment = @aps_environment
|
19
29
|
notification.notify!
|
20
30
|
end
|
21
31
|
|
22
|
-
def self.notify!(alert,
|
32
|
+
def self.notify!(alert, user_identifiers, scheduled_at = nil)
|
23
33
|
notification = CloudFivePush::Notification.new
|
24
34
|
notification.alert = alert
|
25
35
|
notification.user_identifiers = user_identifiers
|
26
36
|
notification.scheduled_at = scheduled_at
|
37
|
+
notification.aps_environment = @aps_environment
|
27
38
|
notification.notify!
|
28
39
|
end
|
29
40
|
end
|
data/spec/notification_spec.rb
CHANGED
@@ -1,18 +1,25 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe CloudFivePush::Notification do
|
4
|
-
before(:all) { CloudFivePush.api_key = "fake" }
|
5
|
-
|
6
|
-
|
7
|
-
it "accepts an array of identifiers" do
|
4
|
+
before(:all) { CloudFivePush.api_key = "fake"; }
|
5
|
+
let(:notification) { CloudFivePush::Notification.new }
|
6
|
+
context "Setting user identifiers" do
|
7
|
+
it "accepts an array of identifiers" do
|
8
8
|
notification.user_identifiers = [1,2,3]
|
9
9
|
expect(notification.user_identifiers).to eq [1,2,3]
|
10
10
|
end
|
11
11
|
|
12
|
-
it "accepts a single user_identifier" do
|
12
|
+
it "accepts a single user_identifier" do
|
13
13
|
notification.user_identifiers = 1
|
14
14
|
expect(notification.user_identifiers).to eq [1]
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
+
|
19
|
+
it "Uses the global aps_environment setting" do
|
20
|
+
CloudFivePush.aps_environment = :development
|
21
|
+
expect(notification.aps_environment).to eq :development
|
22
|
+
CloudFivePush.aps_environment = nil #reset
|
23
|
+
end
|
24
|
+
|
18
25
|
end
|
metadata
CHANGED
@@ -1,83 +1,83 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cloud_five_push
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Samson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-02-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.5'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.5'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: httparty
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: json
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
description: Dead simple push notifications
|
@@ -87,8 +87,8 @@ executables: []
|
|
87
87
|
extensions: []
|
88
88
|
extra_rdoc_files: []
|
89
89
|
files:
|
90
|
-
- .gitignore
|
91
|
-
- .rspec
|
90
|
+
- ".gitignore"
|
91
|
+
- ".rspec"
|
92
92
|
- Gemfile
|
93
93
|
- LICENSE.txt
|
94
94
|
- README.md
|
@@ -109,17 +109,17 @@ require_paths:
|
|
109
109
|
- lib
|
110
110
|
required_ruby_version: !ruby/object:Gem::Requirement
|
111
111
|
requirements:
|
112
|
-
- -
|
112
|
+
- - ">="
|
113
113
|
- !ruby/object:Gem::Version
|
114
114
|
version: '0'
|
115
115
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
116
116
|
requirements:
|
117
|
-
- -
|
117
|
+
- - ">="
|
118
118
|
- !ruby/object:Gem::Version
|
119
119
|
version: '0'
|
120
120
|
requirements: []
|
121
121
|
rubyforge_project:
|
122
|
-
rubygems_version: 2.
|
122
|
+
rubygems_version: 2.4.5
|
123
123
|
signing_key:
|
124
124
|
specification_version: 4
|
125
125
|
summary: Wraps the API for push.cloudfiveapp.com
|