pusher-push-notifications 1.3.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/stale.yml +26 -0
- data/.github/workflows/gh-release.yml +35 -0
- data/.github/workflows/publish.yml +17 -0
- data/.github/workflows/release.yml +71 -0
- data/.github/workflows/test.yml +31 -0
- data/CHANGELOG.md +14 -23
- data/Gemfile.lock +72 -82
- data/lib/pusher/push_notifications.rb +12 -19
- data/lib/pusher/push_notifications/client.rb +1 -0
- data/lib/pusher/push_notifications/token.rb +1 -0
- data/lib/pusher/push_notifications/use_cases/delete_user.rb +6 -5
- data/lib/pusher/push_notifications/use_cases/generate_token.rb +6 -5
- data/lib/pusher/push_notifications/use_cases/publish.rb +13 -10
- data/lib/pusher/push_notifications/use_cases/publish_to_users.rb +8 -8
- data/lib/pusher/push_notifications/version.rb +1 -1
- data/pull_request_template.md +7 -0
- data/pusher-push-notifications.gemspec +3 -3
- metadata +29 -38
- data/.travis.yml +0 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 30b4e2f22bdd9f95ca9c3b8e436a6593555756f2cd38937fedc3694873dd59e6
|
4
|
+
data.tar.gz: 4828505ed28d2d7104c616ad64b4a26bed4630e723681d013bef102a960029e6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 20cc5786f0d326c6b2c87542a7410f68988d9c90b79099305b59946e610777d0c99e09c020922986e5b62a160038556e00dd3c79cc5428762880a63e40877d4f
|
7
|
+
data.tar.gz: 6c0b2c93006323f152d0ee61ec6002f548e54bbe6d9a6a70a36c1ae54fadf943974c81243567b56dbde6a6941523206eafbbc3f3aad49fa2721fab50420ae110
|
data/.github/stale.yml
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# Configuration for probot-stale - https://github.com/probot/stale
|
2
|
+
|
3
|
+
# Number of days of inactivity before an Issue or Pull Request becomes stale
|
4
|
+
daysUntilStale: 90
|
5
|
+
|
6
|
+
# Number of days of inactivity before an Issue or Pull Request with the stale label is closed.
|
7
|
+
# Set to false to disable. If disabled, issues still need to be closed manually, but will remain marked as stale.
|
8
|
+
daysUntilClose: 7
|
9
|
+
|
10
|
+
# Only issues or pull requests with all of these labels are check if stale. Defaults to `[]` (disabled)
|
11
|
+
onlyLabels: []
|
12
|
+
|
13
|
+
# Issues or Pull Requests with these labels will never be considered stale. Set to `[]` to disable
|
14
|
+
exemptLabels:
|
15
|
+
- pinned
|
16
|
+
- security
|
17
|
+
|
18
|
+
# Set to true to ignore issues with an assignee (defaults to false)
|
19
|
+
exemptAssignees: true
|
20
|
+
|
21
|
+
# Comment to post when marking as stale. Set to `false` to disable
|
22
|
+
markComment: >
|
23
|
+
This issue has been automatically marked as stale because it has not had
|
24
|
+
recent activity. It will be closed if no further activity occurs. If you'd
|
25
|
+
like this issue to stay open please leave a comment indicating how this issue
|
26
|
+
is affecting you. Thank you.
|
@@ -0,0 +1,35 @@
|
|
1
|
+
name: Github Release
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [ master ]
|
6
|
+
|
7
|
+
jobs:
|
8
|
+
create-release:
|
9
|
+
name: Create Release
|
10
|
+
runs-on: ubuntu-latest
|
11
|
+
steps:
|
12
|
+
- name: Checkout code
|
13
|
+
uses: actions/checkout@v2
|
14
|
+
- name: Setup git
|
15
|
+
run: |
|
16
|
+
git config user.email "pusher-ci@pusher.com"
|
17
|
+
git config user.name "Pusher CI"
|
18
|
+
- name: Prepare description
|
19
|
+
run: |
|
20
|
+
csplit -s CHANGELOG.md "/##/" {1}
|
21
|
+
cat xx01 > CHANGELOG.tmp
|
22
|
+
- name: Prepare tag
|
23
|
+
run: |
|
24
|
+
export TAG=$(head -1 CHANGELOG.tmp | cut -d' ' -f2)
|
25
|
+
echo "TAG=$TAG" >> $GITHUB_ENV
|
26
|
+
- name: Create Release
|
27
|
+
uses: actions/create-release@v1
|
28
|
+
env:
|
29
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
30
|
+
with:
|
31
|
+
tag_name: ${{ env.TAG }}
|
32
|
+
release_name: ${{ env.TAG }}
|
33
|
+
body_path: CHANGELOG.tmp
|
34
|
+
draft: false
|
35
|
+
prerelease: false
|
@@ -0,0 +1,17 @@
|
|
1
|
+
name: RubyGems release
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [ master ]
|
6
|
+
|
7
|
+
jobs:
|
8
|
+
build:
|
9
|
+
runs-on: ubuntu-latest
|
10
|
+
|
11
|
+
steps:
|
12
|
+
- uses: actions/checkout@v1
|
13
|
+
|
14
|
+
- name: Publish gem
|
15
|
+
uses: dawidd6/action-publish-gem@v1
|
16
|
+
with:
|
17
|
+
api_key: ${{secrets.RUBYGEMS_API_KEY}}
|
@@ -0,0 +1,71 @@
|
|
1
|
+
name: Release
|
2
|
+
|
3
|
+
on:
|
4
|
+
pull_request:
|
5
|
+
types: [ labeled ]
|
6
|
+
branches:
|
7
|
+
- master
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
prepare-release:
|
11
|
+
name: Prepare release
|
12
|
+
runs-on: ubuntu-latest
|
13
|
+
|
14
|
+
steps:
|
15
|
+
- name: Set major release
|
16
|
+
if: ${{ github.event.label.name == 'release-major' }}
|
17
|
+
run: echo "RELEASE=major" >> $GITHUB_ENV
|
18
|
+
- name: Set minor release
|
19
|
+
if: ${{ github.event.label.name == 'release-minor' }}
|
20
|
+
run: echo "RELEASE=minor" >> $GITHUB_ENV
|
21
|
+
- name: Set patch release
|
22
|
+
if: ${{ github.event.label.name == 'release-patch' }}
|
23
|
+
run: echo "RELEASE=patch" >> $GITHUB_ENV
|
24
|
+
- name: Check release env
|
25
|
+
run: |
|
26
|
+
if [[ -z "${{ env.RELEASE }}" ]];
|
27
|
+
then
|
28
|
+
echo "You need to set a release label on PRs to the main branch"
|
29
|
+
exit 1
|
30
|
+
else
|
31
|
+
exit 0
|
32
|
+
fi
|
33
|
+
- name: Install semver-tool
|
34
|
+
run: |
|
35
|
+
export DIR=$(mktemp -d)
|
36
|
+
cd $DIR
|
37
|
+
curl https://github.com/fsaintjacques/semver-tool/archive/3.2.0.tar.gz -L -o semver.tar.gz
|
38
|
+
tar -xvf semver.tar.gz
|
39
|
+
sudo cp semver-tool-3.2.0/src/semver /usr/local/bin
|
40
|
+
- name: Bump version
|
41
|
+
run: |
|
42
|
+
export CURRENT=$(gem info pusher-push-notifications --remote --exact | grep -o "pusher-push-notifications ([0-9]*\.[0-9]*\.[0-9]*)" | awk -F '[()]' '{print $2}')
|
43
|
+
export NEW_VERSION=$(semver bump ${{ env.RELEASE }} $CURRENT)
|
44
|
+
echo "VERSION=$NEW_VERSION" >> $GITHUB_ENV
|
45
|
+
- name: Checkout code
|
46
|
+
uses: actions/checkout@v2
|
47
|
+
- name: Setup git
|
48
|
+
run: |
|
49
|
+
git config user.email "pusher-ci@pusher.com"
|
50
|
+
git config user.name "Pusher CI"
|
51
|
+
git fetch
|
52
|
+
git checkout ${{ github.event.pull_request.head.ref }}
|
53
|
+
- name: Prepare CHANGELOG
|
54
|
+
run: |
|
55
|
+
echo "${{ github.event.pull_request.body }}" | csplit -s - "/##/"
|
56
|
+
echo "# Changelog
|
57
|
+
|
58
|
+
## ${{ env.VERSION }}
|
59
|
+
" >> CHANGELOG.tmp
|
60
|
+
grep "^*" xx01 >> CHANGELOG.tmp
|
61
|
+
grep -v "^# " CHANGELOG.md >> CHANGELOG.tmp
|
62
|
+
cp CHANGELOG.tmp CHANGELOG.md
|
63
|
+
- name: Prepare version.rb
|
64
|
+
run: |
|
65
|
+
sed -i "s|VERSION = '[^']*'|VERSION = '${{ env.VERSION }}'|" lib/pusher/push_notifications/version.rb
|
66
|
+
- name: Commit changes
|
67
|
+
run: |
|
68
|
+
git add CHANGELOG.md lib/pusher/push_notifications/version.rb
|
69
|
+
git commit -m "Bump to version ${{ env.VERSION }}"
|
70
|
+
- name: Push
|
71
|
+
run: git push
|
@@ -0,0 +1,31 @@
|
|
1
|
+
name: Test
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [ master ]
|
6
|
+
pull_request:
|
7
|
+
branches: [ master ]
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
test:
|
11
|
+
|
12
|
+
runs-on: ubuntu-latest
|
13
|
+
strategy:
|
14
|
+
matrix:
|
15
|
+
ruby-version: ['2.6', '2.7', '3.0']
|
16
|
+
|
17
|
+
env:
|
18
|
+
PUSHER_INSTANCE_ID: 1b880590-6301-4bb5-b34f-45db1c5f5644
|
19
|
+
PUSHER_SECRET_KEY: abc
|
20
|
+
|
21
|
+
steps:
|
22
|
+
- uses: actions/checkout@v2
|
23
|
+
- name: Set up Ruby
|
24
|
+
uses: ruby/setup-ruby@v1
|
25
|
+
with:
|
26
|
+
ruby-version: ${{ matrix.ruby-version }}
|
27
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
28
|
+
- name: Run tests
|
29
|
+
run: bundle exec rake
|
30
|
+
- name: Run rubocop
|
31
|
+
run: bundle exec rubocop
|
data/CHANGELOG.md
CHANGED
@@ -1,36 +1,27 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
-
|
3
|
+
## 2.0.0
|
4
4
|
|
5
|
-
|
6
|
-
|
5
|
+
* [ADDED] Support for Ruby 3.0.
|
6
|
+
* [REMOVED] Support for Ruby 2.5 and below.
|
7
|
+
* [CHANGED] Refactor tests to avoid caze dependency.
|
7
8
|
|
8
|
-
##
|
9
|
+
## 1.3.0
|
9
10
|
|
10
|
-
|
11
|
+
* [ADDED] Support for multiple instances of Beams clients to exist for more advanced use cases.
|
11
12
|
|
12
|
-
|
13
|
+
## 1.2.1
|
13
14
|
|
14
|
-
|
15
|
+
* [FIXED] Endpoint also allows the scheme to be configured to enable for local development.
|
15
16
|
|
16
|
-
##
|
17
|
+
## 1.2.0
|
17
18
|
|
18
|
-
|
19
|
+
* [ADDED] Support for "endpoint" overrides to allow for internal integration testing.
|
19
20
|
|
20
|
-
|
21
|
+
## 1.1.0
|
21
22
|
|
22
|
-
|
23
|
+
* [ADDED] Support for "Authenticated Users" feature: publishToUsers, generateToken and deleteUser.
|
23
24
|
|
24
|
-
|
25
|
+
## 1.0.0
|
25
26
|
|
26
|
-
|
27
|
-
|
28
|
-
## [1.1.0](https://github.com/pusher/push-notifications-ruby/compare/v1.0.0...v1.1.0) - 2019-02-22
|
29
|
-
|
30
|
-
Added
|
31
|
-
|
32
|
-
Support for "Authenticated Users" feature: publishToUsers, generateToken and deleteUser.
|
33
|
-
|
34
|
-
## [1.0.0](https://github.com/pusher/push-notifications-ruby/compare/v0.3.0...v1.0.0) - 2018-07-31
|
35
|
-
|
36
|
-
- General availability (GA) release.
|
27
|
+
* [ADDED] General availability (GA) release.
|
data/Gemfile.lock
CHANGED
@@ -2,130 +2,120 @@ PATH
|
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
4
|
pusher-push-notifications (1.3.0)
|
5
|
-
caze (~> 0)
|
6
5
|
jwt (~> 2.1, >= 2.1.0)
|
7
6
|
rest-client (~> 2.0, >= 2.0.2)
|
8
7
|
|
9
8
|
GEM
|
10
9
|
remote: https://rubygems.org/
|
11
10
|
specs:
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
byebug (10.0.2)
|
21
|
-
caze (0.2.2)
|
22
|
-
activesupport (>= 3)
|
23
|
-
codecov (0.1.10)
|
24
|
-
json
|
25
|
-
simplecov
|
26
|
-
url
|
27
|
-
coderay (1.1.2)
|
28
|
-
concurrent-ruby (1.1.4)
|
29
|
-
coveralls (0.8.21)
|
11
|
+
addressable (2.7.0)
|
12
|
+
public_suffix (>= 2.0.2, < 5.0)
|
13
|
+
ast (2.4.2)
|
14
|
+
byebug (11.1.3)
|
15
|
+
codecov (0.5.1)
|
16
|
+
simplecov (>= 0.15, < 0.22)
|
17
|
+
coderay (1.1.3)
|
18
|
+
coveralls (0.8.23)
|
30
19
|
json (>= 1.8, < 3)
|
31
|
-
simplecov (~> 0.
|
20
|
+
simplecov (~> 0.16.1)
|
32
21
|
term-ansicolor (~> 1.3)
|
33
|
-
thor (
|
22
|
+
thor (>= 0.19.4, < 2.0)
|
34
23
|
tins (~> 1.6)
|
35
|
-
crack (0.4.
|
36
|
-
|
37
|
-
diff-lcs (1.
|
38
|
-
docile (1.
|
39
|
-
domain_name (0.5.
|
24
|
+
crack (0.4.5)
|
25
|
+
rexml
|
26
|
+
diff-lcs (1.4.4)
|
27
|
+
docile (1.3.5)
|
28
|
+
domain_name (0.5.20190701)
|
40
29
|
unf (>= 0.0.5, < 1.0.0)
|
41
|
-
dotenv (2.
|
42
|
-
hashdiff (0.
|
30
|
+
dotenv (2.7.6)
|
31
|
+
hashdiff (1.0.1)
|
32
|
+
http-accept (1.7.0)
|
43
33
|
http-cookie (1.0.3)
|
44
34
|
domain_name (~> 0.5)
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
method_source (0.9.2)
|
50
|
-
mime-types (3.2.2)
|
35
|
+
json (2.5.1)
|
36
|
+
jwt (2.2.2)
|
37
|
+
method_source (1.0.0)
|
38
|
+
mime-types (3.3.1)
|
51
39
|
mime-types-data (~> 3.2015)
|
52
|
-
mime-types-data (3.
|
53
|
-
minitest (5.11.3)
|
40
|
+
mime-types-data (3.2021.0225)
|
54
41
|
netrc (0.11.0)
|
55
|
-
parallel (1.
|
56
|
-
parser (
|
57
|
-
ast (~> 2.
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
public_suffix (3.0.1)
|
42
|
+
parallel (1.20.1)
|
43
|
+
parser (3.0.0.0)
|
44
|
+
ast (~> 2.4.1)
|
45
|
+
pry (0.13.1)
|
46
|
+
coderay (~> 1.1)
|
47
|
+
method_source (~> 1.0)
|
48
|
+
pry-byebug (3.9.0)
|
49
|
+
byebug (~> 11.0)
|
50
|
+
pry (~> 0.13.0)
|
51
|
+
public_suffix (4.0.6)
|
66
52
|
rainbow (3.0.0)
|
67
|
-
rake (
|
53
|
+
rake (13.0.3)
|
68
54
|
rb-readline (0.5.5)
|
69
|
-
|
55
|
+
regexp_parser (2.1.1)
|
56
|
+
rest-client (2.1.0)
|
57
|
+
http-accept (>= 1.7.0, < 2.0)
|
70
58
|
http-cookie (>= 1.0.2, < 2.0)
|
71
59
|
mime-types (>= 1.16, < 4.0)
|
72
60
|
netrc (~> 0.8)
|
73
|
-
|
74
|
-
|
75
|
-
rspec-
|
76
|
-
rspec-
|
77
|
-
|
78
|
-
|
79
|
-
|
61
|
+
rexml (3.2.4)
|
62
|
+
rspec (3.10.0)
|
63
|
+
rspec-core (~> 3.10.0)
|
64
|
+
rspec-expectations (~> 3.10.0)
|
65
|
+
rspec-mocks (~> 3.10.0)
|
66
|
+
rspec-core (3.10.1)
|
67
|
+
rspec-support (~> 3.10.0)
|
68
|
+
rspec-expectations (3.10.1)
|
80
69
|
diff-lcs (>= 1.2.0, < 2.0)
|
81
|
-
rspec-support (~> 3.
|
82
|
-
rspec-mocks (3.
|
70
|
+
rspec-support (~> 3.10.0)
|
71
|
+
rspec-mocks (3.10.2)
|
83
72
|
diff-lcs (>= 1.2.0, < 2.0)
|
84
|
-
rspec-support (~> 3.
|
85
|
-
rspec-support (3.
|
86
|
-
rubocop (
|
73
|
+
rspec-support (~> 3.10.0)
|
74
|
+
rspec-support (3.10.2)
|
75
|
+
rubocop (1.11.0)
|
87
76
|
parallel (~> 1.10)
|
88
|
-
parser (>=
|
89
|
-
powerpack (~> 0.1)
|
77
|
+
parser (>= 3.0.0.0)
|
90
78
|
rainbow (>= 2.2.2, < 4.0)
|
79
|
+
regexp_parser (>= 1.8, < 3.0)
|
80
|
+
rexml
|
81
|
+
rubocop-ast (>= 1.2.0, < 2.0)
|
91
82
|
ruby-progressbar (~> 1.7)
|
92
|
-
unicode-display_width (
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
83
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
84
|
+
rubocop-ast (1.4.1)
|
85
|
+
parser (>= 2.7.1.5)
|
86
|
+
ruby-progressbar (1.11.0)
|
87
|
+
simplecov (0.16.1)
|
88
|
+
docile (~> 1.1)
|
97
89
|
json (>= 1.8, < 3)
|
98
90
|
simplecov-html (~> 0.10.0)
|
99
91
|
simplecov-html (0.10.2)
|
100
|
-
|
92
|
+
sync (0.5.0)
|
93
|
+
term-ansicolor (1.7.1)
|
101
94
|
tins (~> 1.0)
|
102
|
-
thor (
|
103
|
-
|
104
|
-
|
105
|
-
tzinfo (1.2.5)
|
106
|
-
thread_safe (~> 0.1)
|
95
|
+
thor (1.1.0)
|
96
|
+
tins (1.28.0)
|
97
|
+
sync
|
107
98
|
unf (0.1.4)
|
108
99
|
unf_ext
|
109
|
-
unf_ext (0.0.7.
|
110
|
-
unicode-display_width (
|
111
|
-
url (0.3.2)
|
100
|
+
unf_ext (0.0.7.7)
|
101
|
+
unicode-display_width (2.0.0)
|
112
102
|
vcr (3.0.3)
|
113
|
-
webmock (3.
|
103
|
+
webmock (3.12.0)
|
114
104
|
addressable (>= 2.3.6)
|
115
105
|
crack (>= 0.3.2)
|
116
|
-
hashdiff
|
106
|
+
hashdiff (>= 0.4.0, < 2.0.0)
|
117
107
|
|
118
108
|
PLATFORMS
|
119
109
|
ruby
|
120
110
|
|
121
111
|
DEPENDENCIES
|
122
|
-
bundler (~>
|
112
|
+
bundler (~> 2.2)
|
123
113
|
codecov (~> 0)
|
124
114
|
coveralls (~> 0.8.21)
|
125
115
|
dotenv (~> 2.2, >= 2.2.1)
|
126
116
|
pry-byebug (~> 3.6, >= 3.6.0)
|
127
117
|
pusher-push-notifications!
|
128
|
-
rake (~>
|
118
|
+
rake (~> 13.0)
|
129
119
|
rb-readline (~> 0)
|
130
120
|
rspec (~> 3.0)
|
131
121
|
rubocop (>= 0.49.0)
|
@@ -133,4 +123,4 @@ DEPENDENCIES
|
|
133
123
|
webmock (~> 3.0, >= 3.0.1)
|
134
124
|
|
135
125
|
BUNDLED WITH
|
136
|
-
|
126
|
+
2.2.13
|
@@ -1,7 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'caze'
|
4
|
-
|
5
3
|
require_relative './push_notifications/client'
|
6
4
|
require_relative './push_notifications/use_cases/publish'
|
7
5
|
require_relative './push_notifications/use_cases/publish_to_users'
|
@@ -13,19 +11,18 @@ require_relative './push_notifications/token'
|
|
13
11
|
|
14
12
|
module Pusher
|
15
13
|
module PushNotifications
|
16
|
-
include Caze
|
17
|
-
|
18
14
|
class PushError < RuntimeError; end
|
19
15
|
|
20
|
-
has_use_case :publish, UseCases::Publish
|
21
|
-
has_use_case :publish_to_interests, UseCases::Publish
|
22
|
-
has_use_case :publish_to_users, UseCases::PublishToUsers
|
23
|
-
has_use_case :delete_user, UseCases::DeleteUser
|
24
|
-
has_use_case :generate_token, UseCases::GenerateToken
|
25
|
-
|
26
16
|
class << self
|
17
|
+
extend Forwardable
|
18
|
+
|
27
19
|
attr_reader :instance_id, :secret_key
|
28
20
|
|
21
|
+
def_delegators UseCases::Publish, :publish, :publish_to_interests
|
22
|
+
def_delegators UseCases::PublishToUsers, :publish_to_users
|
23
|
+
def_delegators UseCases::DeleteUser, :delete_user
|
24
|
+
def_delegators UseCases::GenerateToken, :generate_token
|
25
|
+
|
29
26
|
def configure
|
30
27
|
yield(self)
|
31
28
|
# returning a duplicate of `self` to allow multiple clients to be
|
@@ -34,23 +31,19 @@ module Pusher
|
|
34
31
|
end
|
35
32
|
|
36
33
|
def instance_id=(instance_id)
|
37
|
-
if instance_id.nil? || instance_id.delete(' ').empty?
|
38
|
-
|
39
|
-
end
|
34
|
+
raise PushError, 'Invalid instance id' if instance_id.nil? || instance_id.delete(' ').empty?
|
35
|
+
|
40
36
|
@instance_id = instance_id
|
41
37
|
end
|
42
38
|
|
43
39
|
def secret_key=(secret_key)
|
44
|
-
if secret_key.nil? || secret_key.delete(' ').empty?
|
45
|
-
|
46
|
-
end
|
40
|
+
raise PushError, 'Invalid secret key' if secret_key.nil? || secret_key.delete(' ').empty?
|
41
|
+
|
47
42
|
@secret_key = secret_key
|
48
43
|
end
|
49
44
|
|
50
45
|
def endpoint=(endpoint)
|
51
|
-
if !endpoint.nil? && endpoint.delete(' ').empty?
|
52
|
-
raise PushError, 'Invalid endpoint override'
|
53
|
-
end
|
46
|
+
raise PushError, 'Invalid endpoint override' if !endpoint.nil? && endpoint.delete(' ').empty?
|
54
47
|
|
55
48
|
@endpoint = endpoint
|
56
49
|
end
|
@@ -1,22 +1,23 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'caze'
|
4
|
-
|
5
3
|
module Pusher
|
6
4
|
module PushNotifications
|
7
5
|
module UseCases
|
8
6
|
class DeleteUser
|
9
|
-
include Caze
|
10
|
-
|
11
7
|
class UserDeletionError < RuntimeError; end
|
12
8
|
|
13
|
-
|
9
|
+
class << self
|
10
|
+
def delete_user(*args, **kwargs)
|
11
|
+
new(*args, **kwargs).delete_user
|
12
|
+
end
|
13
|
+
end
|
14
14
|
|
15
15
|
def initialize(user:)
|
16
16
|
@user = user
|
17
17
|
@user_id = Pusher::PushNotifications::UserId.new
|
18
18
|
|
19
19
|
raise UserDeletionError, 'User Id cannot be empty.' if user.empty?
|
20
|
+
|
20
21
|
if user.length > UserId::MAX_USER_ID_LENGTH
|
21
22
|
raise UserDeletionError, 'User id length too long ' \
|
22
23
|
"(expected fewer than #{UserId::MAX_USER_ID_LENGTH + 1} characters)"
|
@@ -1,22 +1,23 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'caze'
|
4
|
-
|
5
3
|
module Pusher
|
6
4
|
module PushNotifications
|
7
5
|
module UseCases
|
8
6
|
class GenerateToken
|
9
|
-
include Caze
|
10
|
-
|
11
7
|
class GenerateTokenError < RuntimeError; end
|
12
8
|
|
13
|
-
|
9
|
+
class << self
|
10
|
+
def generate_token(*args, **kwargs)
|
11
|
+
new(*args, **kwargs).generate_token
|
12
|
+
end
|
13
|
+
end
|
14
14
|
|
15
15
|
def initialize(user:)
|
16
16
|
@user = user
|
17
17
|
@user_id = Pusher::PushNotifications::UserId.new
|
18
18
|
|
19
19
|
raise GenerateTokenError, 'User Id cannot be empty.' if user.empty?
|
20
|
+
|
20
21
|
if user.length > UserId::MAX_USER_ID_LENGTH
|
21
22
|
raise GenerateTokenError, 'User id length too long ' \
|
22
23
|
"(expected fewer than #{UserId::MAX_USER_ID_LENGTH + 1} characters)"
|
@@ -1,36 +1,39 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'caze'
|
4
|
-
|
5
3
|
module Pusher
|
6
4
|
module PushNotifications
|
7
5
|
module UseCases
|
8
6
|
class Publish
|
9
|
-
include Caze
|
10
|
-
|
11
7
|
class PublishError < RuntimeError; end
|
12
8
|
|
13
|
-
|
14
|
-
|
9
|
+
class << self
|
10
|
+
def publish(*args, **kwargs)
|
11
|
+
new(*args, **kwargs).publish
|
12
|
+
end
|
13
|
+
|
14
|
+
def publish_to_interests(*args, **kwargs)
|
15
|
+
new(*args, **kwargs).publish_to_interests
|
16
|
+
end
|
17
|
+
end
|
15
18
|
|
16
19
|
def initialize(interests:, payload: {})
|
17
20
|
@interests = interests
|
18
21
|
@payload = payload
|
19
22
|
@user_id = Pusher::PushNotifications::UserId.new
|
20
23
|
|
21
|
-
valid_interest_pattern = /^(_
|
24
|
+
valid_interest_pattern = /^(_|-|=|@|,|\.|:|[A-Z]|[a-z]|[0-9])*$/
|
22
25
|
|
23
26
|
interests.each do |interest|
|
24
27
|
next if valid_interest_pattern.match?(interest)
|
28
|
+
|
25
29
|
raise PublishError,
|
26
30
|
"Invalid interest name \nMax #{UserId::MAX_USER_ID_LENGTH}" \
|
27
31
|
' characters and can only contain ASCII upper/lower-case' \
|
28
32
|
' letters, numbers or one of _-=@,.:'
|
29
33
|
end
|
30
34
|
|
31
|
-
if interests.empty?
|
32
|
-
|
33
|
-
end
|
35
|
+
raise PublishError, 'Must provide at least one interest' if interests.empty?
|
36
|
+
|
34
37
|
if interests.length > 100
|
35
38
|
raise PublishError, "Number of interests #{interests.length}" \
|
36
39
|
' exceeds maximum of 100'
|
@@ -1,16 +1,16 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'caze'
|
4
|
-
|
5
3
|
module Pusher
|
6
4
|
module PushNotifications
|
7
5
|
module UseCases
|
8
6
|
class PublishToUsers
|
9
|
-
include Caze
|
10
|
-
|
11
7
|
class UsersPublishError < RuntimeError; end
|
12
8
|
|
13
|
-
|
9
|
+
class << self
|
10
|
+
def publish_to_users(*args, **kwargs)
|
11
|
+
new(*args, **kwargs).publish_to_users
|
12
|
+
end
|
13
|
+
end
|
14
14
|
|
15
15
|
def initialize(users:, payload: {})
|
16
16
|
@users = users
|
@@ -21,14 +21,14 @@ module Pusher
|
|
21
21
|
raise UsersPublishError, 'User Id cannot be empty.' if user.empty?
|
22
22
|
|
23
23
|
next unless user.length > UserId::MAX_USER_ID_LENGTH
|
24
|
+
|
24
25
|
raise UsersPublishError, 'User id length too long ' \
|
25
26
|
"(expected fewer than #{UserId::MAX_USER_ID_LENGTH + 1}" \
|
26
27
|
' characters)'
|
27
28
|
end
|
28
29
|
|
29
|
-
if users.count < 1
|
30
|
-
|
31
|
-
end
|
30
|
+
raise UsersPublishError, 'Must supply at least one user id.' if users.count < 1
|
31
|
+
|
32
32
|
if users.length > UserId::MAX_NUM_USER_IDS
|
33
33
|
raise UsersPublishError, "Number of user ids #{users.length} "\
|
34
34
|
"exceeds maximum of #{UserId::MAX_NUM_USER_IDS}."
|
@@ -5,6 +5,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
5
5
|
require 'pusher/push_notifications/version'
|
6
6
|
|
7
7
|
Gem::Specification.new do |spec|
|
8
|
+
spec.required_ruby_version = '>= 2.4.2'
|
8
9
|
spec.name = 'pusher-push-notifications'
|
9
10
|
spec.version = Pusher::PushNotifications::VERSION
|
10
11
|
spec.authors = ['Lucas Medeiros', 'Pusher']
|
@@ -21,16 +22,15 @@ Gem::Specification.new do |spec|
|
|
21
22
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
23
|
spec.require_paths = ['lib']
|
23
24
|
|
24
|
-
spec.add_dependency 'caze', '~> 0'
|
25
25
|
spec.add_dependency 'jwt', '~> 2.1', '>= 2.1.0'
|
26
26
|
spec.add_dependency 'rest-client', '~> 2.0', '>= 2.0.2'
|
27
27
|
|
28
|
-
spec.add_development_dependency 'bundler', '~>
|
28
|
+
spec.add_development_dependency 'bundler', '~> 2.2'
|
29
29
|
spec.add_development_dependency 'codecov', '~> 0'
|
30
30
|
spec.add_development_dependency 'coveralls', '~> 0.8.21'
|
31
31
|
spec.add_development_dependency 'dotenv', '~> 2.2', '>= 2.2.1'
|
32
32
|
spec.add_development_dependency 'pry-byebug', '~> 3.6', '>= 3.6.0'
|
33
|
-
spec.add_development_dependency 'rake', '~>
|
33
|
+
spec.add_development_dependency 'rake', '~> 13.0'
|
34
34
|
spec.add_development_dependency 'rb-readline', '~> 0'
|
35
35
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
36
36
|
spec.add_development_dependency 'rubocop', '>= 0.49.0'
|
metadata
CHANGED
@@ -1,50 +1,36 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pusher-push-notifications
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lucas Medeiros
|
8
8
|
- Pusher
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2021-03-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
|
-
name:
|
15
|
+
name: jwt
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
18
|
- - "~>"
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: '
|
21
|
-
type: :runtime
|
22
|
-
prerelease: false
|
23
|
-
version_requirements: !ruby/object:Gem::Requirement
|
24
|
-
requirements:
|
25
|
-
- - "~>"
|
26
|
-
- !ruby/object:Gem::Version
|
27
|
-
version: '0'
|
28
|
-
- !ruby/object:Gem::Dependency
|
29
|
-
name: jwt
|
30
|
-
requirement: !ruby/object:Gem::Requirement
|
31
|
-
requirements:
|
20
|
+
version: '2.1'
|
32
21
|
- - ">="
|
33
22
|
- !ruby/object:Gem::Version
|
34
23
|
version: 2.1.0
|
35
|
-
- - "~>"
|
36
|
-
- !ruby/object:Gem::Version
|
37
|
-
version: '2.1'
|
38
24
|
type: :runtime
|
39
25
|
prerelease: false
|
40
26
|
version_requirements: !ruby/object:Gem::Requirement
|
41
27
|
requirements:
|
42
|
-
- - ">="
|
43
|
-
- !ruby/object:Gem::Version
|
44
|
-
version: 2.1.0
|
45
28
|
- - "~>"
|
46
29
|
- !ruby/object:Gem::Version
|
47
30
|
version: '2.1'
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 2.1.0
|
48
34
|
- !ruby/object:Gem::Dependency
|
49
35
|
name: rest-client
|
50
36
|
requirement: !ruby/object:Gem::Requirement
|
@@ -71,14 +57,14 @@ dependencies:
|
|
71
57
|
requirements:
|
72
58
|
- - "~>"
|
73
59
|
- !ruby/object:Gem::Version
|
74
|
-
version: '
|
60
|
+
version: '2.2'
|
75
61
|
type: :development
|
76
62
|
prerelease: false
|
77
63
|
version_requirements: !ruby/object:Gem::Requirement
|
78
64
|
requirements:
|
79
65
|
- - "~>"
|
80
66
|
- !ruby/object:Gem::Version
|
81
|
-
version: '
|
67
|
+
version: '2.2'
|
82
68
|
- !ruby/object:Gem::Dependency
|
83
69
|
name: codecov
|
84
70
|
requirement: !ruby/object:Gem::Requirement
|
@@ -131,36 +117,36 @@ dependencies:
|
|
131
117
|
name: pry-byebug
|
132
118
|
requirement: !ruby/object:Gem::Requirement
|
133
119
|
requirements:
|
134
|
-
- - ">="
|
135
|
-
- !ruby/object:Gem::Version
|
136
|
-
version: 3.6.0
|
137
120
|
- - "~>"
|
138
121
|
- !ruby/object:Gem::Version
|
139
122
|
version: '3.6'
|
123
|
+
- - ">="
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: 3.6.0
|
140
126
|
type: :development
|
141
127
|
prerelease: false
|
142
128
|
version_requirements: !ruby/object:Gem::Requirement
|
143
129
|
requirements:
|
144
|
-
- - ">="
|
145
|
-
- !ruby/object:Gem::Version
|
146
|
-
version: 3.6.0
|
147
130
|
- - "~>"
|
148
131
|
- !ruby/object:Gem::Version
|
149
132
|
version: '3.6'
|
133
|
+
- - ">="
|
134
|
+
- !ruby/object:Gem::Version
|
135
|
+
version: 3.6.0
|
150
136
|
- !ruby/object:Gem::Dependency
|
151
137
|
name: rake
|
152
138
|
requirement: !ruby/object:Gem::Requirement
|
153
139
|
requirements:
|
154
140
|
- - "~>"
|
155
141
|
- !ruby/object:Gem::Version
|
156
|
-
version: '
|
142
|
+
version: '13.0'
|
157
143
|
type: :development
|
158
144
|
prerelease: false
|
159
145
|
version_requirements: !ruby/object:Gem::Requirement
|
160
146
|
requirements:
|
161
147
|
- - "~>"
|
162
148
|
- !ruby/object:Gem::Version
|
163
|
-
version: '
|
149
|
+
version: '13.0'
|
164
150
|
- !ruby/object:Gem::Dependency
|
165
151
|
name: rb-readline
|
166
152
|
requirement: !ruby/object:Gem::Requirement
|
@@ -243,7 +229,7 @@ dependencies:
|
|
243
229
|
- - ">="
|
244
230
|
- !ruby/object:Gem::Version
|
245
231
|
version: 3.0.1
|
246
|
-
description:
|
232
|
+
description:
|
247
233
|
email:
|
248
234
|
- lucastoc@gmail.com
|
249
235
|
- support@pusher.com
|
@@ -253,10 +239,14 @@ extra_rdoc_files: []
|
|
253
239
|
files:
|
254
240
|
- ".coveralls.yml"
|
255
241
|
- ".env.sample"
|
242
|
+
- ".github/stale.yml"
|
243
|
+
- ".github/workflows/gh-release.yml"
|
244
|
+
- ".github/workflows/publish.yml"
|
245
|
+
- ".github/workflows/release.yml"
|
246
|
+
- ".github/workflows/test.yml"
|
256
247
|
- ".gitignore"
|
257
248
|
- ".rspec"
|
258
249
|
- ".rubocop.yml"
|
259
|
-
- ".travis.yml"
|
260
250
|
- CHANGELOG.md
|
261
251
|
- Gemfile
|
262
252
|
- Gemfile.lock
|
@@ -275,12 +265,13 @@ files:
|
|
275
265
|
- lib/pusher/push_notifications/user_id.rb
|
276
266
|
- lib/pusher/push_notifications/version.rb
|
277
267
|
- lib/pusher_push_notifications.rb
|
268
|
+
- pull_request_template.md
|
278
269
|
- pusher-push-notifications.gemspec
|
279
270
|
homepage: https://github.com/pusher/push-notifications-ruby
|
280
271
|
licenses:
|
281
272
|
- MIT
|
282
273
|
metadata: {}
|
283
|
-
post_install_message:
|
274
|
+
post_install_message:
|
284
275
|
rdoc_options: []
|
285
276
|
require_paths:
|
286
277
|
- lib
|
@@ -288,15 +279,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
288
279
|
requirements:
|
289
280
|
- - ">="
|
290
281
|
- !ruby/object:Gem::Version
|
291
|
-
version:
|
282
|
+
version: 2.4.2
|
292
283
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
293
284
|
requirements:
|
294
285
|
- - ">="
|
295
286
|
- !ruby/object:Gem::Version
|
296
287
|
version: '0'
|
297
288
|
requirements: []
|
298
|
-
rubygems_version: 3.
|
299
|
-
signing_key:
|
289
|
+
rubygems_version: 3.1.2
|
290
|
+
signing_key:
|
300
291
|
specification_version: 4
|
301
292
|
summary: Pusher Push Notifications Ruby server SDK
|
302
293
|
test_files: []
|