pusher-push-notifications 1.3.0 → 2.0.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0c2390e1a4a59aac3d17169ef09419fee58805d3d2f3679d07b93f3079f8b98f
4
- data.tar.gz: 718bd77ac234dedc626dcb4c21f7a9e445a22e0c4c15279f22b3a7ada844e369
3
+ metadata.gz: 7b6ed8156fc1fb15e299754cc324357877136643d3fb11b9ee2df005eac629a0
4
+ data.tar.gz: 2beec8b29a6f2a8760490e4e8bb50e33cb0a6216147a964ee55f45522c5a3c71
5
5
  SHA512:
6
- metadata.gz: 05b38f814043989418b15f64cd51c4181a9f9baf7f19cb7110fc5cd511056e03eedcce1366612a9dda477cfcdb82bba50af03ab757c69f90269ae883d4bf1807
7
- data.tar.gz: '08631394abc01bcd223e371bc81ae939ae23ce97f0fb621a1cb6d41dca9779f4c9e91e4639a3b9493bc3ee0eb81de53f2a8a7552ea21bda5e4f3826eaf578cd5'
6
+ metadata.gz: 995111be0507cf0010fc3dbd1dd0a7661ad23ba64409e74cd72f222ed8e938b28df8d751fb28c2fe19bfff13cde35ece544937bf0b314ead0abf651c16b4459f
7
+ data.tar.gz: b293b85bbd4c64bf6300dc7b2191afc33076736ae722fd56482c89d4b934190ad0da3c2b5da522c6a961c24c9d5473fd4d33a9c3bcf02887abd79cfe34c3bbb1
data/.coveralls.yml CHANGED
@@ -1 +1 @@
1
- repo_token: uaAoIkOEP9l7PCLENpJSSVVrcm94JDNYO
1
+ repo_token: secret
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,74 @@
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: Prepare Gemfile.lock
67
+ run: |
68
+ sed -i "s|pusher-push-notifications ([^)]*)|pusher-push-notifications (${{ env.VERSION }})|" Gemfile.lock
69
+ - name: Commit changes
70
+ run: |
71
+ git add CHANGELOG.md lib/pusher/push_notifications/version.rb Gemfile.lock
72
+ git commit -m "Bump to version ${{ env.VERSION }}"
73
+ - name: Push
74
+ 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,31 @@
1
1
  # Changelog
2
2
 
3
- All notable changes to this project will be documented in this file.
3
+ ## 2.0.1
4
4
 
5
- The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
6
- and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
5
+ * [CHANGED] Update Gemfile lock on release.
7
6
 
8
- ## [Unreleased](https://github.com/pusher/push-notifications-ruby/compare/v1.3.0...HEAD)
7
+ ## 2.0.0
9
8
 
10
- ## [1.3.0](https://github.com/pusher/push-notifications-ruby/compare/v1.2.1...v1.3.0) - 2020-07-01
9
+ * [ADDED] Support for Ruby 3.0.
10
+ * [REMOVED] Support for Ruby 2.5 and below.
11
+ * [CHANGED] Refactor tests to avoid caze dependency.
11
12
 
12
- Added
13
+ ## 1.3.0
13
14
 
14
- Support for multiple instances of Beams clients to exist for more advanced use cases.
15
+ * [ADDED] Support for multiple instances of Beams clients to exist for more advanced use cases.
15
16
 
16
- ## [1.2.1](https://github.com/pusher/push-notifications-ruby/compare/v1.2.0...v1.2.1) - 2020-06-26
17
+ ## 1.2.1
17
18
 
18
- Fixed
19
+ * [FIXED] Endpoint also allows the scheme to be configured to enable for local development.
19
20
 
20
- Endpoint also allows the scheme to be configured to enable for local development.
21
+ ## 1.2.0
21
22
 
22
- ## [1.2.0](https://github.com/pusher/push-notifications-ruby/compare/v1.1.0...v1.2.0) - 2020-06-25
23
+ * [ADDED] Support for "endpoint" overrides to allow for internal integration testing.
23
24
 
24
- Added
25
+ ## 1.1.0
25
26
 
26
- Support for "endpoint" overrides to allow for internal integration testing.
27
+ * [ADDED] Support for "Authenticated Users" feature: publishToUsers, generateToken and deleteUser.
27
28
 
28
- ## [1.1.0](https://github.com/pusher/push-notifications-ruby/compare/v1.0.0...v1.1.0) - 2019-02-22
29
+ ## 1.0.0
29
30
 
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.
31
+ * [ADDED] General availability (GA) release.
data/Gemfile.lock CHANGED
@@ -1,131 +1,121 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pusher-push-notifications (1.3.0)
5
- caze (~> 0)
4
+ pusher-push-notifications (2.0.2)
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
- activesupport (5.2.2)
13
- concurrent-ruby (~> 1.0, >= 1.0.2)
14
- i18n (>= 0.7, < 2)
15
- minitest (~> 5.1)
16
- tzinfo (~> 1.1)
17
- addressable (2.5.2)
18
- public_suffix (>= 2.0.2, < 4.0)
19
- ast (2.3.0)
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.14.1)
20
+ simplecov (~> 0.16.1)
32
21
  term-ansicolor (~> 1.3)
33
- thor (~> 0.19.4)
22
+ thor (>= 0.19.4, < 2.0)
34
23
  tins (~> 1.6)
35
- crack (0.4.3)
36
- safe_yaml (~> 1.0.0)
37
- diff-lcs (1.3)
38
- docile (1.1.5)
39
- domain_name (0.5.20180417)
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.2.1)
42
- hashdiff (0.3.7)
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
- i18n (1.5.3)
46
- concurrent-ruby (~> 1.0)
47
- json (2.1.0)
48
- jwt (2.1.0)
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.2018.0812)
53
- minitest (5.11.3)
40
+ mime-types-data (3.2021.0225)
54
41
  netrc (0.11.0)
55
- parallel (1.12.1)
56
- parser (2.4.0.2)
57
- ast (~> 2.3)
58
- powerpack (0.1.1)
59
- pry (0.12.2)
60
- coderay (~> 1.1.0)
61
- method_source (~> 0.9.0)
62
- pry-byebug (3.6.0)
63
- byebug (~> 10.0)
64
- pry (~> 0.10)
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 (10.5.0)
53
+ rake (13.0.3)
68
54
  rb-readline (0.5.5)
69
- rest-client (2.0.2)
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
- rspec (3.7.0)
74
- rspec-core (~> 3.7.0)
75
- rspec-expectations (~> 3.7.0)
76
- rspec-mocks (~> 3.7.0)
77
- rspec-core (3.7.0)
78
- rspec-support (~> 3.7.0)
79
- rspec-expectations (3.7.0)
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.7.0)
82
- rspec-mocks (3.7.0)
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.7.0)
85
- rspec-support (3.7.0)
86
- rubocop (0.52.0)
73
+ rspec-support (~> 3.10.0)
74
+ rspec-support (3.10.2)
75
+ rubocop (1.11.0)
87
76
  parallel (~> 1.10)
88
- parser (>= 2.4.0.2, < 3.0)
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 (~> 1.0, >= 1.0.1)
93
- ruby-progressbar (1.9.0)
94
- safe_yaml (1.0.4)
95
- simplecov (0.14.1)
96
- docile (~> 1.1.0)
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
- term-ansicolor (1.6.0)
92
+ sync (0.5.0)
93
+ term-ansicolor (1.7.1)
101
94
  tins (~> 1.0)
102
- thor (0.19.4)
103
- thread_safe (0.3.6)
104
- tins (1.16.3)
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.5)
110
- unicode-display_width (1.3.0)
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.1.1)
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 (~> 1.16)
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 (~> 10.0)
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
- 1.16.2
126
+ 2.2.13
data/README.md CHANGED
@@ -1,7 +1,6 @@
1
1
  # Pusher Beams Ruby Server SDK
2
2
 
3
- [![Build Status](https://travis-ci.org/pusher/push-notifications-ruby.svg?branch=master)](https://travis-ci.org/pusher/push-notifications-ruby)
4
- [![Coverage Status](https://coveralls.io/repos/github/pusher/push-notifications-ruby/badge.svg?branch=update-sdk)](https://coveralls.io/github/pusher/push-notifications-ruby?branch=update-sdk)
3
+ [![Test](https://github.com/pusher/push-notifications-ruby/actions/workflows/test.yml/badge.svg)](https://github.com/pusher/push-notifications-ruby/actions/workflows/test.yml) [![Coverage Status](https://coveralls.io/repos/github/pusher/push-notifications-ruby/badge.svg)](https://coveralls.io/github/pusher/push-notifications-ruby) [![Gem](https://img.shields.io/gem/v/pusher-push-notifications)](https://rubygems.org/gems/pusher-push-notifications)
5
4
 
6
5
  Pusher Beams using the Pusher system.
7
6
 
@@ -54,6 +54,7 @@ module Pusher
54
54
  private
55
55
 
56
56
  attr_reader :config
57
+
57
58
  def_delegators :@config, :instance_id, :secret_key, :endpoint
58
59
 
59
60
  def build_publish_url(resource)
@@ -20,6 +20,7 @@ module Pusher
20
20
  private
21
21
 
22
22
  attr_reader :config
23
+
23
24
  def_delegators :@config, :instance_id, :secret_key
24
25
  end
25
26
  end
@@ -1,41 +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
- export :delete_user, as: :delete_user
14
-
15
- def initialize(user:)
16
- @user = user
17
- @user_id = Pusher::PushNotifications::UserId.new
18
-
9
+ # Contacts the Beams service
10
+ # to remove all the devices of the given user.
11
+ def self.delete_user(client, user:)
19
12
  raise UserDeletionError, 'User Id cannot be empty.' if user.empty?
13
+
20
14
  if user.length > UserId::MAX_USER_ID_LENGTH
21
15
  raise UserDeletionError, 'User id length too long ' \
22
16
  "(expected fewer than #{UserId::MAX_USER_ID_LENGTH + 1} characters)"
23
17
  end
24
- end
25
18
 
26
- # Contacts the Beams service
27
- # to remove all the devices of the given user.
28
- def delete_user
29
19
  client.delete(user)
30
20
  end
31
-
32
- private
33
-
34
- attr_reader :user
35
-
36
- def client
37
- @client ||= PushNotifications::Client.new
38
- end
39
21
  end
40
22
  end
41
23
  end
@@ -1,39 +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
- export :generate_token, as: :generate_token
14
-
15
- def initialize(user:)
16
- @user = user
17
- @user_id = Pusher::PushNotifications::UserId.new
18
-
9
+ # Creates a signed JWT for a user id.
10
+ def self.generate_token(user:)
19
11
  raise GenerateTokenError, 'User Id cannot be empty.' if user.empty?
12
+
20
13
  if user.length > UserId::MAX_USER_ID_LENGTH
21
14
  raise GenerateTokenError, 'User id length too long ' \
22
15
  "(expected fewer than #{UserId::MAX_USER_ID_LENGTH + 1} characters)"
23
16
  end
24
- end
25
17
 
26
- # Creates a signed JWT for a user id.
27
- def generate_token
28
- { 'token' => jwt_token.generate(user) }
29
- end
18
+ jwt_token = PushNotifications::Token.new
30
19
 
31
- private
32
-
33
- attr_reader :user
34
-
35
- def jwt_token
36
- @jwt_token ||= PushNotifications::Token.new
20
+ { 'token' => jwt_token.generate(user) }
37
21
  end
38
22
  end
39
23
  end
@@ -1,63 +1,42 @@
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
- export :publish, as: :publish
14
- export :publish_to_interests, as: :publish_to_interests
15
-
16
- def initialize(interests:, payload: {})
17
- @interests = interests
18
- @payload = payload
19
- @user_id = Pusher::PushNotifications::UserId.new
9
+ # Publish the given payload to the specified interests.
10
+ # <b>DEPRECATED:</b> Please use <tt>publish_to_interests</tt> instead.
11
+ def self.publish(client, interests:, payload: {})
12
+ warn "[DEPRECATION] `publish` is deprecated. \
13
+ Please use `publish_to_interests` instead."
14
+ publish_to_interests(client, interests: interests, payload: payload)
15
+ end
20
16
 
21
- valid_interest_pattern = /^(_|\-|=|@|,|\.|:|[A-Z]|[a-z]|[0-9])*$/
17
+ # Publish the given payload to the specified interests.
18
+ def self.publish_to_interests(client, interests:, payload: {})
19
+ valid_interest_pattern = /^(_|-|=|@|,|\.|:|[A-Z]|[a-z]|[0-9])*$/
22
20
 
23
21
  interests.each do |interest|
24
22
  next if valid_interest_pattern.match?(interest)
23
+
25
24
  raise PublishError,
26
25
  "Invalid interest name \nMax #{UserId::MAX_USER_ID_LENGTH}" \
27
26
  ' characters and can only contain ASCII upper/lower-case' \
28
27
  ' letters, numbers or one of _-=@,.:'
29
28
  end
30
29
 
31
- if interests.empty?
32
- raise PublishError, 'Must provide at least one interest'
33
- end
30
+ raise PublishError, 'Must provide at least one interest' if interests.empty?
31
+
34
32
  if interests.length > 100
35
33
  raise PublishError, "Number of interests #{interests.length}" \
36
34
  ' exceeds maximum of 100'
37
35
  end
38
- end
39
-
40
- # Publish the given payload to the specified interests.
41
- # <b>DEPRECATED:</b> Please use <tt>publish_to_interests</tt> instead.
42
- def publish
43
- warn "[DEPRECATION] `publish` is deprecated. \
44
- Please use `publish_to_interests` instead."
45
- publish_to_interests
46
- end
47
36
 
48
- # Publish the given payload to the specified interests.
49
- def publish_to_interests
50
37
  data = { interests: interests }.merge!(payload)
51
38
  client.post('publishes', data)
52
39
  end
53
-
54
- private
55
-
56
- attr_reader :interests, :payload
57
-
58
- def client
59
- @client ||= PushNotifications::Client.new
60
- end
61
40
  end
62
41
  end
63
42
  end
@@ -1,53 +1,33 @@
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
- export :publish_to_users, as: :publish_to_users
14
-
15
- def initialize(users:, payload: {})
16
- @users = users
17
- @user_id = Pusher::PushNotifications::UserId.new
18
- @payload = payload
19
-
9
+ # Publish the given payload to the specified users.
10
+ def self.publish_to_users(client, users:, payload: {})
20
11
  users.each do |user|
21
12
  raise UsersPublishError, 'User Id cannot be empty.' if user.empty?
22
13
 
23
14
  next unless user.length > UserId::MAX_USER_ID_LENGTH
15
+
24
16
  raise UsersPublishError, 'User id length too long ' \
25
17
  "(expected fewer than #{UserId::MAX_USER_ID_LENGTH + 1}" \
26
18
  ' characters)'
27
19
  end
28
20
 
29
- if users.count < 1
30
- raise UsersPublishError, 'Must supply at least one user id.'
31
- end
21
+ raise UsersPublishError, 'Must supply at least one user id.' if users.count < 1
22
+
32
23
  if users.length > UserId::MAX_NUM_USER_IDS
33
24
  raise UsersPublishError, "Number of user ids #{users.length} "\
34
25
  "exceeds maximum of #{UserId::MAX_NUM_USER_IDS}."
35
26
  end
36
- end
37
27
 
38
- # Publish the given payload to the specified users.
39
- def publish_to_users
40
28
  data = { users: users }.merge!(payload)
41
29
  client.post('publishes/users', data)
42
30
  end
43
-
44
- private
45
-
46
- attr_reader :users, :payload
47
-
48
- def client
49
- @client ||= PushNotifications::Client.new
50
- end
51
31
  end
52
32
  end
53
33
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Pusher
4
4
  module PushNotifications
5
- VERSION = '1.3.0'
5
+ VERSION = '2.0.2'
6
6
  end
7
7
  end
@@ -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,16 +11,8 @@ 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
27
17
  attr_reader :instance_id, :secret_key
28
18
 
@@ -34,23 +24,19 @@ module Pusher
34
24
  end
35
25
 
36
26
  def instance_id=(instance_id)
37
- if instance_id.nil? || instance_id.delete(' ').empty?
38
- raise PushError, 'Invalid instance id'
39
- end
27
+ raise PushError, 'Invalid instance id' if instance_id.nil? || instance_id.delete(' ').empty?
28
+
40
29
  @instance_id = instance_id
41
30
  end
42
31
 
43
32
  def secret_key=(secret_key)
44
- if secret_key.nil? || secret_key.delete(' ').empty?
45
- raise PushError, 'Invalid secret key'
46
- end
33
+ raise PushError, 'Invalid secret key' if secret_key.nil? || secret_key.delete(' ').empty?
34
+
47
35
  @secret_key = secret_key
48
36
  end
49
37
 
50
38
  def endpoint=(endpoint)
51
- if !endpoint.nil? && endpoint.delete(' ').empty?
52
- raise PushError, 'Invalid endpoint override'
53
- end
39
+ raise PushError, 'Invalid endpoint override' if !endpoint.nil? && endpoint.delete(' ').empty?
54
40
 
55
41
  @endpoint = endpoint
56
42
  end
@@ -60,6 +46,32 @@ module Pusher
60
46
 
61
47
  "https://#{@instance_id}.pushnotifications.pusher.com"
62
48
  end
49
+
50
+ def publish(interests:, payload: {})
51
+ UseCases::Publish.publish(client, interests: interests, payload: payload)
52
+ end
53
+
54
+ def publish_to_interests(interests:, payload: {})
55
+ UseCases::Publish.publish_to_interests(client, interests: interests, payload: payload)
56
+ end
57
+
58
+ def publish_to_users(users:, payload: {})
59
+ UseCases::PublishToUsers.publish_to_users(client, users: users, payload: payload)
60
+ end
61
+
62
+ def delete_user(user:)
63
+ UseCases::DeleteUser.delete_user(client, user: user)
64
+ end
65
+
66
+ def generate_token(user:)
67
+ UseCases::GenerateToken.generate_token(user: user)
68
+ end
69
+
70
+ private
71
+
72
+ def client
73
+ @client ||= Client.new(config: self)
74
+ end
63
75
  end
64
76
  end
65
77
  end
@@ -0,0 +1,7 @@
1
+ ## Description
2
+
3
+ Add a short description of the change. If this is related to an issue, please add a reference to the issue.
4
+
5
+ ## CHANGELOG
6
+
7
+ * [CHANGED] Describe your change here. Look at CHANGELOG.md to see the format.
@@ -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', '~> 1.16'
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', '~> 10.0'
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,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pusher-push-notifications
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 2.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lucas Medeiros
@@ -9,42 +9,28 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2020-07-02 00:00:00.000000000 Z
12
+ date: 2022-03-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: caze
15
+ name: jwt
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
18
  - - "~>"
19
19
  - !ruby/object:Gem::Version
20
- version: '0'
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: '1.16'
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: '1.16'
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: '10.0'
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: '10.0'
149
+ version: '13.0'
164
150
  - !ruby/object:Gem::Dependency
165
151
  name: rb-readline
166
152
  requirement: !ruby/object:Gem::Requirement
@@ -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,6 +265,7 @@ 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:
@@ -288,14 +279,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
288
279
  requirements:
289
280
  - - ">="
290
281
  - !ruby/object:Gem::Version
291
- version: '0'
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.0.8
289
+ rubygems_version: 3.1.2
299
290
  signing_key:
300
291
  specification_version: 4
301
292
  summary: Pusher Push Notifications Ruby server SDK
data/.travis.yml DELETED
@@ -1,8 +0,0 @@
1
- sudo: false
2
- language: ruby
3
- rvm:
4
- - 2.4.2
5
- before_install: gem install bundler -v 1.16.0
6
- script:
7
- - bundle exec rake
8
- - bundle exec rubocop